Пример #1
0
    public void EnableFuelPackHUD(FuelPack fuelPack)
    {
        fuel.fillAmount    = fuelPack.GetFuelPercentage();
        shields.fillAmount = fuelPack.GetShieldPercentage();
        damage.fillAmount  = shields.fillAmount;
        for (int i = 0; i < fuelPack.GetChargedCells(); i++)
        {
            chargedCells[i].enabled = true;
        }
        for (int i = 0; i < fuelPack.GetAvailableCells(); i++)
        {
            availableCells[i].enabled = true;
        }

        fuelPackHUD.SetActive(true);
    }
Пример #2
0
    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();
        }
    }