Example #1
0
    public void updateMap(MapGeneratorFunctionDelegate callback = null)
    {
        createBaseMapVerts = true;
        //  if (isServer) {
        //    Debug.Log("server is updating the map on the clients");
        //   RpcUpdateMap();
        // }

        if (!mainMesh)
        {
            mainMesh = gameObject.GetComponent <MeshFilter>().mesh;
        }
        createMesh(mainMesh);
        positionSpread   = transform.position;
        topSurfaceSpread = new Vector3[totalSurfaceVerts];
        for (int i = 0; i < totalSurfaceVerts; i++)
        {
            topSurfaceSpread[i] = mainMesh.vertices[i];
        }

        if (isCircle)
        {
            //turnIntoCircle(mainMesh, mainMesh.vertices[0], Radius);
        }
        makeCollision(mainMesh.vertices);
        mainMesh.RecalculateBounds();
        topSurface = new Vector3[totalSurfaceVerts];
        for (int i = 0; i < totalSurfaceVerts; i++)
        {
            topSurface[i] = mainMesh.vertices[i];
        }

        if (callback != null)
        {
            callback(this);
        }
    }
Example #2
0
    public void updateMapPlatform(Vector3[] surfaceToAvoidGlobal, MapGeneratorFunctionDelegate callback = null)
    {
        if (!mainMesh)
        {
            mainMesh = gameObject.GetComponent <MeshFilter>().mesh;
        }
        Vector3[] surfaceToAvoidLocal = tranlateVertsToLocalSpace(surfaceToAvoidGlobal);
        Vector3[] surfaceVerts        = createSurfacePlaneThatAvoids(surfaceToAvoidLocal, totalSurfaceVerts);


        Mesh mesh = createMeshFromSurfacePlane(surfaceVerts);

        positionSpread   = transform.position;
        topSurfaceSpread = new Vector3[totalSurfaceVerts];
        for (int i = 0; i < totalSurfaceVerts; i++)
        {
            topSurfaceSpread[i] = mesh.vertices[i];
        }

        //if (isCircle)
        // turnIntoCirclePlatform(mesh,  Radius, baseMG);
        makeCollision(mesh.vertices);


        topSurface = new Vector3[totalSurfaceVerts];
        for (int i = 0; i < totalSurfaceVerts; i++)
        {
            topSurface[i] = mesh.vertices[i];
        }

        if (callback != null)
        {
            callback(this);
        }
        assignMainMesh(mesh);
    }