Exemplo n.º 1
0
 public void RemoveArmy(Army army)
 {
     if (ArmyList.Contains(army))
     {
         ArmyList.Remove(army);
         manager.RemoveArmy(army);
     }
     else
     {
         throw new System.ArgumentException("Attempt to remove army not owned by player");
     }
 }
Exemplo n.º 2
0
    private void AttackPlayer(Player moving, Player player)
    {
        foreach (var attacking in moving.ArmyList)
        {
            foreach (var defending in player.ArmyList)
            {
                if (armies.ArmyPosition(attacking).IsInRange(armies.ArmyPosition(defending), attacking.Range))
                {
                    defending.TakeDamage(generator.Next(1, DAMAGE));
                }
            }
        }

        for (int i = 0; i < player.ArmyList.Count; i++)
        {
            var army = player.ArmyList[i];
            if (army.Health <= 0)
            {
                armies.RemoveArmy(army);
                player.ArmyList.RemoveAt(i);
                i--;
            }
        }
    }