private static void AddSecondWaveAliensWithClearShot(Map map, List<List<Alien>> Waves, List<Alien> aliens) { if (Waves.Count < 2) return; var wave = Waves[1]; foreach (var alien in wave) { var offsetY = alien.PlayerNumber == 1 ? -2 : 2; var entityInFront = map.GetEntity(alien.X, alien.Y + offsetY); if ((entityInFront == null) || (entityInFront.GetType() != typeof(Alien))) { aliens.Add(alien); } } }
private Match(List<BuildingInfo> buildingsAvailable, Map map, List<Player> players, int roundNumber, int roundLimit) { BuildingsAvailable = buildingsAvailable; Map = map; Players = players; RoundNumber = roundNumber; RoundLimit = roundLimit; //test Depth = 0; //reconcile for (var y = 1; y < map.Height - 1; y++) { for (var x = 1; x < map.Width - 1; x++) { var entity = map.GetEntity(x, y); if (entity == null) continue; var type = entity.GetType(); var player = GetPlayer(entity.PlayerNumber); if (type == typeof(Ship)) { player.Ship = (Ship)entity; } else if (type == typeof(Dueler.Entities.Buildings.AlienFactory)) { player.AlienFactory = (Dueler.Entities.Buildings.AlienFactory)entity; } else if (type == typeof(MissileController)) { player.MissileController = (MissileController)entity; } else if (type == typeof(Alien)) { foreach (var wave in player.AlienManager.Waves) { for (var i = 0; i < wave.Count; i++) { if (wave[i].Id == entity.Id) { wave[i] = (Alien)entity; break; } } } } else if (type == typeof(Missile)) { for (var i = 0; i < player.Missiles.Count; i++) { if (player.Missiles[i].Id == entity.Id) { player.Missiles[i] = (Missile)entity; break; } } } } } }