コード例 #1
0
ファイル: MapGen.cs プロジェクト: dodo721/CarRoguelike
    public void DrawMapInEditor()
    {
        MapData map = GenerateMapData(Vector2.zero);

        if (drawMode == DrawMode.NoiseMap)
        {
            display.DrawTexture(TextureGen.TextureFromNoiseMap(map.heightMap));
        }
        else if (drawMode == DrawMode.ColourMap)
        {
            display.DrawTexture(TextureGen.TextureFromColourMap(map.colMap, mapChunkSize, mapChunkSize));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            display.DrawMesh(MeshGen.GenerateTerrainMesh(map.heightMap, heightCoefficient, heightExponent, meshHeightCurve, editorLOD), TextureGen.TextureFromColourMap(map.colMap, mapChunkSize, mapChunkSize));
        }
    }
コード例 #2
0
    private void Update()
    {
        chunkSize = terrain.getChunkSize();

        terrainDict = terrain.getCoordsTerrainDict();

        var     playerPos  = player.position;
        Vector2 chunkCoord = new Vector2(0, 0);

        chunkCoord.x = Mathf.RoundToInt(playerPos.x / chunkSize);
        chunkCoord.y = Mathf.RoundToInt(playerPos.z / chunkSize);

        float scale = mapGen.noiseScale;

        var heightMap = terrainDict[chunkCoord].getHeightMap();

        var newNoise = Noise.GenerateNoiseMap(chunkSize + 1, chunkSize + 1, scale, 1, 0.5f, 2f, 0, Vector2.zero);

        var newItem = spawnables[0];



        var spawnMask    = getPossibleSpawnPoints(heightMap, newNoise, newItem.startRange, newItem.endRange);
        var spawnHeights = applyMask(heightMap, spawnMask);

        var text = TextureGen.TextureFromNoiseMap(spawnHeights);

        DrawTexture(text);

        for (int i = 0; i < maxSpawned; i++)
        {
            GameObject item = spawnedItems[i];
            if (item == null)
            {
                if (terrainDict.ContainsKey(chunkCoord))
                {
                }
            }
            else if (sqrDist(player, item.transform) > sqrDespawnDist)
            {
                // delete gameobject and set item to null
            }
        }
    }