Beispiel #1
0
        public Map(Map map)
        {
            Width = map.Width;
            Height = map.Height;
            UpdateManager = new UpdateManager();
            Init(false);

            // Incomplete: doesn't attempt to copy the map contents, should only used in CopyAndFlip...
        }
Beispiel #2
0
        public static List<Alien> SelectShootingAliensExcludingAliens(Map map, List<List<Alien>> Waves, Entity target, List<Alien> excludedAliens)
        {
            var aliens = FindAliensThatCanShootSafely(map, Waves);
            foreach (var alien in excludedAliens)
            {
                aliens.Remove(alien);
            }

            return aliens.Count == 0 ? null : aliens;
        }
Beispiel #3
0
        private static List<Alien> FindAliensThatCanShootSafely(Map map, List<List<Alien>> Waves)
        {
            var aliens = new List<Alien>();
            if (Waves.Count == 0)
            {
                return aliens;
            }

            AddFrontWaveAliens(Waves, aliens);
            AddSecondWaveAliensWithClearShot(map, Waves, aliens);

            return aliens;
        }
Beispiel #4
0
        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);
                }
            }
        }
Beispiel #5
0
        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;
                            }
                        }
                    }
                }
            }
        }
Beispiel #6
0
        public void StartNewGame(bool aliensDisabled = false, PlayerType turnPlayer = PlayerType.OpponentAliens)
        {
            Players.Clear();
            Players.Add(new Player(1));
            Players.Add(new Player(2));

            if (aliensDisabled)
            {
                Players[0].AlienManager.Disabled = true;
                Players[1].AlienManager.Disabled = true;
            }

            Map = new Map(Settings.Default.MapWidth, Settings.Default.MapHeight);

            UpdateRespawnPlayersIfNecessary();
            Map.UpdateEntities(turnPlayer);

            ShieldFactory.BuildInitial(1);
            ShieldFactory.BuildInitial(2);
        }