//Copy data from car to this car public RSCar(RSCar car) { this.pos = car.pos; this.heading = car.heading; this.gear = car.gear; this.steering = car.steering; }
//Time-flip transform method from the report, which interchanges + and - //l+ r- s- l- -> l- r+ s+ l+ private static List <SegmentSettings> TimeFlip(List <SegmentSettings> pathSettings) { foreach (SegmentSettings settings in pathSettings) { //Set it to forward RSCar.Gear flippedGear = RSCar.Gear.Forward; //If the current setting is forward, then flip if (settings.gear == RSCar.Gear.Forward) { flippedGear = RSCar.Gear.Back; } settings.gear = flippedGear; } return(pathSettings); }
//Display the Reed Shepp path with line renderers private void DisplayPath(List <RSCar> shortestPath) { List <Vector3> nodes = new List <Vector3>(); //A path needs between 1 and 3 line renderers int lineArrayPos = 0; RSCar.Gear currentGear = shortestPath[0].gear; for (int i = 0; i < shortestPath.Count; i++) { nodes.Add(shortestPath[i].pos); //This means we have finished this segment of the path and should make a line renderer if (shortestPath[i].gear != currentGear) { bool isReversing = shortestPath[i - 1].gear == RSCar.Gear.Back ? true : false; AddPositionsToLineRenderer(nodes, lineArray[lineArrayPos], isReversing); //Restart with the next line lineArrayPos += 1; nodes.Clear(); currentGear = shortestPath[i].gear; //So the lines connect nodes.Add(shortestPath[i].pos); } } //The last segment of the line bool isReversingLast = shortestPath[shortestPath.Count - 1].gear == RSCar.Gear.Back ? true : false; AddPositionsToLineRenderer(nodes, lineArray[lineArrayPos], isReversingLast); }
public SegmentSettings(RSCar.Steering steering, RSCar.Gear gear, float length) { this.steering = steering; this.gear = gear; this.length = length; }
public RSCar(Vector3 pos, float headingInRadians, Gear gear, Steering steering) : this(pos, headingInRadians) { this.gear = gear; this.steering = steering; }