Example #1
0
        void Attack()
        {
            double attackerDamage = Attacker.Unit.GetDamage(Defender.Unit, true);

            Attacker.SetDamage(attackerDamage);
            switch (AttackType)
            {
            case AttackType.GroundAttack:
                double defenderDamage = Defender.Unit.GetDamage(Attacker.Unit, false);
                Defender.SetDamage(defenderDamage);
                GroundAttack();
                break;

            case AttackType.ArtilleryAttack:
                Defender.SetDamageReduction(Defender.Unit.Stats.BombardmentDefence.Value);
                Bombard();
                break;

            case AttackType.AirAttack:
                Attacker.SetDamageReduction(Attacker.Unit.Stats.AntiAirDefence.Value);
                Defender.SetDamageReduction(Defender.Unit.Stats.BombardmentDefence.Value);
                Bombard();
                break;

            default:
                throw new Exception("Unknown attack type specified");
            }
        }