コード例 #1
0
ファイル: Game.cs プロジェクト: erickruiz29/Robots
 public void ResetGame()
 {
     _player = new Player();
     _robots = new List<IRobot>();
     _arena = new Arena(_player, _robots);
     _arena.DrawArena();
 }
コード例 #2
0
ファイル: Game.cs プロジェクト: erickruiz29/Robots
        public string StartGame()
        {
            while (_player.GetHealth() > 0)
            {
                var keyPress = GameHelper.GetKeyPress();

                switch (keyPress)
                {
                    case ConsoleKey.UpArrow:
                        MoveAction(GameHelper.PlayerAction.Move.Up);
                        break;
                    case ConsoleKey.DownArrow:
                        MoveAction(GameHelper.PlayerAction.Move.Down);
                        break;
                    case ConsoleKey.LeftArrow:
                        MoveAction(GameHelper.PlayerAction.Move.Left);
                        break;
                    case ConsoleKey.RightArrow:
                        MoveAction(GameHelper.PlayerAction.Move.Right);
                        break;
                    case ConsoleKey.W:
                        AttackAction(GameHelper.PlayerAction.Attack.Up);
                        break;
                    case ConsoleKey.S:
                        AttackAction(GameHelper.PlayerAction.Attack.Down);
                        break;
                    case ConsoleKey.A:
                        AttackAction(GameHelper.PlayerAction.Attack.Left);
                        break;
                    case ConsoleKey.D:
                        AttackAction(GameHelper.PlayerAction.Attack.Right);
                        break;
                }

                _arena.DrawArena();
            }

            string k;
            do
            {
                Console.WriteLine("Player again? (y/n)");
                k = Console.ReadLine()?.ToLower();
            } while (k != "y" && k != "n");

            return k;
        }