/// <summary> /// Sets up values related to the track and road /// </summary> private void SetupRoadValues() { raceTrackDict = new Dictionary <string, RaceTrack>(); foreach (RaceTrack track in tracks) { raceTrackDict.Add(track.Name, track); } for (int i = 0; i < tracks.Length; i++) { tracks[i].CheckMaxRoadTypes(); tracks[i].CheckForStartAndEnd(); } trackPlaying = raceTrackDict[InRoomManager.Instance.NameOfTrackChoosen]; roadOn = roads[2]; roadOn.SetupRoad(trackPlaying.RoadTypes, trackIndexOn); roads[1].SetupRoad(trackPlaying.RoadTypes, trackIndexOn + 1); roads[0].SetupRoad(trackPlaying.RoadTypes, trackIndexOn + 2); roadLength = roadOn.MainBounds.size.y; }
/// <summary> /// Updateds roadOn value and trackIndexOn based on given forward value /// </summary> /// <param name="forward"></param> private void UpdateRoadOn(bool forward) { trackIndexOn += forward ? 1 : -1; //define whether we are on start or end bool onStart = trackIndexOn == 0; bool onEnd = trackIndexOn == trackPlaying.RoadCount - 1; //if we are on the starting road and are moving backward, we set road on to bottom one if (onStart && !forward) { roadOn = roads[2]; } //if we are on the end of the road and are moving forward we set road on to top one else if (onEnd && forward) { roadOn = roads[0]; } else { //on default, road on is always the middle one of the 3 roadOn = roads[1]; } }
private void Testing() { raceTrackDict = new Dictionary <string, RaceTrack>(); foreach (RaceTrack track in tracks) { raceTrackDict.Add(track.Name, track); } for (int i = 0; i < tracks.Length; i++) { tracks[i].CheckMaxRoadTypes(); tracks[i].CheckForStartAndEnd(); } GameObject.Find("Car").GetComponent <Racer>().OnRoadBoundInteraction += DoRoadShift; trackPlaying = raceTrackDict["Default"]; //set other roads their type based on next road types to come roadOn = roads[2]; roadOn.SetupRoad(trackPlaying.RoadTypes, trackIndexOn); roads[1].SetupRoad(trackPlaying.RoadTypes, 1); roads[0].SetupRoad(trackPlaying.RoadTypes, 2); roadLength = roadOn.MainBounds.size.y; }