Esempio n. 1
0
 public void GeneratePlants(int cx, int cz)
 {
     for (int z = -1; z < OpenCog.Map.OCChunk.SIZE_Z + 1; z++)
     {
         for (int x = -1; x < OpenCog.Map.OCChunk.SIZE_X + 1; x++)
         {
             Vector3i worldPos = new Vector3i(cx * OpenCog.Map.OCChunk.SIZE_X + x, 0, cz * OpenCog.Map.OCChunk.SIZE_Z + z);
             worldPos.y = map.GetMaxY(worldPos.x, worldPos.z);
             for (; worldPos.y >= WATER_LEVEL; worldPos.y--)
             {
                 if (map.GetBlock(worldPos).block == dirt && map.GetSunLightmap().GetLight(worldPos + Vector3i.up) > 5)
                 {
                     map.SetBlock(grass, worldPos);
                 }
             }
         }
     }
 }
    private IEnumerator GenerateColumn(int cx, int cz)
    {
        if (MapName == string.Empty)
        {
            //OCLogger.Debugging("Let's make a column in [" + cx + ", " + cz + "]!");
            yield return(StartCoroutine(terrainGenerator.Generate(cx, cz)));

            yield return(null);

            if (treeGenerator.Length > 0)
            {
                int x     = cx * OpenCog.Map.OCChunk.SIZE_X + OpenCog.Map.OCChunk.SIZE_X / 2;
                int z     = cz * OpenCog.Map.OCChunk.SIZE_Z + OpenCog.Map.OCChunk.SIZE_Z / 2;
                int y     = map.GetMaxY(x, z) + 1;
                int index = UnityEngine.Random.Range(0, treeGenerator.Length);
                treeGenerator[index].Generate(x, y, z);
            }
        }
    }