// private void EnemyNearPlanet(Ship ship) // { // foreach (var planet in GameMap.GetAllPlanets().Values) // { // if (ship.GetDistanceTo(planet) > planet.GetRadius() + Constants.DOCK_RADIUS) // { // continue; // } // // if (EnemyShipsWithinDockingDistance.ContainsKey(planet)) // { // EnemyShipsWithinDockingDistance[planet].Add(ship); // } // else // { // EnemyShipsWithinDockingDistance.Add(planet, new List<Ship>(){ship}); // } // } // } private void UpdatePlanets() { //Reset lists ClaimedPlanets.Clear(); UnClaimedPlanets.Clear(); // EnemyShipsWithinDockingDistance.Clear(); foreach (var pair in GameMap.GetAllPlanets()) { var planet = pair.Value; if (planet.IsOwned()) { ClaimedPlanets.Add(planet); } else { UnClaimedPlanets.Add(planet); } } }
private void UpdateLeader() { var totalShips = 0; var leaderShipCount = Leader.GetShips().Count(s => s.Value.GetHealth() > 0); var leaderPlanetCount = ClaimedPlanets.Count(p => p.GetOwner() == Leader.GetId()); foreach (var player in GameMap.GetAllPlayers()) { var shipCount = GetPlayerShipCount(player); totalShips += shipCount; var planetCount = ClaimedPlanets.Count(p => p.GetOwner() == player.GetId()); if (leaderShipCount < shipCount && leaderPlanetCount <= planetCount) { Leader = player; leaderShipCount = shipCount; leaderPlanetCount = planetCount; } } MyShipsOverEnemyPercentage = (double)MyShips.Count / totalShips; }