示例#1
0
 public bool AddRoad(DirEnum dir)
 {
     if (!roads.Contains(dir))
     {
         roads.Add(dir);
         return(true);
     }
     return(false);
 }
 /// <summary>
 /// A public constructor for block objects.  The constructor takes an argument for each datafield in the
 /// object, allowing them all to be initialized at once.
 /// </summary>
 /// <param name="bID">The block ID of the block</param>
 /// <param name="state">The StateEnum state of the block (Healthy, TrackCircuitFailure, etc)</param>
 /// <param name="pBID">The previous* block ID of the block.</param>
 /// <param name="sElev">The cumulative elevation of the block</param>
 /// <param name="g">The grade of the track on this block</param>
 /// <param name="loc">An X,Y pair stored in an integer array representing the </param>
 /// <param name="bS">The block size of this block</param>
 /// <param name="dir">The DirEnum direction of the block</param>
 /// <param name="atts">An array of infrastructure attributes for the block</param>
 /// <param name="d1">The block ID of the next* block.</param>
 /// <param name="d2">The block ID of the alternate next* block.  Only valid if block has switch</param>
 /// <param name="tCID">The Track Circuit ID that the given block reports on</param>
 /// <param name="l">The line of the current block: either "Red" or "Green"</param>
 /// <param name="sL">The Speed Limit of the block.  Trains must maintain speeds below posted limits</param>
 public Block(int bID, StateEnum state, int pBID, double sElev, double g, int[] loc, double bS, DirEnum dir,
              string[] atts, int d1, int d2, int tCID, string l, int sL)
 {
     _blockID      = bID;
     State         = state;
     _prevBlockID  = pBID;
     _startingElev = sElev;
     _grade        = g;
     _location     = loc;
     BlockSize     = bS;
     _direction    = dir;
     _attributes   = atts;
     _switchDest1  = d1;
     SwitchDest2   = d2;
     _trackCirID   = tCID;
     _line         = l;
     _speedLimit   = sL;
 }
示例#3
0
 /// <summary>
 /// A public constructor for block objects.  The constructor takes an argument for each datafield in the
 /// object, allowing them all to be initialized at once.
 /// </summary>
 /// <param name="bID">The block ID of the block</param>
 /// <param name="state">The StateEnum state of the block (Healthy, TrackCircuitFailure, etc)</param>
 /// <param name="pBID">The previous* block ID of the block.</param>
 /// <param name="sElev">The cumulative elevation of the block</param>
 /// <param name="g">The grade of the track on this block</param>
 /// <param name="loc">An X,Y pair stored in an integer array representing the </param>
 /// <param name="bS">The block size of this block</param>
 /// <param name="dir">The DirEnum direction of the block</param>
 /// <param name="atts">An array of infrastructure attributes for the block</param>
 /// <param name="d1">The block ID of the next* block.</param>
 /// <param name="d2">The block ID of the alternate next* block.  Only valid if block has switch</param>
 /// <param name="tCID">The Track Circuit ID that the given block reports on</param>
 /// <param name="l">The line of the current block: either "Red" or "Green"</param>
 /// <param name="sL">The Speed Limit of the block.  Trains must maintain speeds below posted limits</param>
 public Block(int bID, StateEnum state, int pBID, double sElev, double g, int[] loc, double bS, DirEnum dir,
              string[] atts, int d1, int d2, int tCID, string l, int sL)
 {
     _blockID = bID;
     State = state;
     _prevBlockID = pBID;
     _startingElev = sElev;
     _grade = g;
     _location = loc;
     BlockSize = bS;
     _direction = dir;
     _attributes = atts;
     _switchDest1 = d1;
     SwitchDest2 = d2;
     _trackCirID = tCID;
     _line = l;
     _speedLimit = sL;
 }
