private static void BuildAtX(Match game, Player player, int x)
        {
            var ship = player.Ship;
            var deltaY = player.PlayerNumber == 1 ? -1 : 1;
            List<Alien> explosions = new List<Alien>();

            for (var shieldX = x; shieldX < x + ship.Width; shieldX++)
            {
                var shieldY = ship.Y + deltaY;
                for (var counter = 0; counter < 3; counter++)
                {
                    var entity = game.Map.GetEntity(shieldX, shieldY);
                    if (entity == null)
                    {
                        game.Map.AddEntity(new Shield(player.PlayerNumber) {X = shieldX, Y = shieldY});
                    }
                    else if (entity.Type == EntityType.Alien)
                    {
                        explosions.Add((Alien) entity);
                    }
                    else if ((entity.Type == EntityType.Bullet) ||
                             (entity.Type == EntityType.Missile))
                    {
                        entity.Destroy();
                    }

                    shieldY += deltaY;
                }
            }

            foreach (var alien in explosions)
            {
                Alien.Explode(alien.X, alien.Y);
            }
        }
Exemplo n.º 2
0
 public Player(Player player)
 {
     PlayerNumber = player.PlayerNumber;
     PlayerNumberReal = player.PlayerNumberReal;
     PlayerName = player.PlayerName;
     Kills = player.Kills;
     Lives = player.Lives;
     RespawnTimer = player.RespawnTimer;
     MissileLimit = player.MissileLimit;
     Missiles = new List<Missile>(player.Missiles);
     AlienWaveSize = player.AlienWaveSize;
     AlienManager = new AlienManager(player.AlienManager);
 }
Exemplo n.º 3
0
        public static Player CopyAndFlip(Player player, CoordinateFlipper flipper,
            Dictionary<int, Entity> flippedEntities)
        {
            var copy = new Player(player)
            {
                PlayerNumber = player.PlayerNumber == 1 ? 2 : 1
            };

            copy.Missiles.Clear();
            foreach (var missile in player.Missiles)
            {
                copy.Missiles.Add(flippedEntities.ContainsKey(missile.Id)
                    ? (Missile) flippedEntities[missile.Id]
                    : Missile.CopyAndFlip(missile, flipper, flippedEntities));
            }

            if (player.MissileController != null)
            {
                copy.MissileController = MissileController.CopyAndFlip(player.MissileController, flipper, flippedEntities);
            }

            if (player.AlienFactory != null) {
                copy.AlienFactory = AlienFactory.CopyAndFlip (player.AlienFactory, flipper, flippedEntities);
            }

            copy.AlienManager = AlienManager.CopyAndFlip(player.AlienManager, flipper, flippedEntities);

            if (player.Ship != null) {
                copy.Ship = Ship.CopyAndFlip(player.Ship, flipper, flippedEntities);
            }

            return copy;
        }