Beispiel #1
0
    void addThinRhomb(string tileType, int closestEdge, Tile closestTile)
    {
        Vector3[] verticiesToAdd  = new Vector3[4];
        Vector3[] newVertices     = new Vector3[4];
        Vector3[] closestTileVers = closestTile.worldVertices;
        float     currentAngle    = closestTile.rotation;
        int       rotateIndex     = 5;
        float     angle           = 0f;

        var tileCondition = (tileType == "thinRhomb");

        Debug.Log(closestEdge);


        switch (closestEdge)
        {
        case 1:

            rotateIndex = tileCondition ? 2 : 2;
            angle       = tileCondition ? -36f : -162f;

            break;

        case 2:

            rotateIndex = tileCondition ? 2 : 1;
            angle       = tileCondition ? 36f : -54f;

            break;


        case 3:

            rotateIndex = tileCondition ? 3 : 1;
            angle       = tileCondition ? -36f : -126f;

            break;


        case 4:

            rotateIndex = tileCondition ? 3 : 3;
            angle       = tileCondition ? 36f : -18f;

            break;
        }

        float tileRotation = currentAngle + angle;

        if (tileType == "thinRhomb")
        {
            newVertices = HelperFunctionsClass.FlipThin(closestTileVers);

            tileRotation += 180f;
        }

        else if (tileType == "thickRhomb")
        {
            newVertices = closestTileVers;

            if (closestEdge == 2 || closestEdge == 4)
            {
                newVertices = HelperFunctionsClass.ThinFromThickDown(closestTileVers[rotateIndex]);
            }
            else
            {
                newVertices = HelperFunctionsClass.ThinFromThickUp(closestTileVers[rotateIndex]);
            }

            angle += currentAngle;
        }

        else
        {
            throw new Exception("What is this you are trying to add to? #madlad");
        }


        GameObject newTile = (GameObject)Instantiate(thinRhomb);

        newTile.GetComponent <ThinRhomb>().tileVertices = newVertices;
        newTile.GetComponent <ThinRhomb>().rotation     = tileRotation;
        newTile.transform.RotateAround(closestTileVers[rotateIndex], new Vector3(0, 0, 1), angle);
    }