Exemplo n.º 1
0
    bool CanPlaceBuilding()
    {
        var cubeSize = newBuilding.GetSize();

        for (int x = 0; x < cubeSize; ++x)
        {
            for (int y = 0; y < cubeSize; ++y)
            {
                if (fieldData.GetState(placeCell.x + x, placeCell.y + y) != FieldData.CellState.Free)
                {
                    return(false);
                }
            }
        }

        return(true);
    }
Exemplo n.º 2
0
    public void Initialize(int width, int height, float lockedRatio)
    {
        fieldData = new FieldData(width, height, lockedRatio);
        transform.localPosition = new Vector3(-0.5f * width * cellSize, 0.0f, -0.5f * height * cellSize);

        for (int x = 0; x < fieldData.width; ++x)
        {
            for (int y = 0; y < fieldData.height; ++y)
            {
                if (fieldData.GetState(x, y) == FieldData.CellState.Free)
                {
                    AddGround(x, y);
                }
                else
                {
                    AddBlock(x, y);
                }
            }
        }
    }