Beispiel #1
0
        public bool Fight(TroopInventory defender)
        {
            TroopInventory attacker = this;

            Troop attackerTroop = attacker.GetInitialTroop();
            Troop defenderTroop = defender.GetInitialTroop();

            while (attackerTroop != null && defenderTroop != null)
            {
                attackerTroop.Fight(defenderTroop);
                if (attackerTroop.health <= 0)
                {
                    attacker.RemoveUnit(attackerTroop.type, 1);
                    attackerTroop = attacker.GetNextTroop(attackerTroop.type);
                }
                if (defenderTroop.health <= 0)
                {
                    defender.RemoveUnit(defenderTroop.type, 1);
                    defenderTroop = defender.GetNextTroop(defenderTroop.type);
                }
            }
            return(defender.GetTroopCount() > 0 ? false : true);
        }
Beispiel #2
0
 public void StartFight()
 {
     Troop.Fight(startCity.cityInfo.troops, targetCity.cityInfo.troops);
     ShowFightDeathScreen();
 }