Beispiel #1
0
    public GameObject getWall(TerrainCornerType left, TerrainCornerType right)
    {
        GameObject go;

        go = walls[(int)left, (int)right];
        return(go);
    }
Beispiel #2
0
    public void createWall(TerrainCornerType left, TerrainCornerType right, float rot)
    {
        try
        {
            Vector3 rotDir = new Vector3(0f, rot, 0f);

            GameObject go = type.prefabs.getWall(left, right);
            if (go == null)
            {
                return;
            }

            go = Instantiate(type.prefabs.getWall(left, right), transform.position, Quaternion.Euler(rotDir)) as GameObject;
            walls.Add(go);
            go.transform.parent = transform;
        }
        catch (System.Exception e)
        {
            Debug.LogError(e.ToString() + ": COULD NOT INSTANTIATE WALL " + left.ToString() + " " + right.ToString());
        }
        //go.transform.eulerAngles = new Vector3(0f, direction.y, 0f);
    }
Beispiel #3
0
    /// <summary>
    /// Adds pretty looking cliffs between terrain of different altitudes
    /// </summary>
    public void autoWall()
    {
        if (node == null)
        {
            return;
        }

        Transform auto = autoWaller.transform;

        auto.position = node.position;
        auto.rotation = transform.rotation;

        foreach (GameObject wall in walls)
        {
            Destroy(wall);
        }

        for (int i = 0; i < 4; i++)
        {
            // O O O
            // O X O
            // O O O
            //auto.rotation = Quaternion.AngleAxis( 90 , Vector3.up );


            Node     n;
            Altitude front      = Altitude.unassigned;
            Altitude frontRight = Altitude.unassigned;;
            Altitude frontLeft  = Altitude.unassigned;;
            Altitude back       = Altitude.unassigned;;
            Altitude backRight  = Altitude.unassigned;;
            Altitude backLeft   = Altitude.unassigned;;
            Altitude left       = Altitude.unassigned;;
            Altitude right      = Altitude.unassigned;;

            //Assign front
            n = Board.instance.getNode(auto.position + auto.forward);
            if (n != null)
            {
                front = n.terrain.type.gameplayData.altitude;
            }

            //assign frontright
            n = Board.instance.getNode(auto.position + auto.forward + auto.right);
            if (n != null)
            {
                frontRight = n.terrain.type.gameplayData.altitude;
            }

            //assign frontleft
            n = Board.instance.getNode(auto.position + (auto.forward - auto.right));
            if (n != null)
            {
                frontLeft = n.terrain.type.gameplayData.altitude;
            }

            //assign back
            n = Board.instance.getNode(auto.position - (auto.forward));
            if (n != null)
            {
                back = n.terrain.type.gameplayData.altitude;
            }

            //assign backright
            n = Board.instance.getNode(auto.position - (auto.forward + auto.right));
            if (n != null)
            {
                backRight = n.terrain.type.gameplayData.altitude;
            }

            //assign backleft
            n = Board.instance.getNode(auto.position - (auto.forward - auto.right));
            if (n != null)
            {
                backLeft = n.terrain.type.gameplayData.altitude;
            }

            //assign left
            n = Board.instance.getNode(auto.position - (auto.right));
            if (n != null)
            {
                left = n.terrain.type.gameplayData.altitude;
            }

            //assign right
            n = Board.instance.getNode(auto.position + (auto.right));
            if (n != null)
            {
                right = n.terrain.type.gameplayData.altitude;
            }

            TerrainCornerType lCorner = TerrainCornerType.Flat;
            TerrainCornerType rCorner = TerrainCornerType.Flat;

            // 2 1 2
            //   X
            //
            //if there's nothing in front (1)
            if (isDifferent(front))
            {
                //if there's nothing on the frontleft and nothing on the frontright
                if (isDifferent(frontLeft) && isDifferent(frontRight))
                {
                    //if there's nothing on left and right
                    if (isDifferent(left) && isDifferent(right))
                    {
                        //wall with both rounded corners
                        lCorner = TerrainCornerType.Outer;
                        rCorner = TerrainCornerType.Outer;
                    }
                    //if there's something on the right
                    else if (isDifferent(left) && !isDifferent(right))
                    {
                        //wall with rounded on left, flat on right
                        lCorner = TerrainCornerType.Outer;
                        rCorner = TerrainCornerType.Flat;
                    }
                    //if there's something on the left
                    else if (!isDifferent(left) && isDifferent(right))
                    {
                        //wall with flat on the left, rounded on right
                        lCorner = TerrainCornerType.Flat;
                        rCorner = TerrainCornerType.Outer;
                    }
                }
                //if there's nothing on the frontleft and something on the frontright
                else if (isDifferent(frontLeft) && !isDifferent(frontRight))
                {
                    if (isDifferent(left))
                    {
                        //wall with rounded edge on left, inner corner on right
                        lCorner = TerrainCornerType.Outer;
                        rCorner = TerrainCornerType.Inner;
                    }
                    else
                    {
                        //wall with flat on left, inner corner on right
                        lCorner = TerrainCornerType.Flat;
                        rCorner = TerrainCornerType.Inner;
                    }
                }
                //if there's something on the frontleft and nothing on the frontright
                else if (!isDifferent(frontLeft) && isDifferent(frontRight))
                {
                    if (isDifferent(right))
                    {
                        //wall with inner corner on left, rounded on right
                        lCorner = TerrainCornerType.Inner;
                        rCorner = TerrainCornerType.Outer;
                    }
                    else
                    {
                        //wall with inner corner on left, flat on right
                        lCorner = TerrainCornerType.Inner;
                        rCorner = TerrainCornerType.Flat;
                    }
                }
                else if (!isDifferent(frontLeft) && !isDifferent(frontRight))
                {
                    lCorner = TerrainCornerType.Inner;
                    rCorner = TerrainCornerType.Inner;
                }
                createWall(lCorner, rCorner, auto.eulerAngles.y);
            }
            //else don't place a wall here
            auto.rotation = Quaternion.AngleAxis(auto.eulerAngles.y + 90, Vector3.up);
        }
    }
Beispiel #4
0
 public GameObject getWall(TerrainCornerType left, TerrainCornerType right)
 {
     GameObject go;
     go = walls[(int)left, (int)right];
     return go;
 }
Beispiel #5
0
    public void createWall(TerrainCornerType left, TerrainCornerType right, float rot )
    {
        try
        {
            Vector3 rotDir = new Vector3( 0f , rot , 0f );

            GameObject go = type.prefabs.getWall( left , right );
            if ( go == null )
                return;

            go = Instantiate( type.prefabs.getWall( left, right ) , transform.position , Quaternion.Euler( rotDir) ) as GameObject;
            walls.Add( go );
            go.transform.parent = transform;
        }
        catch ( System.Exception e )
        {
            Debug.LogError( e.ToString() + ": COULD NOT INSTANTIATE WALL " + left.ToString() + " " + right.ToString() );
        }
        //go.transform.eulerAngles = new Vector3(0f, direction.y, 0f);
    }