public Road(Vector2 from, Vector2 to, float fromOffset, float toOffset, float width, float interval, float bolid) { this.id = ID; this.from = from; this.to = to; this.fromOffset = fromOffset; this.toOffset = toOffset; this.width = width; this.interval = interval; this.bolid = bolid; var dir = (to - from); this.direction = dir.normalized; this.magnitude = dir.magnitude; this.fromPointID = RoadPointer.AddPoint(from, ID); this.toPointID = RoadPointer.AddPoint(to, ID); ID++; }
private void SetNextRoad(Road road, CityArea city, float straightRate) { if (this.isIntersection == true) { var next = city.Roads[this.nextID]; this.dir = next.Direction * (this.isForward == true ? 1f : -1f); this.magnitude = next.OffsetMagnitude; this.from = this.pos; this.to = (this.isForward == true ? next.OffsetTo : next.OffsetFrom) + (this.dir.Normal() * this.offset); this.roadID = this.nextID; this.isIntersection = false; } else { this.nextID = RoadPointer.GetNextRoadID( road, this.isForward == true ? road.ToPointID : road.FromPointID, city, straightRate); var next = city.Roads[this.nextID]; this.isForward = next.IsForward(this.to); var dir = next.Direction * (isForward == true ? 1f : -1f); this.from = this.to; this.to = (isForward == true ? next.OffsetFrom : next.OffsetTo) + dir.Normal() * this.offset; dir = this.to - this.from; this.dir = dir.normalized; this.magnitude = dir.magnitude; this.isIntersection = true; } this.progress = 0f; }