public bool TryApplyPowerup() { if (!IsCanApply()) { return(false); } SetAmount(0); _powerup.ApplyPowerup(); return(true); }
public bool TryApplyPowerup() { if (!IsCanApply()) { return(false); } Mana.SetAmount(0); UpdateReadyMark(); _powerup.ApplyPowerup(); return(true); }
void onTriggerEnterEvent(Collider2D col) { Debug.Log("onTriggerEnterEvent: " + col.gameObject.name); //powerup collision if (col.gameObject.tag == "Powerup") { Powerup powerup = col.gameObject.GetComponent <Powerup> (); powerup.SetPlayer(gameObject); if (powerup.IsRelevant()) { activePowerup = powerup; powerup.ApplyPowerup(); powerupEndTime = 400f; hasPowerup = true; powerup.transform.position = new Vector2(transform.position.y, 20); } } //shark collision detection if (col.gameObject.tag == "Enemy") { if (col.gameObject.GetComponent <Enemy> ().eType == "Shark") { print("shark collision"); DamagePlayer(2); Destroy(col.gameObject); } } }
private void ApplyPowerup(Powerup powerup) { if (activePowerup == powerup) { return; } // cancel any previously running powerups. if (activePowerup != null) { activePowerup.Cancel(); Destroy(activePowerup.gameObject); } SoundManager.PlaySfx(powerup.collectedSfx); activePowerup = powerup; powerup.ApplyPowerup(); }