Game Development Reference
In-Depth Information
057 //------------------------------------------------
058 //Accessors to set and get cash
059 public float Cash
060 {
061 //Return cash value
062 get{return cash;}
063
064 //Set cash and validate, if required
065 set
066 {
067 //Set cash
068 cash = value;
069
070 //Check collection limit - post notification if limit reached
071 if(cash >= CashTotal)
072 GameManager.Notifications.PostNotification(this, "CashCollected");
073 }
074 }
075 //------------------------------------------------
076 //Accessors to set and get health
077 public int Health
078 {
079 //Return health value
080 get{return health;}
081
082 //Set health and validate, if required
083 set
084 {
085 health = value;
086
087 //Playe Die functionality
088 if(health <= 0) gameObject.SendMessage("Die",SendMessageOptions.
DontRequireReceiver);
089 }
090 }
091 //------------------------------------------------
092 //Function to apply damage to the player
093 public IEnumerator ApplyDamage(int Amount = 0)
094 {
095 //Reduce health
096 Health -= Amount;
097
098 //Post damage notification
099 GameManager.Notifications.PostNotification(this, "PlayerDamaged");
100
101 //Show damage texture
102 ShowDamage = true;
103
104 //Wait for interval
105 yield return new WaitForSeconds(DamageInterval);
106
Search WWH ::




Custom Search