Exemple #1
0
        private void Explode(ButtonExtended b)
        {
            if (timer.Enabled)
            {
                timer.Stop();
            }
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    if (allButtons[x, y].isBomb)
                    {
                        allButtons[x, y].Text = "*";
                    }
                }
            }
            DialogRestartOrContinue form = new DialogRestartOrContinue($"You lose :-( (\n\rYour time is {Time}");

            form.ShowDialog();
            if (form.DialogResult() == '1')
            {
                RestartToolStripMenuItem_Click(0, null);
            }
            else if (form.DialogResult() == '0')
            {
                status = 1;
            }
            else
            {
                Close();
            }
            //MessageBox.Show($"Вы проиграли (\n\rВаше время - {Time}");
            //status = 1;
        }
Exemple #2
0
 private void CheckWin()
 {
     if (status == 0)
     {
         int check   = 0;
         int allOpen = 0;
         for (int x = 0; x < width; x++)
         {
             for (int y = 0; y < height; y++)
             {
                 if (allButtons[x, y].isBomb && allButtons[x, y].isFlag)
                 {
                     check++;
                 }
                 if (!allButtons[x, y].isBomb && (allButtons[x, y].Text != "" || allButtons[x, y].isClearAround == false))
                 {
                     allOpen++;
                 }
             }
         }
         if (check == CountBombs || CountBombs + allOpen == allButtons.Length)
         {
             if (timer.Enabled)
             {
                 timer.Stop();
             }
             DialogRestartOrContinue form = new DialogRestartOrContinue($"You win !!!\n\rYour time is {Time}");
             form.ShowDialog();
             if (form.DialogResult() == '1')
             {
                 RestartToolStripMenuItem_Click(0, null);
             }
             else if (form.DialogResult() == '0')
             {
                 status = 1;
             }
             else
             {
                 Close();
             }
         }
     }
 }
Exemple #3
0
 private void changeColor(int sum, int x, int y)
 {
     if (sum == 4)
     {
         pics[x, y].BackColor = Color.Pink;
     }
     else if (sum == 8)
     {
         pics[x, y].BackColor = Color.FromArgb(255, 165, 0);
     }
     else if (sum == 16)
     {
         pics[x, y].BackColor = Color.FromArgb(255, 165, 79);
     }
     else if (sum == 32)
     {
         pics[x, y].BackColor = Color.FromArgb(255, 52, 179);
     }
     else if (sum == 64)
     {
         pics[x, y].BackColor = Color.FromArgb(244, 164, 96);
     }
     else if (sum == 128)
     {
         pics[x, y].BackColor = Color.FromArgb(205, 133, 63);
     }
     else if (sum == 256)
     {
         pics[x, y].BackColor = Color.FromArgb(255, 48, 48);
     }
     else if (sum == 512)
     {
         pics[x, y].BackColor = Color.FromArgb(255, 106, 106);
     }
     else if (sum == 1024)
     {
         pics[x, y].BackColor = Color.FromArgb(255, 69, 0);
     }
     else if (sum == 2048)
     {
         pics[x, y].BackColor = Color.Red;
         if (questionEnd == 0)
         {
             DialogRestartOrContinue form = new DialogRestartOrContinue($"Congratulation !\n\rYou win !\n\rYour score : {score}\n\rDo you want to cotinue the game ?");
             form.ShowDialog();
             if (form.DialogResult() == '1')
             {
                 RestartMenu_Click(0, null);
             }
             else if (form.DialogResult() == '0')
             {
                 questionEnd = 1;
             }
             else
             {
                 Exit_Click(0, null);
             }
         }
     }
     else if (sum == 4096)
     {
         pics[x, y].BackColor = Color.Green; labels[x, y].ForeColor = Color.White;
     }
     else if (sum == 8192)
     {
         pics[x, y].BackColor = Color.Brown; labels[x, y].ForeColor = Color.White;
     }
     else if (sum == 16384)
     {
         pics[x, y].BackColor = Color.Black; labels[x, y].ForeColor = Color.White;
     }
     if (sum > maxBlock)
     {
         maxBlock = sum;
     }
 }