//logic for powerups public void AbsorbPowerUp(GameObject go) { Powerup pu = go.GetComponent <Powerup>(); switch (pu.type) { //the shield powerup. It raises the hero's shield level by 1 case WeaponType.shield: if (_shieldLvl < 4) { _shieldLvl += 1; } break; //the invincibility powerup. Makes the hero invulnerable for a short time and turns the hero yellow for that duration. case WeaponType.invincibility: _isInvincible = true; _startInvin = Time.time; ShowInvin(); break; //the nuke powerup. It destroys all enemies onscreen. case WeaponType.nuke: Main.MAIN_SINGLETON.nuke(); break; } pu.AbsorbedBy(this.gameObject); }
public void AbsorbPowerUp(GameObject go) { Powerup pu = go.GetComponent <Powerup>(); switch (pu.type) { case WeaponType.shield: shieldLevel++; shield.shieldLevel = shieldLevel; break; default: weapon.SetType(pu.type); break; } pu.AbsorbedBy(this.gameObject); }