상속: EditorWindow
예제 #1
0
    //Starting Point Marker will be a pyramid primitive in green colour
    //The instantiated position of the start marker will be exactly like the player as this is a marker to show from where the player started
    void startPosition()
    {
        startPyramid      = new GameObject();
        startPyramid.name = "Start Pyramid";
        startPyramid.tag  = "Start";
        startPyramid.transform.position = playerCube.transform.position;
        startPyramid.AddComponent <PyramidMaker>();

        PyramidMaker pyramidMaker = startPyramid.GetComponent <PyramidMaker>();

        pyramidMaker.PyramidSize     = 2f;
        pyramidMaker.PrimitiveColour = Color.green;
    }
    public void BuildCube()
    {
        PyramidMaker cubeBuilder = new PyramidMaker();

        cubeBuilder.SetUpSubmeshes(6);

        MeshFilter   meshFilter   = this.GetComponent <MeshFilter>();
        MeshRenderer meshrenderer = this.GetComponent <MeshRenderer>();

        //Top Vertices
        Vector3 t0 = new Vector3(cubeSize.x, cubeSize.y, -cubeSize.z);
        Vector3 t1 = new Vector3(-cubeSize.x, cubeSize.y, -cubeSize.z);
        Vector3 t2 = new Vector3(-cubeSize.x, cubeSize.y, cubeSize.z);
        Vector3 t3 = new Vector3(cubeSize.x, cubeSize.y, cubeSize.z);

        //Bottom Vertices
        Vector3 b0 = new Vector3(cubeSize.x, -cubeSize.y, -cubeSize.z);
        Vector3 b1 = new Vector3(-cubeSize.x, -cubeSize.y, -cubeSize.z);
        Vector3 b2 = new Vector3(-cubeSize.x, -cubeSize.y, cubeSize.z);
        Vector3 b3 = new Vector3(cubeSize.x, -cubeSize.y, cubeSize.z);

        //Top
        cubeBuilder.BuildMeshTriangle(t0, t1, t2, 0);
        cubeBuilder.BuildMeshTriangle(t0, t2, t3, 0);

        //Bottom
        cubeBuilder.BuildMeshTriangle(b2, b1, b0, 1);
        cubeBuilder.BuildMeshTriangle(b3, b2, b0, 1);

        //Back
        cubeBuilder.BuildMeshTriangle(b0, t1, t0, 2);
        cubeBuilder.BuildMeshTriangle(b0, b1, t1, 2);

        //Left
        cubeBuilder.BuildMeshTriangle(b1, t2, t1, 3);
        cubeBuilder.BuildMeshTriangle(b1, b2, t2, 3);

        //Right
        cubeBuilder.BuildMeshTriangle(b2, t3, t2, 4);
        cubeBuilder.BuildMeshTriangle(b2, b3, t3, 4);

        //Front
        cubeBuilder.BuildMeshTriangle(b3, t0, t3, 5);
        cubeBuilder.BuildMeshTriangle(b3, b0, t0, 5);

        meshFilter.mesh = cubeBuilder.CreateMesh();

        cubeBuilder.AddMaterials(meshrenderer);
    }
    public void BuildCube()
    {
        PyramidMaker cubeBuilder = new PyramidMaker();

        cubeBuilder.SetUpSubmeshes(6);

        MeshFilter   meshFilter   = this.GetComponent <MeshFilter>();
        MeshRenderer meshrenderer = this.GetComponent <MeshRenderer>();

        //top vertices
        Vector3 t0 = new Vector3(cubeSize.x, cubeSize.y, -cubeSize.z);  //top left
        Vector3 t1 = new Vector3(-cubeSize.x, cubeSize.y, -cubeSize.z); //top right
        Vector3 t2 = new Vector3(-cubeSize.x, cubeSize.y, cubeSize.z);  //bottom right of top square
        Vector3 t3 = new Vector3(cubeSize.x, cubeSize.y, cubeSize.z);   //bottom left of top square

        //bottom vertices
        Vector3 b0 = new Vector3(cubeSize.x, -cubeSize.y, -cubeSize.z);  //bottom left
        Vector3 b1 = new Vector3(-cubeSize.x, -cubeSize.y, -cubeSize.z); //bottom right
        Vector3 b2 = new Vector3(-cubeSize.x, -cubeSize.y, cubeSize.z);  //bottom right of bottom square
        Vector3 b3 = new Vector3(cubeSize.x, -cubeSize.y, cubeSize.z);   //bottom left of bottom square

        //top square
        cubeBuilder.BuildMeshTriangle(t0, t1, t2, 0);
        cubeBuilder.BuildMeshTriangle(t0, t2, t3, 0);

        //bottom square
        cubeBuilder.BuildMeshTriangle(b2, b1, b0, 1);
        cubeBuilder.BuildMeshTriangle(b3, b2, b0, 1);

        //back square
        cubeBuilder.BuildMeshTriangle(b0, t1, t0, 2);
        cubeBuilder.BuildMeshTriangle(b0, b1, t1, 2);

        //left square
        cubeBuilder.BuildMeshTriangle(b1, t2, t1, 3);
        cubeBuilder.BuildMeshTriangle(b1, b2, t2, 3);

        //left square
        cubeBuilder.BuildMeshTriangle(b2, t3, t2, 4);
        cubeBuilder.BuildMeshTriangle(b2, b3, t3, 4);

        //front square
        cubeBuilder.BuildMeshTriangle(b3, t0, t3, 5);
        cubeBuilder.BuildMeshTriangle(b3, b0, t0, 5);

        meshFilter.mesh = cubeBuilder.CreateMesh();

        cubeBuilder.AddMaterials(meshrenderer);
    }
예제 #4
0
    //Finish Point Marker will be a pyramid primitive in orange colour
    //The instantiated position of the finish marker is randomly chosen
    void endPositions()
    {
        endPyramid      = new GameObject();
        endPyramid.name = "Finish Pyramid";
        endPyramid.tag  = "Finish";
        endPyramid.transform.position = new Vector3(Random.Range(2, 28), 0.1f, Random.Range(2, 28));
        endPyramid.AddComponent <PyramidMaker>();

        PyramidMaker pyramidMaker = endPyramid.GetComponent <PyramidMaker>();

        pyramidMaker.PyramidSize     = 2f;
        pyramidMaker.PrimitiveColour = new Color32(255, 69, 0, 255);

        endPyramid.AddComponent <BoxCollider>();
        endPyramid.GetComponent <BoxCollider>().size      = new Vector3(4, 2, 3);
        endPyramid.GetComponent <BoxCollider>().center    = new Vector3(0, 1, 0);
        endPyramid.GetComponent <BoxCollider>().isTrigger = true;
        endPyramid.AddComponent <WallCollider>();
        endPyramid.AddComponent <Rigidbody>();
        endPyramid.GetComponent <Rigidbody>().useGravity = false;
    }