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(); }
void Awake() { // getComponent GetComponents(); side = RoadSide.Center; origin = Vector3.zero; SetMoveDirection(Orientation.North); canJump = true; canChangeRoad = true; canTurn = false; hasTurned = false; RegEvent(); }
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); } }
//constructors public RoadSide(RoadSide defaultLocation) { this.index = defaultLocation.index; }
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(); }
/// <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; }