Game Development Reference
In-Depth Information
12 //Amount of cash for this player
13 private float cash = 0.0f;
14
15 //Reference to transform
16 private Transform ThisTransform = null;
17
18 //Respawn time in seconds after dying
19 public float RespawnTime = 2.0f;
20
21 //Get Mecanim animator component in children
22 private Animator AnimComp = null;
23
24 //------------------------------------------------
25 //Called when object is created
26 void Start()
27 {
28 //Get First person capsule and make non-visible
29 MeshRenderer Capsule = GetComponentInChildren<MeshRenderer>();
30 Capsule.enabled = false;
31
32 //Get Animator
33 AnimComp = GetComponentInChildren<Animator>();
34
35 //Get cached transform
36 ThisTransform = transform;
37 }
38 //------------------------------------------------
39 //Accessors to set and get cash
40 public float Cash
41 {
42 //Return cash value
43 get{return cash;}
44
45 //Set cash and validate, if required
46 set
47 {
48 //Set cash
49 cash = value;
50
51 //Check collection limit - post notification if limit reached
52 if(cash >= CashTotal)
53 GameManager.Notifications.PostNotification(this, "CashCollected");
54 }
55 }
56 //------------------------------------------------
57 //Function called when player dies
58 public IEnumerator Die()
59 {
60 //Disable input
61 GameManager.Instance.InputAllowed = false;
62
63 //Trigger death animation if available
Search WWH ::




Custom Search