示例#1
0
        public static GameState MineHit(GridPoint[,] board, List <string> letters, Messages messages)
        {
            foreach (var point in board)
            {
                point.IsHidden = false;
                GridPointHelper.SetDisplayCharacter(point);
            }

            DisplayBoard(board, letters);
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine(messages.Lose);
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(messages.PlayAgain);
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine();
            return(GameState.Lost);
        }
        public static GridPoint[,] AddGridPointsToBoard(this GridPoint[,] board)
        {
            var height = board.GetLength(0);
            var width  = board.GetLength(1);

            for (int x = 0; x < height; x++)
            {
                for (int y = 0; y < width; y++)
                {
                    board[x, y] = new GridPoint
                    {
                        NeighbourCoordinates = GridPointHelper.CalculateNeighbourCoordinates(x, y, height, width),
                        IsHidden             = true,
                        IsMine            = false,
                        AdjacentMineCount = 0
                    };
                }
                ;
            }
            ;
            return(board);
        }
示例#3
0
 public static GameState MineNotHit(GridPoint selectedPoint)
 {
     selectedPoint.IsHidden = false;
     GridPointHelper.SetDisplayCharacter(selectedPoint);
     return(GameState.InProgress);
 }