//change gearbox types public override void changeGearBoxToAutomatic() { GearBox gearbox = GearBox.Create(false, ratios, 0.2f); currentMotor = new CarMotor(power, 8, 8f, gearbox); resetGears(); }
public override void changeGearBoxToManual() { GearBox gearbox = GearBox.Create(true, ratios, 0.2f); currentMotor = new CarMotor(power, 8, 8f, gearbox); resetGears(); }
private void Awake() { if (instance == null) { instance = this; } }
private CarMotor m_Car; // the car motor we want to use private void Awake() { m_Rigidbody = GetComponent <Rigidbody>(); m_Car = new CarMotor(); m_Car.SetCarMovementInterface(this); m_Car.InitializeCarMotor(m_CentreOfMassOffset, m_MaximumSteerAngle, m_SteerHelper, m_TractionControl, m_FullTorqueOverAllWheels, m_ReverseTorque, m_Topspeed, m_RevRangeBoundary, m_SlipLimit, m_BrakeTorque); m_Car.SetCarAudioInterface(this); m_Car.InitializeCarAudio(lowPitchMin, lowPitchMax); m_Car.StartSound(); }
private CarMotor m_Car; // the car motor we want to use private void Awake() { m_Rigidbody = GetComponent<Rigidbody>(); m_Car = new CarMotor(); m_Car.SetCarMovementInterface(this); m_Car.InitializeCarMotor(m_CentreOfMassOffset, m_MaximumSteerAngle, m_SteerHelper, m_TractionControl, m_FullTorqueOverAllWheels, m_ReverseTorque, m_Topspeed, m_RevRangeBoundary, m_SlipLimit, m_BrakeTorque); m_Car.SetCarAudioInterface(this); m_Car.InitializeCarAudio(lowPitchMin, lowPitchMax); m_Car.StartSound(); }
public void PrintAuto() { Console.WriteLine("Color: " + Color); Console.WriteLine("AmountOfWheels: " + AmountOfWheels); Console.WriteLine("Brand: " + Brand); Console.WriteLine("AmountOfDoors: " + AmountOfDoors); Console.WriteLine("Torque: " + Torque); Console.WriteLine("Motor:"); CarMotor.PrintMotor(); }
public void MoveDidApplyHandbrake() { //Arrange CarMotor car = new CarMotor(); var movement = GetMovementMock(); car.SetCarMovementInterface(movement); //Act car.Move(0, 0, 0, 1); //Assert movement.Received().ApplyHandBrake(Arg.Any <float>()); // we should see the velocity being reset }
public void InitializeCarMotor() { //Arrange CarMotor car = new CarMotor(); var movement = GetMovementMock(); car.SetCarMovementInterface(movement); Vector3 CoM = new Vector3(1, 1, 1); //Act car.InitializeCarMotor(CoM, 25f, 0.7f, 0.5f, 2500f, 500f, 100f, 1f, 0.3f, 20000f); //Assert movement.Received().SetWheelColliderCenterOfMass(CoM); }
public void StopSound() { // Arrange CarMotor car = new CarMotor(); var audio = GetAudioMock(); car.SetCarAudioInterface(audio); //Act car.StopSound(); //Assert audio.Received().StopSound(); }
public void MoveAddDownforce() { //Arrange CarMotor car = new CarMotor(); var movement = GetMovementMock(); car.SetCarMovementInterface(movement); float dF = (float)GetInstanceField(typeof(CarMotor), car, "m_Downforce"); //Act car.Move(0, 0, 0, 1); //Assert movement.Received().AddDownForce(dF); // we should see the velocity being reset }
public void MoveClamping() { //Arrange CarMotor car = new CarMotor(); var movement = GetMovementMock(); car.SetCarMovementInterface(movement); car.InitializeCarMotor(new Vector3(0, 0, 0), 25f, 0.7f, 0.5f, 2500f, 500f, 100f, 1f, 0.3f, 20000f); //Act car.Move(0, 25, -25, 0); //Assert Assert.AreEqual(1f, car.AccelInput); Assert.AreEqual(-1f, -car.BrakeInput); }
public void CarAudio() { // Arrange CarMotor car = new CarMotor(); var audio = GetAudioMock(); car.SetCarAudioInterface(audio); car.InitializeCarAudio(0.5f, 0.5f); //Act car.CarAudio(); //Assert audio.Received().AdjustPitch(Arg.Any <float>()); audio.Received().AdjustVolumes(Arg.Any <float>(), Arg.Any <float>(), Arg.Any <float>(), Arg.Any <float>()); }
public void MoveApplyDrive() { //Arrange CarMotor car = new CarMotor(); var movement = GetMovementMock(); car.SetCarMovementInterface(movement); car.InitializeCarMotor(new Vector3(0, 0, 0), 25f, 0.7f, 0.5f, 2500f, 500f, 100f, 1f, 0.3f, 20000f); float t = (float)GetInstanceField(typeof(CarMotor), car, "m_CurrentTorque"); float accel = 0.5f; //Act car.Move(0, accel, 0, 0); //Assert movement.Received().ApplyMotorTorque(accel * t / 4); // t in this case is the total torque over all 4 wheels so divide by 4 }
public void MoveRotateTires() { //Arrange CarMotor car = new CarMotor(); var movement = GetMovementMock(); car.SetCarMovementInterface(movement); car.InitializeCarMotor(new Vector3(0, 0, 0), 25f, 0.7f, 0.5f, 2500f, 500f, 100f, 1f, 0.3f, 20000f); float maxSteerAngle = (float)GetInstanceField(typeof(CarMotor), car, "m_MaximumSteerAngle"); float steering = 0.5f; //Act car.Move(steering, 0, 0, 0); //Assert movement.Received().RotateFrontTires(steering * maxSteerAngle); }
void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player") { car = other.gameObject.GetComponent <CarMotor>(); // not sure about the syntax here... if (car) { // We speed up the player and then tell to stop after a few seconds car.rb.AddTorque(0, 0, car.speedBoost); car.speedBoost = 1.5f; StartCoroutine(car.StopSpeedUp()); } Destroy(gameObject); } }
public void MoveCapSpeed() { //Arrange CarMotor car = new CarMotor(); var movement = GetMovementMock(); movement.GetRigidbodyVelocity().Returns(100f); // this will return a velocity magnitude equal to our top speed variable car.SetCarMovementInterface(movement); float topSpeed = 100f; car.InitializeCarMotor(new Vector3(0, 0, 0), 25f, 0.7f, 0.5f, 2500f, 500f, topSpeed, 1f, 0.3f, 20000f); float mphConst = (float)GetInstanceField(typeof(CarMotor), car, "k_MphConst"); //Act car.Move(0, 1, 0, 0); //Assert movement.Received().SetRigidbodyVelocity(topSpeed/mphConst); // we should see the velocity being reset }
public void MoveCapSpeed() { //Arrange CarMotor car = new CarMotor(); var movement = GetMovementMock(); movement.GetRigidbodyVelocity().Returns(100f); // this will return a velocity magnitude equal to our top speed variable car.SetCarMovementInterface(movement); float topSpeed = 100f; car.InitializeCarMotor(new Vector3(0, 0, 0), 25f, 0.7f, 0.5f, 2500f, 500f, topSpeed, 1f, 0.3f, 20000f); float mphConst = (float)GetInstanceField(typeof(CarMotor), car, "k_MphConst"); //Act car.Move(0, 1, 0, 0); //Assert movement.Received().SetRigidbodyVelocity(topSpeed / mphConst); // we should see the velocity being reset }
public void MoveCheckForWheelSpinEndTrail() { //Arrange CarMotor car = new CarMotor(); var movement = GetMovementMock(); movement.GetWheelColliderForwardSlip(Arg.Any <int>()).Returns(0); // less then slip limit movement.GetWheelColliderSidewaysSlip(Arg.Any <int>()).Returns(0); // less then slip limit car.SetCarMovementInterface(movement); float slipLimit = 0.3f; car.InitializeCarMotor(new Vector3(0, 0, 0), 25f, 0.7f, 0.5f, 2500f, 500f, 100f, 1f, slipLimit, 20000f); //Act car.Move(0, 0, 0, 1); //Assert movement.Received(4).EndSkidTrail(Arg.Any <int>()); // we should the skid trail ending 4 times }
public void MoveCheckForWheelSpinTireSmoke() { //Arrange CarMotor car = new CarMotor(); var movement = GetMovementMock(); movement.GetWheelColliderForwardSlip(Arg.Any <int>()).Returns(1); // more then slip limit movement.GetWheelColliderSidewaysSlip(Arg.Any <int>()).Returns(1); // more then slip limit car.SetCarMovementInterface(movement); float slipLimit = 0.3f; car.InitializeCarMotor(new Vector3(0, 0, 0), 25f, 0.7f, 0.5f, 2500f, 500f, 100f, 1f, slipLimit, 20000f); //Act car.Move(0, 0, 0, 1); //Assert movement.Received(4).EmitTireSmoke(Arg.Any <int>()); // we should the tire smoke emitted 4 times }
// Start is called before the first frame update void Awake() { //storing the lengths of each command in the dict :) commandToMaxTime = new Dictionary <Command, float>() { { Command.SWERVE_LEFT, swervingMaxTime }, { Command.SWERVE_RIGHT, swervingMaxTime }, { Command.TURN_LEFT, turningMaxTime }, { Command.TURN_RIGHT, turningMaxTime }, { Command.BRAKE, brakingMaxTime }, { Command.SLOW_DOWN, slowingMaxTime } }; motor = GetComponent <CarMotor>(); if (!GameObject.Find(AINavigatorTemplate.name)) { GameObject AIObject = Instantiate(AINavigatorTemplate); AINavigator = AIObject.GetComponent <NavMeshAgent>(); } }
///////////////////////////////////////// void Start() { motor = GetComponent <CarMotor>(); animator = GetComponent <Animator>(); }
public void MoveCheckForWheelSpinEndTrail() { //Arrange CarMotor car = new CarMotor(); var movement = GetMovementMock(); movement.GetWheelColliderForwardSlip(Arg.Any<int>()).Returns(0); // less then slip limit movement.GetWheelColliderSidewaysSlip(Arg.Any<int>()).Returns(0); // less then slip limit car.SetCarMovementInterface(movement); float slipLimit = 0.3f; car.InitializeCarMotor(new Vector3(0, 0, 0), 25f, 0.7f, 0.5f, 2500f, 500f, 100f, 1f, slipLimit, 20000f); //Act car.Move(0, 0, 0, 1); //Assert movement.Received(4).EndSkidTrail(Arg.Any<int>()); // we should the skid trail ending 4 times }
public void CarAudio() { // Arrange CarMotor car = new CarMotor(); var audio = GetAudioMock(); car.SetCarAudioInterface(audio); car.InitializeCarAudio(0.5f, 0.5f); //Act car.CarAudio(); //Assert audio.Received().AdjustPitch(Arg.Any<float>()); audio.Received().AdjustVolumes(Arg.Any<float>(), Arg.Any<float>(), Arg.Any<float>(), Arg.Any<float>()); }
// Use this for initialization void Start() { collider = GetComponent <MeshCollider>(); carMotor = GetComponent <CarMotor>(); }
// Use this for initialization void Start() { carMotor = GetComponent <CarMotor>(); }
public void MoveCheckForWheelSpinTireSmoke() { //Arrange CarMotor car = new CarMotor(); var movement = GetMovementMock(); movement.GetWheelColliderForwardSlip(Arg.Any<int>()).Returns(1); // more then slip limit movement.GetWheelColliderSidewaysSlip(Arg.Any<int>()).Returns(1); // more then slip limit car.SetCarMovementInterface(movement); float slipLimit = 0.3f; car.InitializeCarMotor(new Vector3(0, 0, 0), 25f, 0.7f, 0.5f, 2500f, 500f, 100f, 1f, slipLimit, 20000f); //Act car.Move(0, 0, 0, 1); //Assert movement.Received(4).EmitTireSmoke(Arg.Any<int>()); // we should the tire smoke emitted 4 times }
public void MoveDidApplyHandbrake() { //Arrange CarMotor car = new CarMotor(); var movement = GetMovementMock(); car.SetCarMovementInterface(movement); //Act car.Move(0, 0, 0, 1); //Assert movement.Received().ApplyHandBrake(Arg.Any<float>()); // we should see the velocity being reset }
// Start is called before the first frame update void Awake() { motor = GetComponent <CarMotor>(); }
// Use this for initialization void Start() { motor = GetComponent <CarMotor>(); //Disable Dragon Controller. Wait for Player to mount to enable. this.enabled = false; }