Esempio n. 1
0
    public static LowPolyTerrainData GetRandomMap()
    {
        var result = new LowPolyTerrainData(111, 111);
        const float Depth = 30;

        for (var y = 0; y < result.Height; y++)
        {
            for (var x = 0; x < result.Width; x++)
            {
                var tile = result.GetTile(x, y);

                var height1 = CalcHeight(result, tile.Corner1, Depth);
                var height2 = CalcHeight(result, tile.Corner2, Depth);
                var height3 = CalcHeight(result, tile.Corner3, Depth);

                tile.SetCorner(height1, 0);
                tile.SetCorner(height2, 1);
                tile.SetCorner(height3, 2);
                
                var anyBelow = height1 < 4 || height2 < 4 || height3 < 4;
                var allAbove = height1 > 14 && height2 > 14 && height3 > 14;

                if (allAbove)
                {
                    tile.HasTree = CalcHasTree(result, tile.Corner1);
                    tile.TreeScale = CalcTreeScale(result, tile.Corner2);
                    tile.TreeRotation = CalcTreeRotation(result, tile.Corner3);
                }
                result.SetTileType(x, y, anyBelow ? "sand" : "grass");
            } 
        }

        return result;
    }
Esempio n. 2
0
    public static LowPolyTerrainData GetRandomMap()
    {
        var         result = new LowPolyTerrainData(111, 111);
        const float Depth  = 30;

        for (var y = 0; y < result.Height; y++)
        {
            for (var x = 0; x < result.Width; x++)
            {
                var tile = result.GetTile(x, y);

                var height1 = CalcHeight(result, tile.Corner1, Depth);
                var height2 = CalcHeight(result, tile.Corner2, Depth);
                var height3 = CalcHeight(result, tile.Corner3, Depth);

                tile.SetCorner(height1, 0);
                tile.SetCorner(height2, 1);
                tile.SetCorner(height3, 2);

                var anyBelow = height1 < 4 || height2 < 4 || height3 < 4;
                var allAbove = height1 > 14 && height2 > 14 && height3 > 14;

                if (allAbove)
                {
                    tile.HasTree      = CalcHasTree(result, tile.Corner1);
                    tile.TreeScale    = CalcTreeScale(result, tile.Corner2);
                    tile.TreeRotation = CalcTreeRotation(result, tile.Corner3);
                }
                result.SetTileType(x, y, anyBelow ? "sand" : "grass");
            }
        }

        return(result);
    }