Exemple #1
0
        private static string GetBattleStateString(Player viewingPlayer)
        {
            StringBuilder battleState = new StringBuilder();

            battleState.AppendLine(puddle.Radius.ToString());

            if (viewingPlayer == firstPlayer)
            {
                battleState.AppendLine(firstPlayer.body.Center.x + " " + firstPlayer.body.Center.y + " " + firstPlayer.reloadTimeRemaining);
                battleState.AppendLine(secondPlayer.body.Center.x + " " + secondPlayer.body.Center.y + " " + secondPlayer.reloadTimeRemaining);
            }

            if (viewingPlayer == secondPlayer)
            {
                battleState.AppendLine(secondPlayer.body.Center.x + " " + secondPlayer.body.Center.y + " " + secondPlayer.reloadTimeRemaining);
                battleState.AppendLine(firstPlayer.body.Center.x + " " + firstPlayer.body.Center.y + " " + firstPlayer.reloadTimeRemaining);
            }

            int totalBulletsCount = firstPlayer.bullets.Count + secondPlayer.bullets.Count;

            battleState.AppendLine(totalBulletsCount.ToString());

            List<Bullet> allBullets = new List<Bullet>();
            allBullets.AddRange(firstPlayer.bullets);
            allBullets.AddRange(secondPlayer.bullets);

            foreach (var bullet in allBullets)
            {
                var bulletCurrent = bullet.center;
                var bulletNext = bullet.GetNextPosition();

                battleState.AppendLine(bulletCurrent.x + " " + bulletCurrent.y + " " + bulletNext.x + " " + bulletNext.y);
            }

            return battleState.ToString();
        }
 public PlayerCommandEvaluator(Player player)
 {
     this.player = player;
 }
Exemple #3
0
        private static void LoadPlayers()
        {
            string[] algDirs = System.IO.Directory.GetDirectories("algorithms");

            AlgorithmExecutor firstPlayerAlgorithm = new AlgorithmExecutor(algDirs[0]);
            AlgorithmExecutor secondPlayerAlgorithm = new AlgorithmExecutor(algDirs[1]);

            firstPlayer = new Player(firstPlayerAlgorithm, new Circle(new Vector2(firstPlayerBodyX, 0), playerBodyRadius));
            secondPlayer = new Player(secondPlayerAlgorithm, new Circle(new Vector2(secondPlayerBodyX, 0), playerBodyRadius));

            firstPlayerCommandEvaluator = new PlayerCommandEvaluator(firstPlayer);
            secondPlayerCommandEvaluator = new PlayerCommandEvaluator(secondPlayer);
        }