Exemple #1
0
    public void DoDiamondDestroy(string type, int setScoreMultiplier)
    {
        scoreMultiplier    = setScoreMultiplier;
        blockGrid          = manager.blockGrid;
        blocksToDestroy    = new GameObject[towerHeight * towerWidth];
        numBlocksToDestroy = 0;
        pointsGrid         = new int[towerWidth, towerHeight]; // All values should initialize to zero

        audioManager.PlayBlockSound("DIAMOND");

        minHeightOfDestroyedBlocks = new int[towerWidth];
        for (int i = 0; i < minHeightOfDestroyedBlocks.Length; i++)
        {
            minHeightOfDestroyedBlocks[i] = 10000;
        }

        if (type == "") // Tech bonus
        {
            for (int i = 0; i < towerWidth; i++)
            {
                if (blockGrid[i, 0] != null && blockGrid[i, 0].GetComponent <BlockScript>().type == "diamond")
                {
                    manager.currentHeights[i]           = 0;
                    minHeightOfDestroyedBlocks[i]       = 0;
                    blocksToDestroy[numBlocksToDestroy] = blockGrid[i, 0];
                    numBlocksToDestroy++;
                    blockGrid[i, 0]  = null;
                    pointsGrid[i, 0] = techBonusPointValue * manager.speed;
                    pointsToAdd     += techBonusPointValue * manager.speed;
                    return;
                }
            }
        }

        // else
        for (int i = 0; i < towerWidth; i++)
        {
            for (int j = 0; j < towerHeight; j++)
            {
                if (blockGrid[i, j] != null && (blockGrid[i, j].GetComponent <BlockScript>().type == type || blockGrid[i, j].GetComponent <BlockScript>().type == "diamond"))
                {
                    if (manager.currentHeights[i] >= j)
                    {
                        manager.currentHeights[i] = j;
                    }
                    minHeightOfDestroyedBlocks[i]       = Mathf.Min(j, minHeightOfDestroyedBlocks[i]);
                    blocksToDestroy[numBlocksToDestroy] = blockGrid[i, j];
                    numBlocksToDestroy++;
                    pointsGrid[i, j] += numBlocksToDestroy;
                    pointsToAdd      += numBlocksToDestroy;
                    blockGrid[i, j]   = null;
                }
            }
        }
    }
Exemple #2
0
 public void tryFullDrop()
 {
     if (leftBlock == null || rightBlock == null)
     {
         if (leftBlock != null)
         {
             leftBlock.AddBlockToColumn();
         }
         if (rightBlock != null)
         {
             rightBlock.AddBlockToColumn();
         }
     }
     else if (leftBlock.transform.position.y < rightBlock.transform.position.y)
     {
         leftBlock.AddBlockToColumn();
         rightBlock.AddBlockToColumn();
     }
     else
     {
         rightBlock.AddBlockToColumn();
         leftBlock.AddBlockToColumn();
     }
     // Each drop, add points equal to number of blocks on the board
     manager.addPoints(manager.speed);
     manager.debugDropPoints += manager.speed;
     audioManager.PlayBlockSound("DROP");
     audioManager.RecordDrop();
 }