コード例 #1
0
ファイル: Vertex.cs プロジェクト: Joe32320/Project-Stephenson
 public Vertex(Vector3 nPosition, VertOrientation nOrientation, BoardGraphics nGraphics, int num, bool isInWestHalf, float mapX)
 {
     position = nPosition;
     if (isInWestHalf)
     {
         secondPosition = new Vector3(position.x + mapX, position.y, position.z);
     }
     else
     {
         secondPosition = new Vector3(position.x - mapX, position.y, position.z);
     }
     orientation = nOrientation;
     graphics    = nGraphics;
     vertNum     = num;
     isRiver     = false;
     height      = -500f;
 }
コード例 #2
0
        /// <summary>
        /// Gets the position for object.
        /// </summary>
        /// <returns>The position for object.</returns>
        /// <param name="parentObject">Parent object.</param>
        /// <param name="objectToPlace">Object to place.</param>
        /// <param name="getForWall">Get for wall.</param>
        public void GetPositionForObject(HorzOrientation horzOrientation = HorzOrientation.Center, VertOrientation vertOrientation = VertOrientation.Center)
        {
            float childShortSide = OrientationCalculation.ChildSize.x > OrientationCalculation.ChildSize.z ? OrientationCalculation.ChildSize.z : OrientationCalculation.ChildSize.x;

            // Set object
            OrientationCalculation.Child.transform.SetParent(OrientationCalculation.Wall.transform);
            OrientationCalculation.Child.transform.localPosition = new Vector3((OrientationCalculation.Wall.WallStrength + (childShortSide / 2)) * -1,
                                                                               OrientationCalculation.YPos,
                                                                               OrientationCalculation.ZPos);
            OrientationCalculation.Child.transform.localRotation = Quaternion.Euler(new Vector3(0, OrientationCalculation.Wall.transform.localRotation.y, 0));
        }
コード例 #3
0
    // type=0 is a junction, type=1 is a through, type=2 is a delta, type=3 is a spring, type=4 Delete
    public void buildRiverVertex(int junction, VertOrientation orientate, bool up, bool east, bool west, int vertNum, Vector3 position, Vector3 secondPosition)
    {
        int        angle = 0;
        GameObject piece = riverEnd;

        if (junction == 0)
        {
            if (orientate == VertOrientation.Up)
            {
                angle = 180;
            }
            piece = riverJunction;
        }
        else if (junction == 1)
        {
            if (up && west)
            {
                if (orientate == VertOrientation.Down)
                {
                    angle = 0;
                }
                else
                {
                    angle = 300;
                }
            }
            else if (up && east)
            {
                if (orientate == VertOrientation.Down)
                {
                    angle = 120;
                }
                else
                {
                    angle = 180;
                }
            }
            else if (east && west)
            {
                if (orientate == VertOrientation.Down)
                {
                    angle = 240;
                }
                else
                {
                    angle = 60;
                }
            }

            piece = riverThrough;
        }
        else if (junction == 2 || junction == 3)
        {
            if (up)
            {
                if (orientate == VertOrientation.Down)
                {
                    angle = 0;
                }
                else
                {
                    angle = 180;
                }
            }
            else if (east)
            {
                if (orientate == VertOrientation.Down)
                {
                    angle = 120;
                }
                else
                {
                    angle = 60;
                }
            }
            else
            {
                if (orientate == VertOrientation.Down)
                {
                    angle = 240;
                }
                else
                {
                    angle = 300;
                }
            }

            if (junction == 2)
            {
                piece = riverEnd;
            }
            else
            {
                piece = riverStart;
            }
        }

        if (vertPieces[vertNum] != null)
        {
            Destroy(vertPieces[vertNum]);
            Destroy(vertPieces[vertNum + (vertPieces.Length / 2)]);
        }
        GameObject test = GameObject.Instantiate(piece, position, Quaternion.AngleAxis(angle, new Vector3(0, 0, 1))) as GameObject;

        vertPieces[vertNum]   = test;
        test.transform.parent = gameObject.transform;
        test.isStatic         = true;

        GameObject test1 = GameObject.Instantiate(piece, secondPosition, Quaternion.AngleAxis(angle, new Vector3(0, 0, 1))) as GameObject;

        vertPieces[vertNum + (vertPieces.Length / 2)] = test1;
        test1.transform.parent = gameObject.transform;
        test1.isStatic         = true;

        if (junction == 4)
        {
            if (vertPieces[vertNum] != null)
            {
                Destroy(vertPieces[vertNum]);
                Destroy(vertPieces[vertNum + (vertPieces.Length / 2)]);
            }
        }
    }