Game Development Reference
In-Depth Information
086 //Wait for recovery before re-enabling CanFire
087 yield return new WaitForSeconds(RecoveryDelay);
088
089 //Re-enable CanFire
090 CanFire = true;
091 }
092 //------------------------------------------------
093 //Called when animation has completed playback
094 public void SpriteAnimationStopped()
095 {
096 //If not equipped then exit
097 if(!IsEquipped) return;
098
099 //Show default sprite
100 DefaultSprite.enabled = true;
101 }
102 //------------------------------------------------
103 //Equip weapon
104 public bool Equip(WEAPON_TYPE WeaponType)
105 {
106 //If not this type, then exit and no equip
107 if((WeaponType != Type) || (!Collected) || (Ammo == 0) || (IsEquipped))
return false;
108
109 //Is this weapon. So equip
110 IsEquipped = true;
111
112 //Show default sprite
113 DefaultSprite.enabled = true;
114
115 //Activate Can Fire
116 CanFire = true;
117
118 //Send weapon change event
119 GameManager.Notifications.PostNotification(this, "WeaponChange");
120
121 //Weapon was equipped
122 return true;
123 }
124 //------------------------------------------------
125 //Weapon change event - called when player changes weapon
126 public void WeaponChange(Component Sender)
127 {
128 //Has player changed to this weapon?
129 if(Sender.GetInstanceID() == GetInstanceID()) return;
130
131 //Has changed to other weapon. Hide this weapon
132 StopAllCoroutines();
133 gameObject.SendMessage("StopSpriteAnimation", 0,
SendMessageOptions.DontRequireReceiver);
134
Search WWH ::




Custom Search