示例#1
0
 public void UpdateGrid(Tetromino3D tetromino)
 {
     for (int y = 0; y < gridHeight; y++)
     {
         for (int x = 0; x < gridWidth; x++)
         {
             for (int z = 0; z < gridWidth; z++)
             {
                 if (grid[x, z, y] != null)
                 {
                     //如果图形本来就在这个位置,要进行更新,删除原来的位置,填入新的位置
                     if (grid[x, z, y].parent == tetromino.transform)
                     {
                         grid[x, z, y] = null;
                     }
                 }
             }
         }
     }
     //添加新的位置
     foreach (Transform mino in tetromino.transform)
     {
         Vector3 pos = Round(mino.position);
         if (pos.y <= gridHeight)
         {
             grid[(int)pos.x + 4, (int)pos.z + 4, (int)pos.y - 1] = mino;
         }
     }
 }
示例#2
0
 //判断是否堆满,gameover, 没有超出返回false, 超出返回true
 public bool CheckIsAboveGrid(Tetromino3D tetromino)
 {
     foreach (Transform mino in tetromino.transform)
     {
         Vector3 pos = Round(mino.position);
         if (pos.y > gridHeight)
         {
             return(true);
         }
     }
     return(false);
 }