Ejemplo n.º 1
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);
    }
Ejemplo n.º 2
0
    void MakeMapDimensions()
    {
        //mapType = (MapType)mapTypeIndex;
        arenaHeight = 0;
        arenaDepth  = 0;
        switch (mapType)
        {
        case MapType.cross:
            switch (mapSizeIndex)
            {
            case 0:
                arenaWidth = 20;
                thickness  = 4;
                break;

            case 1:
                arenaWidth = 40;
                thickness  = 6;
                break;

            case 2:
                arenaWidth = 60;
                thickness  = 8;
                break;

            case 3:
                arenaWidth = 100;
                thickness  = 10;
                break;

            default:
                break;
            }
            break;

        case MapType.tangle:
            switch (mapSizeIndex)
            {
            case 0:
                arenaWidth = 20;
                thickness  = 4;
                break;

            case 1:
                arenaWidth = 40;
                thickness  = 6;
                break;

            case 2:
                arenaWidth = 60;
                thickness  = 8;
                break;

            case 3:
                arenaWidth = 100;
                thickness  = 10;
                break;

            default:
                break;
            }
            break;

        case MapType.warren:
            switch (mapSizeIndex)
            {
            case 0:
                arenaWidth = 20;
                thickness  = 4;
                break;

            case 1:
                arenaWidth = 40;
                thickness  = 6;
                break;

            case 2:
                arenaWidth = 60;
                thickness  = 8;
                break;

            case 3:
                arenaWidth = 100;
                thickness  = 10;
                break;

            default:
                break;
            }
            break;

        case MapType.pillars:
            switch (mapSizeIndex)
            {
            case 0:
                arenaWidth = 20;
                thickness  = 4;
                break;

            case 1:
                arenaWidth = 40;
                thickness  = 6;
                break;

            case 2:
                arenaWidth = 60;
                thickness  = 8;
                break;

            case 3:
                arenaWidth = 100;
                thickness  = 10;
                break;

            default:
                break;
            }
            break;

        case MapType.cube:
            switch (mapSizeIndex)
            {
            case 0:
                arenaWidth = 20;
                break;

            case 1:
                arenaWidth = 40;
                break;

            case 2:
                arenaWidth = 60;
                break;

            case 3:
                arenaWidth = 100;
                break;

            default:
                break;
            }
            break;

        case MapType.sphere:
            switch (mapSizeIndex)
            {
            case 0:
                arenaWidth = 20;
                break;

            case 1:
                arenaWidth = 40;
                break;

            case 2:
                arenaWidth = 60;
                break;

            case 3:
                arenaWidth = 100;
                break;

            default:
                break;
            }
            break;

        case MapType.race:
            break;

        default:
            break;
        }

        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;

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

        default:
            break;
        }
    }