示例#1
0
 public override string ToString()
 {
     return(gameObject.name + ": " + direction.ToString());
 }
示例#2
0
 public static string ToAddress(this RoadDirection direction)
 {
     return($"Assets/Tileset/{direction.ToString().ToLowerKebabCase()}.asset");
 }
示例#3
0
        public void SetDirection(RoadDirection direction)
        {
            ArgumentException AE = new ArgumentException("Direction \"" + direction.ToString() + "\" is not compatible with road type " + this.type.ToString() + ".");

            switch (this.type)
            {
            case RoadType.Straight:
                if (direction == RoadDirection.Vertical)
                {
                    transform.localEulerAngles = new Vector3(90, 0, 0);
                }
                else if (direction == RoadDirection.Horizontal)
                {
                    transform.localEulerAngles = new Vector3(90, 0, 270);
                }
                else
                {
                    throw AE;
                }
                break;

            case RoadType.End:
                if (direction == RoadDirection.North)
                {
                    transform.localEulerAngles = new Vector3(90, 0, 180);
                }
                else if (direction == RoadDirection.South)
                {
                    transform.localEulerAngles = new Vector3(90, 0, 0);
                }
                else if (direction == RoadDirection.East)
                {
                    transform.localEulerAngles = new Vector3(90, 0, 90);
                }
                else if (direction == RoadDirection.West)
                {
                    transform.localEulerAngles = new Vector3(90, 0, 270);
                }
                else
                {
                    throw AE;
                }
                break;

            case RoadType.Corner:
                if (direction == RoadDirection.NorthEast)
                {
                    transform.localEulerAngles = new Vector3(90, 0, 90);
                }
                else if (direction == RoadDirection.NorthWest)
                {
                    transform.localEulerAngles = new Vector3(90, 0, 180);
                }
                else if (direction == RoadDirection.SouthEast)
                {
                    transform.localEulerAngles = new Vector3(90, 0, 0);
                }
                else if (direction == RoadDirection.SouthWest)
                {
                    transform.localEulerAngles = new Vector3(90, 0, 270);
                }
                else
                {
                    throw AE;
                }
                break;

            case RoadType.Cross_T:
                if (direction == RoadDirection.North)
                {
                    transform.localEulerAngles = new Vector3(90, 0, 90);
                }
                else if (direction == RoadDirection.South)
                {
                    transform.localEulerAngles = new Vector3(90, 0, 270);
                }
                else if (direction == RoadDirection.East)
                {
                    transform.localEulerAngles = new Vector3(90, 0, 0);
                }
                else if (direction == RoadDirection.West)
                {
                    transform.localEulerAngles = new Vector3(90, 0, 180);
                }
                else
                {
                    throw AE;
                }
                break;

            case RoadType.Cross_X:
                if (direction != RoadDirection.None)
                {
                    throw AE;
                }
                break;

            case RoadType.Single:
                if (direction == RoadDirection.None)
                {
                    transform.localEulerAngles = new Vector3(90, 0, 0);
                }
                else
                {
                    throw AE;
                }
                break;
            }
            this.direction = direction;

            //SetPoints();
        }