Example #1
0
    void Build()
    {
        MakeMapDimensions();
        myMap.CopyToMarching();
        if (cavesque)
        {
            myMap.MakeCavesque();
        }
        myMap.SmoothMesh(smoothness);
        myMap.MakeChunks();
        GameObject tempChunk;

        MeshGenerator.MarchingMesh marchingMesh;
        for (int i = 0; i < myMap.chunkList.Count; i++)
        {
            tempChunk = Instantiate(chunk, transform);
            tempChunk.SetActive(true);
            tempChunk.transform.position = myMap.chunkList[i].position * transform.localScale.x;
            marchingMesh = new MeshGenerator.MarchingMesh(ref myMap.chunkList[i].marchingGrid);
            tempChunk.GetComponent <MeshFilter>().mesh         = marchingMesh.GetMarchingMesh();
            tempChunk.GetComponent <MeshCollider>().sharedMesh = tempChunk.GetComponent <MeshFilter>().sharedMesh;
        }
    }
Example #2
0
    void BuildLevel()
    {
        switch (mapType)
        {
        case MapType.cube:
            myMap = new GameMap.ClusterMap(arenaWidth, arenaHeight, arenaDepth);
            myMap.MakeBox();
            break;

        case MapType.cross:
            myMap = new GameMap.ClusterMap(arenaWidth, arenaHeight, arenaDepth);
            myMap.MakeCross(thickness);
            break;

        case MapType.warren:
            myMap = new GameMap.ClusterMap(arenaWidth);
            myMap.MakeCross(arenaWidth - thickness * 2);
            break;

        case MapType.sphere:
            myMap = new GameMap.ClusterMap(arenaWidth, arenaHeight, arenaDepth);
            myMap.MakeSphere();
            break;

        case MapType.pillars:
            myMap = new GameMap.ClusterMap(arenaWidth, arenaHeight, arenaDepth);
            myMap.MakePillars(thickness);
            break;

        case MapType.tangle:
            myMap = new GameMap.ClusterMap(arenaWidth, arenaHeight, arenaDepth);
            myMap.MakeTangle(thickness);
            break;

        case MapType.race:
            myMap = new GameMap.ClusterMap(6, 6, 160);
            myMap.MakeBox();
            break;

        default:
            break;
        }
        myMap.CopyToMarching();
        if (cavesque)
        {
            myMap.MakeCavesque();
        }
        myMap.SmoothMesh(smoothness);
        myMap.MakeChunks();
        GameObject tempChunk;

        MeshGenerator.MarchingMesh marchingMesh;
        for (int i = 0; i < myMap.chunkList.Count; i++)
        {
            tempChunk = Instantiate(chunk, transform);
            tempChunk.SetActive(true);
            tempChunk.transform.position = myMap.chunkList[i].position * transform.localScale.x;
            marchingMesh = new MeshGenerator.MarchingMesh(ref myMap.chunkList[i].marchingGrid);
            tempChunk.GetComponent <MeshFilter>().mesh         = marchingMesh.GetMarchingMesh();
            tempChunk.GetComponent <MeshCollider>().sharedMesh = tempChunk.GetComponent <MeshFilter>().sharedMesh;
        }

        focalPoint = new Vector3(arenaWidth * cube.transform.localScale.x * 0.5f, arenaWidth * cube.transform.localScale.y * 0.5f, arenaWidth * cube.transform.localScale.z * 0.5f);
    }