Пример #1
0
 public Game(int maxx, int maxy, System.Windows.Forms.Timer t)
 {
     gameState = new PreGameState(this);
     resetGame(maxx,maxy);
     sound = new Sounds();
     timer = t;
 }
Пример #2
0
 static void Drop(int playerNumber)
 {
     if (numberOfPlayers == 2)
     {
         if (brickPlayer[playerNumber].blockPositionY > brickPlayer[Math.Abs(playerNumber - 1)].blockPositionY)
         {
             while (Block.OverlapBlocks(brickPlayer[playerNumber], bigBlock) == false)
             {
                 score += level * 2; // Bonus score
                 brickPlayer[playerNumber].blockPositionY++;
                 if (Block.OverlapBlocks(brickPlayer[playerNumber], bigBlock) == true)
                 {
                     brickPlayer[playerNumber].blockPositionY--;
                     bigBlock = bigBlock + brickPlayer[playerNumber];
                     brickPlayer[playerNumber] = nextBrick;
                     brickPlayer[playerNumber].blockPositionX = playerPos[playerNumber];
                     brickPlayer[playerNumber].Print();
                     CheckForCompleteLines();
                     nextBrick = GenerateRandomBlock(playerPos[0]);
                     Sounds.SFX(Sounds.SoundEffects.Drop);
                     PrintNextBrick();
                     bigBlock.SetColor(15);
                     bigBlock.Print();
                     return;
                 }
                 else
                 {
                     brickPlayer[playerNumber].blockPositionY--;
                     brickPlayer[playerNumber].Clear();
                     brickPlayer[playerNumber].blockPositionY++;
                     brickPlayer[playerNumber].Print();
                 }
             }
         }
         else if (brickPlayer[playerNumber].blockPositionX > brickPlayer[Math.Abs(playerNumber - 1)].blockPositionX + brickPlayer[Math.Abs(playerNumber - 1)].blockCols - 1 || brickPlayer[playerNumber].blockPositionX + brickPlayer[playerNumber].blockCols - 1 < brickPlayer[Math.Abs(playerNumber - 1)].blockPositionX)
         {
             while (Block.OverlapBlocks(brickPlayer[playerNumber], bigBlock) == false)
             {
                 score += level * 2; // Bonus score
                 brickPlayer[playerNumber].blockPositionY++;
                 if (Block.OverlapBlocks(brickPlayer[playerNumber], bigBlock) == true)
                 {
                     brickPlayer[playerNumber].blockPositionY--;
                     bigBlock = bigBlock + brickPlayer[playerNumber];
                     brickPlayer[playerNumber] = nextBrick;
                     brickPlayer[playerNumber].blockPositionX = playerPos[playerNumber];
                     brickPlayer[playerNumber].Print();
                     CheckForCompleteLines();
                     nextBrick = GenerateRandomBlock(playerPos[0]);
                     Sounds.SFX(Sounds.SoundEffects.Drop);
                     PrintNextBrick();
                     bigBlock.SetColor(15);
                     bigBlock.Print();
                     return;
                 }
                 else
                 {
                     brickPlayer[playerNumber].blockPositionY--;
                     brickPlayer[playerNumber].Clear();
                     brickPlayer[playerNumber].blockPositionY++;
                     brickPlayer[playerNumber].Print();
                 }
             }
         }
     }
     else
     {
         while (Block.OverlapBlocks(brickPlayer[playerNumber], bigBlock) == false)
         {
             score += level * 2; // Bonus score
             brickPlayer[playerNumber].blockPositionY++;
             if (Block.OverlapBlocks(brickPlayer[playerNumber], bigBlock) == true)
             {
                 brickPlayer[playerNumber].blockPositionY--;
                 bigBlock = bigBlock + brickPlayer[playerNumber];
                 brickPlayer[playerNumber] = nextBrick;
                 brickPlayer[playerNumber].blockPositionX = playerPos[playerNumber];
                 brickPlayer[playerNumber].Print();
                 CheckForCompleteLines();
                 nextBrick = GenerateRandomBlock(playerPos[0]);
                 Sounds.SFX(Sounds.SoundEffects.Drop);
                 PrintNextBrick();
                 bigBlock.SetColor(15);
                 bigBlock.Print();
                 return;
             }
             else
             {
                 brickPlayer[playerNumber].blockPositionY--;
                 brickPlayer[playerNumber].Clear();
                 brickPlayer[playerNumber].blockPositionY++;
                 brickPlayer[playerNumber].Print();
             }
         }
     }
 }