Example #1
0
 private static bool CheckForDeadPlayers(char[,] gameField, PlayerCordinates player)
 {
     if (gameField[player.Row, player.Col] == '*')
     {
         gameField[player.Row, player.Col] = player.Sign;
         return(true);
     }
     else
     {
         gameField[player.Row, player.Col] = 'x';
         return(false);
     }
 }
Example #2
0
        private static void Move(char[,] gameField, PlayerCordinates player, string playerMove)
        {
            switch (playerMove)
            {
            case "up":
                if (player.Row == 0)
                {
                    player.Row = gameField.GetLength(1) - 1;
                }
                else
                {
                    player.Row--;
                }
                break;

            case "down":
                if (player.Row == gameField.GetLength(1) - 1)
                {
                    player.Row = 0;
                }
                else
                {
                    player.Row++;
                }
                break;

            case "left":
                if (player.Col == 0)
                {
                    player.Col = gameField.GetLength(0) - 1;
                }
                else
                {
                    player.Col--;
                }
                break;

            case "right":
                if (player.Col == gameField.GetLength(0) - 1)
                {
                    player.Col = 0;
                }
                else
                {
                    player.Col++;
                }
                break;
            }
        }
Example #3
0
        private static void FillUpTheMatrix(int matrixRowsAndCols, char[,] gameField, PlayerCordinates firstPlayer, PlayerCordinates secondPlayer)
        {
            for (int rows = 0; rows < matrixRowsAndCols; rows++)
            {
                var field = Console.ReadLine();

                for (int columns = 0; columns < matrixRowsAndCols; columns++)
                {
                    gameField[rows, columns] = field[columns];

                    if (field[columns] == firstPlayer.Sign)
                    {
                        firstPlayer.Row = rows;
                        firstPlayer.Col = columns;
                    }

                    if (field[columns] == secondPlayer.Sign)
                    {
                        secondPlayer.Row = rows;
                        secondPlayer.Col = columns;
                    }
                }
            }
        }