public Racer(iVehicleManager vm, DamageController dc, iRace Race, bool IsMachine) { isMachine = IsMachine; _Race = Race; VehicleManager = vm; _damCtrl = dc; goRacer = vm.goCar; _vehicleController = vm.VehicleController; _defaultMotorForce = _vehicleController.motorForce; _gps = _vehicleController.Gps; if (IsMachine) { _playerGps = DrivingPlayManager.Current.PlayerCarManager.Gps; _playerRacer = DrivingPlayManager.Current.PlayerCarManager.Racer; } else { _scorer = new Scorer(vm, _gps); music = MusicPlayer.Instance; } RoadSegCount = Road.Instance.Segments.Count; if (goRacer.name == "Vehicle1") { _vehicleController.motorForce *= 1.1f; //This car is more powerful. It jumps backward and comes up behind you } _damCtrl.OnCollisionExitEvent += StartHogTimer; }
public void JumpTo(Racer r) { int JumpTotSeg; if (!goRacer.name.EndsWith("1")) { JumpTotSeg = r.TotProgrss + 120; } else { JumpTotSeg = r.TotProgrss - 7; } if (JumpTotSeg < 0) { JumpTotSeg = 0; } int JumpSeg = JumpTotSeg % RoadSegCount; if (JumpSeg < 0) { JumpSeg = 0; } if (JumpSeg > RoadSegCount - 3) { JumpSeg -= (RoadSegCount + 3); } if (Opposition.Where(Opp => Mathf.Abs(Opp.Progrss - JumpSeg) < 7).Count() != 0) { //Debug.Log("Fail"); return; } try { goRacer.transform.position = Road.Instance.XSecs[JumpSeg].MidPt; goRacer.transform.LookAt(Road.Instance.XSecs[JumpSeg + 2].MidPt); goRacer.GetComponent <Rigidbody>().velocity = (Road.Instance.XSecs[JumpSeg + 2].MidPt - Road.Instance.XSecs[JumpSeg].MidPt).normalized * r.goRacer.GetComponent <Rigidbody>().velocity.magnitude; Progrss = JumpSeg; Lap = r.Lap; //bugbugbug if it jumps over the starting line it skips a lap } catch (System.Exception e) { Debug.Log("Cant Jump to " + JumpSeg + " when RoadSegCount = " + RoadSegCount); } iVehicleController VC = VehicleManager.VehicleController; VC.EndSkidmarks = true; PrevProgrss = Progrss; }
protected virtual void Dispose(bool b) { RemoveListeners(); _Race = null; VehicleManager = null; goRacer = null; _vehicleController = null; _damCtrl = null; _gps = null; _playerGps = null; _playerRacer = null; _scorer = null; if (PlayerOpposition != null) { PlayerOpposition.Clear(); Opposition.Clear(); } }