Exemple #1
0
    void PushDown()
    {
        int levelsCleared = 0;

        for (int i = 0; i < ClearingLevels.Length; i++)
        {
            if (ClearingLevels[i])
            {
                for (int y = i - levelsCleared; y < GridY; y++)
                {
                    for (int x = 0; x < GridX; x++)
                    {
                        for (int z = 0; z < GridZ; z++)
                        {
                            if (y < GridY - 1)
                            {
                                GameState[x, y, z] = GameState[x, y + 1, z];
                                TileLogic currentTileController  = TileLiterals[x, y, z].GetComponent(typeof(TileLogic)) as TileLogic;
                                TileLogic previousTileController = TileLiterals[x, y + 1, z].GetComponent(typeof(TileLogic)) as TileLogic;
                                currentTileController.SetColor(previousTileController.GetColor());
                            }
                            else
                            {
                                GameState[x, y, z] = false;
                            }
                        }
                    }
                }
                levelsCleared    += 1;
                Score            += 1;
                ClearingLevels[i] = false;
            }
        }
        UpdateBoard();
    }
Exemple #2
0
 void DrawPiece()
 {
     PieceComponent[] pieces = CurrentPiece.GetPieces();
     for (int i = 0; i < pieces.Length; i++)
     {
         int finalX = Round(pieces[i].GetX()) + CurrentPiece.GetPositionX();
         int finalY = Round(pieces[i].GetY()) + CurrentPiece.GetPositionY();
         int finalZ = Round(pieces[i].GetZ()) + CurrentPiece.GetPositionZ();
         if (GridX > finalX && finalX >= 0 && GridY > finalY && finalY >= 0 && GridZ > finalZ && finalZ >= 0)
         {
             TileLogic CurrentTileController = TileLiterals[finalX, finalY, finalZ].GetComponent(typeof(TileLogic)) as TileLogic;
             CurrentTileController.SetColor(CurrentColor);
             CurrentTileController.Show();
         }
         else
         {
             Debug.Log("Failed to place at position: (" + finalX.ToString() + "," + finalY.ToString() + "," + finalZ.ToString() + ")");
         }
     }
 }