Пример #1
0
        private void GameOver()
        {
            boardView.GameOver();
            Image fail = new Image()
            {
                Source = new BitmapImage(new Uri(@"/Resources/sad.png", UriKind.Relative)), Margin = new Thickness(0)
            };

            mainButton.Content = fail;
            timer.Stop();
            UniGrid.IsEnabled = false;
        }
Пример #2
0
 public void Activate()
 {
     if (!IsRevealed && !IsFlagged)
     {
         IsRevealed    = true;
         BTN.IsEnabled = false;
         board.UnrevealedButtons.Remove(this);
         if (IsMine)
         {
             BTN.Background = Brushes.Red;
             Image i = new Image();
             i.Source    = new BitmapImage(new Uri("Assets/Mine.png", UriKind.Relative));
             BTN.Content = i;
             board.GameOver();
         }
         else
         {
             // Set Text to number of neighbors.
             int Count = board.CountMineNeighbors(X, Y);
             if (Count > 0)
             {
                 BTN.Content    = Count;
                 BTN.Foreground = Colors[Count - 1];
                 board.RevealedButtons.Add(this);
             }
             else
             {
                 // 0 neighbors that are mines, so activate each one.
                 foreach (RelativePositions pos in Enum.GetValues(typeof(RelativePositions)))
                 {
                     MineButton b = GetNeighbor(pos);
                     if (b != null && b.IsRevealed == false)
                     {
                         b.Activate();
                     }
                 }
             }
         }
     }
 }