void Update() { if (!(CrossPlatformInputManager.GetAxis("Horizontal") == 0)) { TurboSound.Play(); } GasDisplay.GetComponent <Text>().text = "GAS: " + gas; CashEarned = GlobalCash.EarnedCashCount; EngineLevelDisplay.GetComponent <Text>().text = EngineLevel + "/15"; SuspensionLevelDisplay.GetComponent <Text>().text = SuspensionLevel + "/15"; RotationLevelDisplay.GetComponent <Text>().text = RotationLevel + "/15"; TankLevelDisplay.GetComponent <Text>().text = TankLevel + "/15"; TiresLevelDisplay.GetComponent <Text>().text = TiresLevel + "/15"; EngineDisplay.GetComponent <Text>().text = "" + UpgradeCost; SuspensionDisplay.GetComponent <Text>().text = "" + UpgradeCostSuspension; RotationDisplay.GetComponent <Text>().text = "" + UpgradeCostRotation; TankDisplay.GetComponent <Text>().text = "" + UpgradeCostTank; TiresDisplay.GetComponent <Text>().text = "" + UpgradeCostTires; speedReal = GetComponent <Rigidbody2D>().velocity.magnitude * 3.6f; ThrottleSound.volume = 0.05f; ThrottleSound.pitch = 1f; speedRealFloored = Mathf.Floor(speedReal); DisplaySpeed.GetComponent <Text>().text = speedRealFloored + " km/h"; ShowVelocity.ShowSpeed(speedReal, 0, 130); GetComponent <Rigidbody2D>().AddTorque(carRotationSpeed * CrossPlatformInputManager.GetAxis("Horizontal")); dirX = CrossPlatformInputManager.GetAxis("Horizontal"); if (CrossPlatformInputManager.GetAxis("Horizontal") > 0 && gas > 0) { ThrottleSound.volume = 0.15f; ThrottleSound.pitch = (speedReal / 20) + 0.1f; gasLeak = 0.03f * ((5 + TankLevel) / 5); if (TractionFront) { motorFront.motorSpeed = speedF * -1; motorFront.maxMotorTorque = torqueF; frontwheel.motor = motorFront; } if (TractionBack) { motorBack.motorSpeed = speedF * -1; motorBack.maxMotorTorque = torqueF; backwheel.motor = motorBack; backwheel2.motor = motorBack; } else { motorBack.motorSpeed = 0; } } else if (CrossPlatformInputManager.GetAxis("Horizontal") < 0 && gas > 0) { ThrottleSound.volume = 0.15f; ThrottleSound.pitch = (speedReal / 20) + 0.1f; gasLeak = 0.03f * ((5 + TankLevel) / 5); if (TractionFront) { motorFront.motorSpeed = speedB * -1; motorFront.maxMotorTorque = torqueB; frontwheel.motor = motorFront; } if (TractionBack) { motorBack.motorSpeed = speedB * -1; motorBack.maxMotorTorque = torqueB; backwheel.motor = motorBack; backwheel2.motor = motorBack; } else { motorBack.motorSpeed = 0; } } else { gasLeak = 0.017f * (5 + TankLevel); backwheel.useMotor = false; backwheel2.useMotor = false; frontwheel.useMotor = false; } torqueF = (130f * EngineLevel + 3800) * 0.25f; torqueB = (130f * EngineLevel + 3800) * 0.25f; speedF = (130f * EngineLevel + 3800) * 0.25f; UpgradeCost = 400 * (EngineLevel) + 400; carRotationSpeed = RotationLevel + 8; UpgradeCostRotation = 400 * (RotationLevel) + 400; frontSuspension.frequency = (SuspensionLevel + 1) * 0.25f; backSuspension.frequency = (SuspensionLevel + 1) * 0.25f; backSuspension2.frequency = (SuspensionLevel + 1) * 0.25f; UpgradeCostSuspension = 400 * (SuspensionLevel) + 400; UpgradeCostTank = 400 * (TankLevel) + 400; WheelMaterial.wheelFriction = 0.1f + (0.05f * (TiresLevel + 1)); UpgradeCostTires = 400 * (TiresLevel) + 400; }
void Start() { thisSpeedo = this; }