Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        SelectCamera();
        if (Input.GetKeyUp(KeyCode.P))
        {
            orbitHUD.SetActive(true);
        }

        // toggle trajectory prediction
        if (Input.GetKeyUp(KeyCode.T))
        {
            bool pred = GravityEngine.Instance().trajectoryPrediction;
            GravityEngine.Instance().SetTrajectoryPrediction(!pred);
        }

        shipInfo.SetTextInfo(0, Vector3.zero);
        float altitude = shipInfo.GetAltitude();

        // Awkward
        if (doLineScale)
        {
            lineScaler.FindAll();
            if (mainCameraBoom.activeInHierarchy)
            {
                lineScaler.SetZoom(EARTH_LINE_SCALE);
            }
            else
            {
                lineScaler.SetZoom(SHIP_LINE_SCALE);
            }
        }

        if ((altitude < HUD_ENABLE_ALTITUTE) && orbitPredictorOn)
        {
            orbitHUD.SetActive(false);
            // have added an orbit predictor, need to apply correct scale, but LineScaler will not be there until next frame
            doLineScale      = true;
            orbitPredictorOn = false;
        }
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        SelectCamera();
        if (Input.GetKeyUp(KeyCode.Space))
        {
            if (!running)
            {
                // add the ship to the NBody integrator. The ship has a RocketEngine that
                // will start immediatly.
                // GE is already running so that e.g. objects in orbit are moving
                // Test - allow GE to start on launch
                if (!GravityEngine.Instance().evolveAtStart)
                {
                    GravityEngine.Instance().SetEvolve(true);
                }

                GravityEngine.Instance().AddBody(ship);
                running = true;
                multiStage.SetEngine(true);
                launchTime = GravityEngine.Instance().GetPhysicalTime();
                DisplayManager.Instance().DisplayMessage("Ignition");
            }
            else
            {
                DropStage();
            }
        }

        if (Input.GetKeyUp(KeyCode.P))
        {
            orbitHUD.SetActive(true);
        }

        // toggle trajectory prediction
        if (Input.GetKeyUp(KeyCode.T))
        {
            bool pred = GravityEngine.Instance().trajectoryPrediction;
            GravityEngine.Instance().SetTrajectoryPrediction(!pred);
        }

        if (running)
        {
            EngineControls();
            bool  updated  = UpdateThrustAxis();
            float time     = GravityEngine.Instance().GetPhysicalTime() - launchTime;
            float fuel     = multiStage.GetFuel(GravityEngine.Instance().GetPhysicalTime());
            bool  engineOn = multiStage.IsEngineOn();
            if (engineOn)
            {
                if (fuel > 0)
                {
                    if (updated)
                    {
                        GravityEngine.Instance().TrajectoryRestart();
                    }
                }
                else
                {
                    DropStage();
                }
            }

            shipInfo.SetTextInfo(fuel, time, shipController.transform.rotation.eulerAngles);
            float altitude = shipInfo.GetAltitude();
            if ((altitude < 0) && (time > LAUNCH_LOCKOUT))
            {
                // ship has crashed
                DisplayManager.Instance().DisplayMessage("Impact");
                // just remove the ship (so e.g. space station etc keep orbiting)
                GravityEngine.Instance().RemoveBody(ship);
            }
            if (altitude > HUD_ENABLE_ALTITUTE)
            {
                orbitHUD.SetActive(altitude > HUD_ENABLE_ALTITUTE);
                // have added an orbit predictor, need to apply correct scale

                lineScaler.FindAll();
                if (mainCameraBoom.activeInHierarchy)
                {
                    lineScaler.SetZoom(EARTH_LINE_SCALE);
                }
                else
                {
                    lineScaler.SetZoom(SHIP_LINE_SCALE);
                }
            }
        }
    }