コード例 #1
0
    public TerrainCellData GenerateFlatCell(Vector2 coords)
    {
        TerrainCellData data = new TerrainCellData();

        data.xCoord = (int)coords.x;
        data.yCoord = (int)coords.y;
        data.id     = world.CoordsToCellId((int)coords.x, (int)coords.y);


        for (int i = 0; i < cellSize; i++)
        {
            for (int j = 0; j < cellSize; j++)
            {
                TerrainBlock block = new TerrainBlock();
                block.gpx     = i;
                block.gpz     = j;
                block.blockId = TerrainBlock.Blocks.Dirt;
                data.blocks.Add(block);
            }
        }

        // Add blocks to each corner
        data.blocks.Add(new TerrainBlock(new Vector3(1, 1, 1)));
        data.blocks.Add(new TerrainBlock(new Vector3(cellSize - 2, 1, 1)));
        data.blocks.Add(new TerrainBlock(new Vector3(1, 1, cellSize - 2)));
        data.blocks.Add(new TerrainBlock(new Vector3(cellSize - 2, 1, cellSize - 2)));

        return(data);
    }