Exemplo n.º 1
0
        private void UpdateCounts(int Shape)
        {
            ButtonProcceed.ChangeImage(FTR.Properties.Resources.Generate);
            switch (Shape)
            {
            case 0:
                ScreenCounts[6].ChangeImage(GetCountPreview(Quanities[Shape]));
                return;

            case 1:
                ScreenCounts[3].ChangeImage(GetCountPreview(Quanities[Shape]));
                return;

            case 2:
                ScreenCounts[0].ChangeImage(GetCountPreview(Quanities[Shape]));
                return;

            case 3:
                ScreenCounts[2].ChangeImage(GetCountPreview(Quanities[Shape]));
                return;

            case 4:
                ScreenCounts[5].ChangeImage(GetCountPreview(Quanities[Shape]));
                return;

            case 5:
                ScreenCounts[1].ChangeImage(GetCountPreview(Quanities[Shape]));
                return;

            case 6:
                ScreenCounts[4].ChangeImage(GetCountPreview(Quanities[Shape]));
                return;
            }
        }
Exemplo n.º 2
0
 public override void ButtonsCheck(Form1 Window, Sprite sprite)
 {
     if (sprite == ButtonBack)
     {
         Clear();
         GC.SuppressFinalize(this);
         Window.LoadLevel(new Menu());
     }
     else if (sprite == ButtonProcceed)
     {
         if (TetrominosInUse == 0 && (Width * Height) % 4 == 0)
         {
             Clear();
             GC.SuppressFinalize(this);
             Window.LoadLevel(new Loading());
             Window.Refresh();
             Window.SuspendRender();
             Generator NewGenerator;
             bool      Task;
             do //бесконечный цикл, ну почти
             {
                 NewGenerator = new Generator(Width, Height);
                 GC.Collect();
                 Task = NewGenerator.Generate(); //Проверяет случайное решение на решаемость
             } while (Task != true);
             Window.ResumeRender();
         }
         else if ((Width * Height) % 4 == 0 && TetrominosInUse >= (Width * Height) / 4)
         {
             Clear();
             GC.SuppressFinalize(this);
             Window.LoadLevel(new Game(Quanities[2], Quanities[5], Quanities[0], Quanities[1], Quanities[4], Quanities[6], Quanities[3], Width, Height, Properties.Resources.DarkForest03));
         }
         else
         {
             ButtonProcceed.ChangeImage(FTR.Properties.Resources.GenerateError);
         }
     }
     else if (sprite.Tag == "Field")
     {
         ButtonProcceed.ChangeImage(FTR.Properties.Resources.Generate);
         for (int i = 0; i < 14; i++)
         {
             if (sprite == SlotField[i])
             {
                 if (i < 7)
                 {
                     SlotField[Width - 4].ChangeImage(FTR.Properties.Resources.FieldHUD);
                     Width = i + 4;
                 }
                 else
                 {
                     SlotField[Height + 3].ChangeImage(FTR.Properties.Resources.FieldHUD);
                     Height = i - 3;
                 }
                 SlotField[i].ChangeImage(FTR.Properties.Resources.FieldHUD_Selected);
             }
         }
     }
     else if (sprite.Tag == "TetAdd")
     {
         if (sprite == AddTetromino[0] && Quanities[2] < 9) //L 2
         {
             Quanities[2]++;
             TetrominosInUse++;
             UpdateCounts(2);
         }
         else if (sprite == AddTetromino[2] && Quanities[5] < 9) //I 5
         {
             Quanities[5]++;
             TetrominosInUse++;
             UpdateCounts(5);
         }
         else if (sprite == AddTetromino[4] && Quanities[3] < 9) //S 3
         {
             Quanities[3]++;
             TetrominosInUse++;
             UpdateCounts(3);
         }
         else if (sprite == AddTetromino[6] && Quanities[0] < 9) //O 0
         {
             Quanities[0]++;
             TetrominosInUse++;
             UpdateCounts(0);
         }
         else if (sprite == AddTetromino[8] && Quanities[1] < 9) //J 1
         {
             Quanities[1]++;
             TetrominosInUse++;
             UpdateCounts(1);
         }
         else if (sprite == AddTetromino[10] && Quanities[6] < 9) //T 6
         {
             Quanities[6]++;
             TetrominosInUse++;
             UpdateCounts(6);
         }
         else if (sprite == AddTetromino[12] && Quanities[4] < 9) //Z 4
         {
             Quanities[4]++;
             TetrominosInUse++;
             UpdateCounts(4);
         }
     }
     else if (sprite.Tag == "TetRemove")
     {
         if (sprite == AddTetromino[1] && Quanities[2] > 0) //L 2
         {
             Quanities[2]--;
             TetrominosInUse--;
             UpdateCounts(2);
         }
         else if (sprite == AddTetromino[3] && Quanities[5] > 0) //I 5
         {
             Quanities[5]--;
             TetrominosInUse--;
             UpdateCounts(5);
         }
         else if (sprite == AddTetromino[5] && Quanities[3] > 0) //S 3
         {
             Quanities[3]--;
             TetrominosInUse--;
             UpdateCounts(3);
         }
         else if (sprite == AddTetromino[7] && Quanities[0] > 0) //O 0
         {
             Quanities[0]--;
             TetrominosInUse--;
             UpdateCounts(0);
         }
         else if (sprite == AddTetromino[9] && Quanities[1] > 0) //J 1
         {
             Quanities[1]--;
             TetrominosInUse--;
             UpdateCounts(1);
         }
         else if (sprite == AddTetromino[11] && Quanities[6] > 0) //T 6
         {
             Quanities[6]--;
             TetrominosInUse--;
             UpdateCounts(6);
         }
         else if (sprite == AddTetromino[13] && Quanities[4] > 0) //Z 4
         {
             Quanities[4]--;
             TetrominosInUse--;
             UpdateCounts(4);
         }
     }
 }