示例#4
0
    //获取角色移动方向
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.W))
        {
            Player_1 = DirEnum.P1Up;

            isMove      = true;
            WhichPlayer = 1;
            Forward     = MoveDir.Up;

            Debug.Log("key is W");
        }
        if (Input.GetKeyDown(KeyCode.A))
        {
            Player_1 = DirEnum.P1Left;

            isMove      = true;
            WhichPlayer = 1;
            Forward     = MoveDir.Left;

            isMove = true;
            Debug.Log("key is A");
        }
        if (Input.GetKeyDown(KeyCode.S))
        {
            Player_1 = DirEnum.P1Down;

            isMove      = true;
            WhichPlayer = 1;
            Forward     = MoveDir.Down;

            Debug.Log("key is S");
        }
        if (Input.GetKeyDown(KeyCode.D))
        {
            Player_1 = DirEnum.P1Right;

            isMove      = true;
            WhichPlayer = 1;
            Forward     = MoveDir.Right;

            Debug.Log("key is D");
        }
        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            Player_2 = DirEnum.P2Up;

            isMove      = true;
            WhichPlayer = 2;
            Forward     = MoveDir.Up;

            Debug.Log("key is UP");
        }
        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            Player_2 = DirEnum.P2Left;

            isMove      = true;
            WhichPlayer = 2;
            Forward     = MoveDir.Left;

            Debug.Log("key is LEFT");
        }
        if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            Player_2 = DirEnum.P2Down;

            isMove      = true;
            WhichPlayer = 2;
            Forward     = MoveDir.Down;

            Debug.Log("key is DOWN");
        }
        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            Player_2 = DirEnum.P2Right;

            isMove      = true;
            WhichPlayer = 2;
            Forward     = MoveDir.Right;

            Debug.Log("key is RIGHT");
        }
        if (isMove)
        {
            input_GM.Move(WhichPlayer, Forward);
        }
    }
示例#5
0
        public Color GetPixel(int x, int y)
        {
            RotationType rotationType = RotationType.None;

            string[] dirs = Enum.GetNames(typeof(DirEnum));
            switch (roads.Count)
            {
                #region 一条路
            case 1:
                texType = TextrueType.ThreeSide;
                for (int i = 0; i < dirs.Length; i++)
                {
                    DirEnum temp = (DirEnum)Enum.Parse(typeof(DirEnum), dirs[i]);
                    if (roads.Contains(temp))
                    {
                        switch (temp)
                        {
                        case DirEnum.Up:
                            rotationType = RotationType.OppositesUpDown;
                            break;

                        case DirEnum.Down:
                            rotationType = RotationType.None;
                            break;

                        case DirEnum.Left:
                            rotationType = RotationType.ClockWise;
                            break;

                        case DirEnum.Right:
                            rotationType = RotationType.AntiClockWise;
                            break;

                        default:
                            Debug.LogError("=");
                            break;
                        }
                        break;
                    }
                }
                break;

                #endregion

                #region 2条路

            case 2:
                if (roads.Contains(DirEnum.Up) && roads.Contains(DirEnum.Down))
                {
                    texType      = TextrueType.TwoSideFaceToFace;
                    rotationType = RotationType.None;
                }
                else if (roads.Contains(DirEnum.Left) && roads.Contains(DirEnum.Right))
                {
                    texType      = TextrueType.TwoSideFaceToFace;
                    rotationType = RotationType.ClockWise;
                }
                else if (roads.Contains(DirEnum.Left) && roads.Contains(DirEnum.Up))
                {
                    texType      = TextrueType.TwoSideAdjacent;
                    rotationType = RotationType.ClockWise;
                }
                else if (roads.Contains(DirEnum.Left) && roads.Contains(DirEnum.Down))
                {
                    texType      = TextrueType.TwoSideAdjacent;
                    rotationType = RotationType.None;
                }
                else if (roads.Contains(DirEnum.Right) && roads.Contains(DirEnum.Up))
                {
                    texType      = TextrueType.TwoSideAdjacent;
                    rotationType = RotationType.DuiJiaoRightTop;
                }
                else if (roads.Contains(DirEnum.Right) && roads.Contains(DirEnum.Down))
                {
                    texType      = TextrueType.TwoSideAdjacent;
                    rotationType = RotationType.OppositesLeftRight;
                }
                break;

                #endregion

                #region 3条路
            case 3:
                texType = TextrueType.OneSide;
                for (int i = 0; i < dirs.Length; i++)
                {
                    DirEnum temp = (DirEnum)Enum.Parse(typeof(DirEnum), dirs[i]);
                    if (!roads.Contains(temp))
                    {
                        switch (temp)
                        {
                        case DirEnum.Up:
                            rotationType = RotationType.AntiClockWise;
                            break;

                        case DirEnum.Down:
                            rotationType = RotationType.ClockWise;
                            break;

                        case DirEnum.Left:
                            rotationType = RotationType.OppositesLeftRight;
                            break;

                        case DirEnum.Right:
                            rotationType = RotationType.None;
                            break;

                        default:
                            Debug.LogError("=");
                            break;
                        }
                        break;
                    }
                }
                break;
                #endregion

                #region 4条路
            case 4:
                texType      = TextrueType.NoSide;
                rotationType = RotationType.None;
                break;

                #endregion
            default:
                texType      = TextrueType.FourSide;
                rotationType = RotationType.None;
                break;
            }
            Texture2D tex = GetTexture(texType);
            if (tex == null)
            {
                return(Color.red);
            }
            return(GetColorWithRotation(tex, x, y, rotationType));
        }