public static bool Battle(Player player, IArmed enemy) { if (player == null) { throw new ArgumentException("Player can not be null"); } if (enemy == null) { throw new ArgumentException("Player can not fight with null enemy"); } var battleResult = player.CanBeat(enemy.Army); if (!battleResult) { player.Die(); } return(battleResult); }
// Actual effect which powerup has on entity it was applied to public void ApplyTo(IArmed armed) { //check for already applied powerup and disable it before applying current one //this logic may be changed if there are different types of energy powerups //with different fire rate multipliers and durations if (ActiveEnergyPowerUp != null) { ActiveEnergyPowerUp.PowerUpExpired(armed); } ActiveEnergyPowerUp = this; armed.MultiplyFireRate(_fireRateMultiplier); StartCoroutine(PowerUpExpiring(armed)); _isApplied = true; _representation.enabled = false; //hide this powerup }
public void HitByWeapon(WeaponModel weaponModel, IArmed other) { //ship is hit not the player //Deactivate(); }
// Coroutine for delayed expiring private IEnumerator PowerUpExpiring(IArmed armed) { yield return(new WaitForSeconds(_duration)); PowerUpExpired(armed); }
// Actions which happen when the powerup expires public void PowerUpExpired(IArmed armed) { armed.RestoreOriginalFireRate(); Destroy(gameObject); }