Example #1
0
        /// <summary>
        /// 递归调用显示周围没雷的方块
        /// </summary>
        /// <param name="currentUserButton"></param>
        ///
        public void DisplayAround(UserButton userbutton)
        {
            if (userbutton.AroundMineCount != 0)
            {
                userbutton.Open(userbutton);

                return;
            }
            else
            {
                userbutton.Open(userbutton);

                foreach (UserButton button in MineFieldGrid.Children)
                {
                    if (button.IsShow == true)
                    {
                        continue;
                    }
                    else
                    {
                        if (Math.Abs(button.x - userbutton.x) == 1 && Math.Abs(button.y - userbutton.y) == 0 && button.IsShow == false)
                        {
                            DisplayAround(button);
                        }
                        if (Math.Abs(button.y - userbutton.y) == 1 && Math.Abs(button.x - userbutton.x) == 0 && button.IsShow == false)
                        {
                            DisplayAround(button);
                        }
                        if (Math.Abs(button.x - userbutton.x) == 1 && Math.Abs(button.y - userbutton.y) == 1 && button.IsShow == false)
                        {
                            DisplayAround(button);
                        }
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// 点击鼠标事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void mouse_Press(object sender, RoutedEventArgs e)
        {
            UserButton userButton = sender as UserButton;

            //userButton.IsEnabled = false;
            userButton.IsShow = true;

            if (showNum == 0)
            {
                foreach (UserButton showButton in MineFieldGrid.Children)
                {
                    if (showButton.IsShow == true)
                    {
                        showNum++;
                    }
                }
                if (showNum == 1)
                {
                    this.showTime();
                }
            }

            if (this.IsAllMineSweeped())
            {
                this.DisplayAll();
                this.MineField_MineSweeppedSuccessfully();
            }
            else
            {
                if (userButton.HasMine)
                {
                    this.DisplayAll();
                    userButton.Open(userButton);
                    timer.Stop();

                    this.MineField_MineSweeppedFaid();
                }
                else
                {
                    this.DisplayAround(userButton);
                }
            }
        }
Example #3
0
 /// <summary>
 /// 递归调用显示周围没雷的方块
 /// </summary>
 /// <param name="currentUserButton"></param>
 /// 
 public void DisplayAround(UserButton userbutton)
 {
     if (userbutton.AroundMineCount != 0 )
     {
         userbutton.Open(userbutton);
         
         return;
     }
     else
     {
         userbutton.Open(userbutton);
        
         foreach (UserButton button in MineFieldGrid.Children)
         {
             if (button.IsShow  ==true )
             {
                 continue;
             }
             else
             {
                 if (Math.Abs(button.x - userbutton.x) == 1 && Math.Abs(button.y - userbutton.y) == 0 && button.IsShow==false )
                     DisplayAround(button);
                 if (Math.Abs(button.y - userbutton.y) == 1 && Math.Abs(button.x - userbutton.x) == 0 && button.IsShow==false )
                     DisplayAround(button);
                 if (Math.Abs(button.x - userbutton.x) == 1 && Math.Abs(button.y - userbutton.y) == 1 && button.IsShow==false )
                     DisplayAround(button);
             }
         }
     }
 }