Beispiel #1
0
 //Start The Game
 private void startGame()
 {
     gameOver = false;
     //Prepare game board
     for (int i = 0; i < 10; i++)
     {
         for (int j = 0; j < 24; j++)
         {
             gameBoard[i, j] = 0;
         }
     }
     fallingTile = newTile();
     nextTile    = newTile();
     fallingTile.colorShape();
     speedUp         = false;
     rowAnimation    = false;
     rowComplete     = -1;
     score           = 0;
     scoreMultiplier = 40;
     rowsCleared     = 0;
     audio.PlayOneShot(placeSFX);
 }
Beispiel #2
0
 //Game Logic
 private void gameLogic()
 {
     if (gameOver)
     {
         return;
     }
     if (timer > 0 && !speedUp)
     {
         timer--;
     }
     else
     {
         timer = Mathf.Max(1, 60 - rowsCleared * 2);
         if (rowComplete != -1)
         {
             shiftTilesDown(rowComplete);
             rowComplete = -1;
             score      += scoreMultiplier;
             if (scoreMultiplier == 40)
             {
                 scoreMultiplier = 60;
             }
             else if (scoreMultiplier == 60)
             {
                 scoreMultiplier = 200;
             }
             if (scoreMultiplier == 200)
             {
                 scoreMultiplier = 900;
             }
             rowsCleared++;
             audio.PlayOneShot(clearSFX);
             return;
         }
         if (fallingTile.atBottom && fallingTile.isAtTop())
         {
             gameOver = true;
             audio.PlayOneShot(loseSFX);
         }
         else if (fallingTile.atBottom)
         {
             rowComplete = checkRows();
             if (rowComplete != -1)
             {
                 rowAnimation = true;
                 speedUp      = false;
                 timer        = 15;
             }
             else
             {
                 rowAnimation = false;
                 fallingTile  = nextTile;
                 nextTile     = newTile();
                 fallingTile.colorShape();
                 audio.PlayOneShot(placeSFX);
                 scoreMultiplier = 40;
             }
         }
         else if (!rowAnimation)
         {
             fallingTile.moveDown();
         }
     }
 }