Beispiel #1
0
    private bool canSpawnTetromino()
    {
        int x = Mathf.RoundToInt(spawnPoint.x);
        int y = Mathf.RoundToInt(spawnPoint.y);

        return(blockMap.findBlock(x, y));
    }
    public bool canMoveTo(Vector3 dir)
    {
        for (int i = 0; i < transform.childCount; ++i)
        {
            Transform block = transform.GetChild(i);
            int       x     = Mathf.RoundToInt(block.position.x + dir.x);
            int       y     = Mathf.RoundToInt(block.position.y + dir.y);

            if (blockMap.isOutOfGrid(x, y))
            {
                return(false);
            }
            else if (blockMap.findBlock(x, y))
            {
                return(false);
            }
        }

        return(true);
    }