コード例 #1
0
ファイル: Game.cs プロジェクト: niley7464/unity-fun-game
    public void UpdateGrid(Tetronemo tetronemo)
    {
        for (int y = 0; y < gridHeight; ++y)
        {
            for (int x = 0; x < gridWidth; ++x)
            {
                if (grid[x, y] != null)
                {
                    if (grid[x, y].parent == tetronemo.transform)
                    {
                        grid[x, y] = null;
                    }
                }
            }
        }

        foreach (Transform nemo in tetronemo.transform)
        {
            Vector2 pos = Round(nemo.position);
            if (pos.y < gridHeight)
            {
                grid[(int)pos.x, (int)pos.y] = nemo;
            }
        }
    }
コード例 #2
0
ファイル: Game.cs プロジェクト: niley7464/unity-fun-game
 public bool CheckIsAboveGrid(Tetronemo tetronemo)
 {
     for (int x = 0; x < gridWidth; ++x)
     {
         foreach (Transform nemo in tetronemo.transform)
         {
             Vector2 pos = Round(nemo.position);
             if (pos.y > gridHeight - 1)
             {
                 return(true);
             }
         }
     }
     return(false);
 }