Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        if (showingWinMessage)
        {
            showingWinMessageTimer -= Time.deltaTime;

            if (showingWinMessageTimer < 0)
            {
                ShowReallyWinMessage();

                if (Input.GetMouseButtonDown(0))
                {
                    WinAndGoToMenu();
                }
            }
        }

        if (reachedMars && !showingWinMessage)
        {
            reachedMarsTimer -= Time.deltaTime;

            if (reachedMarsTimer < 0)
            {
                ShowWinMessage();
            }
        }

        if (outOfTime && showingOutOfTimeMessage)
        {
            if (Input.GetMouseButtonDown(0))
            {
                CleanAndGoToMenu();
            }
        }

        if (showingOutOfTimeMessage)
        {
            outOfTimeMessageTimer -= Time.deltaTime;

            if (outOfTimeMessageTimer < 0)
            {
                ShowReallyOutOfTimeMessage();
            }
        }

        if (boosterActivated)
        {
            boosterTimer -= Time.deltaTime;

            if (boosterTimer < 0)
            {
                boosterActivated = false;
                ship.BoosterActive(false);
            }
        }


        if (dead && showingDeadMessage)
        {
            if (Input.GetMouseButtonDown(0))
            {
                CleanAndGoToMenu();
            }
        }


        if (showingDeadMessage)
        {
            deadMessageTimer -= Time.deltaTime;

            if (deadMessageTimer < 0)
            {
                ShowReallyDeadMessage();
            }
        }


        float gamma = Gamma.GetGamma(currentSpeed);

        CheckGammaValue(1f / gamma);

        oldGamma = 1f / gamma;

        float timePassedThisFrame = Time.deltaTime * gamma;

        if (!reachedMars)
        {
            timeLeft -= timePassedThisFrame;
        }
        gui.UpdateGUI(timeLeft, currentSpeed, fuel, gamma);

        starsNear.UpdateScale(1f / gamma);
        starsMedium.UpdateScale(0.65f / gamma);
        starsFar.UpdateScale(0.5f / gamma);



        mainTimer.UpdateTimer(timeLeft);
        speedCounter.UpdateSpeedCounter(currentSpeed);


        if (timeLeft < 0)
        {
            timeLeft = 0;
            RanOutOfTime();
        }


        if (outOfBounds)
        {
            outOfBoundsTimer += Time.deltaTime;

            if (outOfBoundsTimer > outOfBoundsDeathDuration)
            {
                if (outOfBoundsTop)
                {
                    SpawnAsteroid(3.6f, 80);
                    SpawnAsteroid(4.4f, 80);
                    SpawnAsteroid(5.2f, 80);
                    SpawnAsteroid(6.0f, 80);
                    SpawnAsteroid(6.8f, 80);
                }
                else
                {
                    SpawnAsteroid(-3.6f, 80);
                    SpawnAsteroid(-4.4f, 80);
                    SpawnAsteroid(-5.2f, 80);
                    SpawnAsteroid(-6.0f, 80);
                    SpawnAsteroid(-6.8f, 80);
                }

                outOfBoundsTimer = 0;
            }
        }
        else if (outOfBoundsTimer > 0)
        {
            outOfBoundsTimer = 0;

            oobAudio.StopPlayingOOBSound();
        }


//
//		if (Input.GetKeyDown(KeyCode.Alpha1)){
//			SpawnAlarm(2.7f);
//		}
//
//		if (Input.GetKeyDown(KeyCode.Alpha2)){
//			SpawnAlarm(1.8f);
//		}
//
//		if (Input.GetKeyDown(KeyCode.Alpha3)){
//			SpawnAlarm(0.9f);
//		}
//
//		if (Input.GetKeyDown(KeyCode.Alpha4)){
//			SpawnAlarm(0);
//		}
//
//		if (Input.GetKeyDown(KeyCode.Alpha5)){
//			SpawnAlarm(-0.9f);
//		}
//
//		if (Input.GetKeyDown(KeyCode.Alpha6)){
//			SpawnAlarm(-1.8f);
//		}
//
//		if (Input.GetKeyDown(KeyCode.Alpha7)){
//			SpawnAlarm(-2.7f);
//		}



        if (!showingUrAGoodMessage && !showingDeadMessage && !showingOutOfTimeMessage && !showingWinMessage)
        {
            frontMessage.Active(false);
        }

        outOfBounds = false;
    }