public void ChangeAssistMode(GameTypes.AssistMode mode) { switch (mode) { case GameTypes.AssistMode.NoAssist: hoverIndicator.color = inactiveColour; astroIndicator.color = inactiveColour; quantumIndicator.color = inactiveColour; break; case GameTypes.AssistMode.Hover: hoverIndicator.color = activeColour; astroIndicator.color = inactiveColour; quantumIndicator.color = inactiveColour; break; case GameTypes.AssistMode.Astro: hoverIndicator.color = inactiveColour; astroIndicator.color = activeColour; quantumIndicator.color = inactiveColour; break; case GameTypes.AssistMode.Quantum: hoverIndicator.color = inactiveColour; astroIndicator.color = inactiveColour; quantumIndicator.color = activeColour; break; } }
void ChangeAssistMode(GameTypes.AssistMode mode) { switch (mode) { case GameTypes.AssistMode.NoAssist: rb.useGravity = true; if (thrusters) { thrusters.SetAstroThrottle(0f); } if (powered) { landingGear.Retract(); } Debug.Log("Ship: Assist off"); break; case GameTypes.AssistMode.Hover: rb.useGravity = false; limitHoverSpeed = false; if (thrusters) { thrusters.SetAstroThrottle(0f); } landingGear.Extend(); Debug.Log("Ship: Hover Mode on"); break; case GameTypes.AssistMode.Astro: rb.useGravity = false; thrusters.SetThrottle(0f); thrusters.SetAstroThrottle(transform.InverseTransformDirection(rb.velocity).z / thrusters.maxAstroSpeed); landingGear.Retract(); Debug.Log("Ship: Astro Flight on"); break; case GameTypes.AssistMode.Quantum: rb.useGravity = false; thrusters.SetThrottle(0f); thrusters.SetAstroThrottle(0f); boosters.SetThrottle(0f, 0f, Vector3.zero); landingGear.Retract(); Debug.Log("Ship: Quantum Flight on"); break; } if (thrusters && mode != GameTypes.AssistMode.Astro) { thrusters.SetThrottle(Input.GetAxis("Move Forward/Back")); } shipComputer.ChangeAssistMode(mode); assistMode = mode; }
public void CheckInput(ControlObject controlObject) { // Toggle Power if (controlObject.jump && assistMode != GameTypes.AssistMode.Quantum) { if (powered) { TogglePower(false); } else if (!powered && FuelAvailable() && !busy) { TogglePower(true); } } if (powered) { if (FuelAvailable()) { // Thruster control if (thrusters) { switch (assistMode) { case GameTypes.AssistMode.NoAssist: thrusters.SetThrottle(controlObject.forwardBack); shipComputer.UpdateThrottleGauge(thrusters.GetThrottle()); fuelPack.DrainFuel(Mathf.Abs(thrusters.GetThrottle()) / thrusters.efficiency * Time.deltaTime); break; case GameTypes.AssistMode.Hover: thrusters.SetThrottle(controlObject.forwardBack / 2f); shipComputer.UpdateThrottleGauge(thrusters.GetThrottle()); fuelPack.DrainFuel(Mathf.Abs(thrusters.GetThrottle() / thrusters.efficiency * Time.deltaTime)); break; case GameTypes.AssistMode.Astro: thrusters.AdjustAstroThrottle(controlObject.forwardBack * astroThrottleSensitivity * Time.deltaTime); shipComputer.UpdateThrottleGauge(thrusters.GetAstroThrottle()); fuelPack.DrainFuel(thrusters.GetAstroFuel() * Time.deltaTime); break; } } // Booster control if (boosters) { Vector3 torque; if (!freeLook) { torque = new Vector3(-controlObject.verticalLook, controlObject.horizontalLook * yawMultiplier, controlObject.roll); } else { torque = new Vector3(0f, 0f, controlObject.roll); } switch (assistMode) { case GameTypes.AssistMode.NoAssist: case GameTypes.AssistMode.Astro: boosters.SetThrottle(controlObject.rightLeft, controlObject.upDown, torque); fuelPack.DrainFuel((Mathf.Abs(controlObject.rightLeft) + Mathf.Abs(controlObject.upDown)) / boosters.efficiency * Time.deltaTime); if (assistMode == GameTypes.AssistMode.Astro) { fuelPack.DrainFuel(1f / thrusters.efficiency * Time.deltaTime); // Idle burn rate } break; case GameTypes.AssistMode.Hover: boosters.SetThrottle(controlObject.rightLeft / 2f, controlObject.upDown / 2f, torque); fuelPack.DrainFuel((Mathf.Abs(controlObject.rightLeft) / 2f + Mathf.Abs(controlObject.upDown)) / 2f / boosters.efficiency * Time.deltaTime); fuelPack.DrainFuel(1f / boosters.efficiency * Time.deltaTime); // Idle burn rate break; } } // Quantum Drive if (thrusters && boosters && quantumDrive) { if (controlObject.quantumJump) { quantumDrive.PickTarget(); } if (assistMode == GameTypes.AssistMode.Quantum && quantumDrive.IsJumping()) { fuelPack.DrainFuel(1f / quantumDrive.efficiency * Time.deltaTime); // Quantum burn rate } } shipComputer.UpdateFuelGauge(fuelPack.GetFuelPercentage()); // Assist Modes if (controlObject.changeAssist) { switch (assistMode) { case GameTypes.AssistMode.NoAssist: ChangeAssistMode(previousAssistMode); break; case GameTypes.AssistMode.Hover: if (boosters && thrusters) { ChangeAssistMode(GameTypes.AssistMode.Astro); } break; case GameTypes.AssistMode.Astro: ChangeAssistMode(GameTypes.AssistMode.Hover); break; } } if (controlObject.toggleAssist && assistMode != GameTypes.AssistMode.Quantum) { if (assistMode != GameTypes.AssistMode.NoAssist) { previousAssistMode = assistMode; ChangeAssistMode(GameTypes.AssistMode.NoAssist); } else { ChangeAssistMode(previousAssistMode); } } // Speedometer shipComputer.UpdateSpeedometer(rb.velocity.magnitude, transform.InverseTransformDirection(rb.velocity).z < -0.5f); // Light if (controlObject.light) { if (lightOn) { shipLight.TogglePower(false); lightOn = false; } else { shipLight.TogglePower(true); lightOn = true; } } } else { TogglePower(false); } } else if (controlObject.interact && !busy) { StartCoroutine("ExitShip"); } // Shield Cells if (controlObject.chargeShieldCell && fuelPack) { fuelPack.ChargeShields(); } // Camera if (controlObject.aim) { if (freeLook) { freeLook = false; } else { freeLook = true; } } if (controlObject.changeCamera && !busy) { PlayerCamera.instance.TogglePerspective(); } if (freeLook) { FreeLook(controlObject.horizontalLook, controlObject.verticalLook); } else { ResetCameraRig(); } }