Beispiel #1
0
        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);
        }
Beispiel #2
0
        // 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();
 }
Beispiel #4
0
        // Coroutine for delayed expiring
        private IEnumerator PowerUpExpiring(IArmed armed)
        {
            yield return(new WaitForSeconds(_duration));

            PowerUpExpired(armed);
        }
Beispiel #5
0
 // Actions which happen when the powerup expires
 public void PowerUpExpired(IArmed armed)
 {
     armed.RestoreOriginalFireRate();
     Destroy(gameObject);
 }