Esempio n. 1
0
        protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
        {
            base.OnMouseLeftButtonUp(e);

            if (!IsFlagged)
            {
                if (IsMine)
                {
                    Background = new SolidColorBrush(Color.FromRgb(219, 43, 31));
                    Content    = new Image
                    {
                        Source            = new BitmapImage(new Uri(minePath)),
                        VerticalAlignment = VerticalAlignment.Center
                    };
                    Console.WriteLine("GAME OVER");
                    Game.Lose();

                    // Do game over
                }
                else
                {
                    Reveal(PosX, PosY);
                    Game.GameBoard.RevealedCount++;
                    // Check if all non-mine tiles are clear, display score
                    if (DidWin())
                    {
                        Game.Win();
                    }
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Uncovers not flagged covered tiles/explodes the bomb on described coors.
 /// </summary>
 /// <param name="x_tile">Clicked tile x coors.</param>
 /// <param name="y_tile">Clicked tile y coors.</param>
 internal void LeftClickTile(uint x_tile, uint y_tile)
 {
     if (TileState[x_tile, y_tile] == 0)
     {
         // lose condition
         if (TileBomb[x_tile, y_tile])
         {
             ClickedBomb = Tuple.Create <uint, uint>(x_tile, y_tile);
             game.Lose();
         }
         else
         {
             Uncover(x_tile, y_tile);
         }
     }
 }