Пример #1
0
    public virtual IEnumerator CalculateMapFromScratch()
    {
        map = new byte[World.currentWorld.chunkWidth, World.currentWorld.chunkHeight, World.currentWorld.chunkWidth];

        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                for (int z = 0; z < width; z++)
                {
                    //map[x, y, z] = GetTheoreticalByte(new Vector3(x, y,z)+transform.position);
                    if (y > 25)
                    {
                        map[x, y, z] = (byte)Block.ID.AIR;
                    }
                    else if (y == 25)
                    {
                        map[x, y, z] = 1;
                    }
                    else if (y < 25 && y > 0)
                    {
                        map[x, y, z] = (byte)Block.ID.STONE;
                    }
                    else if (y == 0)
                    {
                        map[x, y, z] = (byte)Block.ID.BEDROCK;
                    }
                    else
                    {
                        map[x, y, z] = (byte)Block.ID.DIRT;
                    }
                }
            }
        }

        for (int x = 0; x < width; x++)
        {
            for (int z = 0; z < width; z++)
            {
                if (Random.Range(0, 300) == 1)
                {
                    TreeGen.makeTree(x, 25, z, map);
                }
            }
        }
        yield return(0);
    }