예제 #1
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);
 }
예제 #2
0
        private static void BuildBuilding(Match game, Player player, Building building)
        {
            var deltaY = building.PlayerNumber == 1 ? 1 : -1;
            var ship = player.Ship;

            if (building.LivesCost > player.Lives)
            {
                throw new NotEnoughLivesException();
            }

            building.X = ship.X;
            building.Y = ship.Y + deltaY;
            game.Map.AddEntity(building);
            player.Lives -= building.LivesCost;
        }
예제 #3
0
        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)
                    {
                        var shield = new Shield(player.PlayerNumber) { X = shieldX, Y = shieldY };

                        game.Map.AddEntity(shield);

                        //test
                        Match.GetInstance().Map.AddTempEntity(new NodeEntity(Match.GetInstance().Depth,shield ));
                    }
                    else if (entity.Type == EntityType.Alien)
                    {
                        explosions.Add((Alien)entity);
                    }
                    else if ((entity.Type == EntityType.Bullet) ||
                             (entity.Type == EntityType.Missile))
                    {
                        Match.GetInstance().Map.AddKillEntity(new NodeEntity(Match.GetInstance().Depth, entity, hasMoved: false, isExplosion: true));
                        entity.Destroy();
                    }

                    shieldY += deltaY;
                }
            }

            foreach (var alien in explosions)
            {
                Alien.Explode(alien.X, alien.Y);
            }
        }
예제 #4
0
        private static double GetWhipsAndPunches(Player player)
        {
            var whips = 0.0;
            var lives = player.Lives;
            var controller = player.MissileController;
            var factory = player.AlienFactory;
            var game = Match.GetInstance();
            var homePlayerNumber = player.PlayerNumber;
            var ship = player.Ship;

            if (lives < Settings.Default.LivesInitial
                && (controller == null && factory == null))
            {
                whips -= 100;
            }

            if (ship != null)
            {
                if (ShipKanKillInTheNextRound(game, player.Ship, homePlayerNumber))
                {
                    whips += 0.5;
                }
            }
            else
            {
                whips -= 50;
            }

            var opponentWaveWidth = AlienWaveWidth(homePlayerNumber);
            var homeWaveWidth = AlienWaveWidth(2);

            var opponentWaveHeight = AlienWaveHeight(homePlayerNumber);

            whips -= (250 * opponentWaveWidth + 500 * opponentWaveHeight);

            if (opponentWaveWidth >= 12) whips -= (opponentWaveWidth - homeWaveWidth);

            return whips;
        }
예제 #5
0
        private static List<ShipCommand> FindLegalShipCommands(Match game, Player player, int playerNumber, List<ShipCommand> list)
        {
            var ship = player.Ship;

            if (ShipMustMoveRight(game, ship, playerNumber))
            {
                return new List<ShipCommand> { ShipCommand.MoveRight };
            }

            if (ShipMustMoveLeft(game, ship, playerNumber))
            {
                return new List<ShipCommand> { ShipCommand.MoveLeft };
            }

            if (ShipMustShoot(game, ship, playerNumber))
            {
                return new List<ShipCommand> { ShipCommand.Shoot };
            }

            if (ShipMustShieldBuildingOnRight(game, ship, playerNumber))
            {
                return new List<ShipCommand> { ShipCommand.MoveRight };
            }

            if (ShipMustShieldBuildingOnLeft(game, ship, playerNumber))
            {
                return new List<ShipCommand> { ShipCommand.MoveLeft };
            }

            if (ShipKanKill(game, ship, playerNumber))
            {
                return new List<ShipCommand> { ShipCommand.Shoot };
            }

            if (!ShipKanMoveRight(game, ship, playerNumber))
            {
                list.Remove(ShipCommand.MoveRight);
            }

            if (!ShipKanMoveLeft(game, ship, playerNumber))
            {
                list.Remove(ShipCommand.MoveLeft);
            }

            if (!ShipKanBuildController(game, ship, playerNumber))
            {
                list.Remove(ShipCommand.BuildMissileController);
            }

            if (!ShipKanBuildFactory(game, ship, playerNumber))
            {
                list.Remove(ShipCommand.BuildAlienFactory);
            }

            list.Remove(ShipCommand.Shoot);
            list.Remove(ShipCommand.BuildShield);
            return list;
        }