public Troop GetRandomTroop(Platoon platoon) { Random random = new Random(); int randomId = random.Next(0, platoon.GetCount() - 1); int count = platoon.GetTroops().Count; if (count > 0) { return(platoon.GetTroops()[randomId]); } return(null); }
public void TakeDammage(Platoon enemyPlatoon) { Random random = new Random(); for (int i = 0; i < enemyPlatoon.GetCount(); i++) { int randomTroopId = random.Next(0, _allTroops.Count - 1); if (enemyPlatoon.GetCount() < 0) { Troop enemyTroop = GetRandomTroop(enemyPlatoon); if (enemyTroop != null) { _allTroops[randomTroopId].TakeDammage(enemyTroop.Dammage, enemyTroop.DammageType); } } else { _allTroops[randomTroopId].TakeDammage(enemyPlatoon.GetTroops()[enemyPlatoon.GetTroops().Count - 1].Dammage, enemyPlatoon.GetTroops()[enemyPlatoon.GetTroops().Count - 1].DammageType); } } RemoveDeadTroops(); }