コード例 #1
0
        public RoadConnection( IRoadLine roadLine, RoadSide roadSide )
        {
            this._shapeChanged = new Subject<Unit>();

            var wrapper = new RoadLineWrapper( roadLine, roadSide != RoadSide.Begin );
           // this._connectedRoads = new List<RoadLineWrapper> { wrapper };
            this._connectedRoads = new List<RoadLineWrapper>();

            this._shape = this.GenerateShape();
        }
コード例 #2
0
        void Awake()
        {
            // getComponent
            GetComponents();

            side   = RoadSide.Center;
            origin = Vector3.zero;
            SetMoveDirection(Orientation.North);

            canJump       = true;
            canChangeRoad = true;
            canTurn       = false;
            hasTurned     = false;

            RegEvent();
        }
コード例 #3
0
        public Vector3 GetCorrectPosition(RoadSide roadSide)
        {
            float x = transform.localPosition.x;
            float y = transform.localPosition.y;
            float z = transform.localPosition.z;

            switch (moveToward)
            {
            case Orientation.North:
                return(new Vector3(origin.x + (int)roadSide, y, z));

            case Orientation.East:
                return(new Vector3(x, y, origin.z - (int)roadSide));

            case Orientation.South:
                return(new Vector3(origin.x - (int)roadSide, y, z));

            case Orientation.West:
                return(new Vector3(x, y, origin.z + (int)roadSide));

            default:
                return(transform.localPosition);
            }
        }
コード例 #4
0
 //constructors
 public RoadSide(RoadSide defaultLocation)
 {
     this.index = defaultLocation.index;
 }
コード例 #5
0
        public void Connect( IRoadLine roadLine, RoadSide roadSide )
        {
            Assert.That( this._connectedRoads, Is.Not.Contains( roadLine ) ).Throw<ArgumentException>();

            if ( this._connectedRoads.Any( t => t.Orginal == roadLine ) )
            {
                return;
            }

            this._connectedRoads.Add( new RoadLineWrapper( roadLine, roadSide != RoadSide.Begin ));
            this._shape = this.GenerateShape();
        }
コード例 #6
0
 /// <summary>
 /// 变道, 变道只改变坐标的x或者z分量
 /// moveDirection:
 /// straight      :锁x  左x-1    中x    右x+1
 /// right         :锁z  左z+1    中z    右z-1
 /// back          :锁x  左x+1    中x    右x-1
 /// left          :锁z  左z-1    中z    右z+1
 /// </summary>
 void ChangeRoad(RoadSide side)
 {
     this.side = side;
 }