Beispiel #1
0
    // Black screen is shown each time Mario dies or finishes level
    public void SetBlackScreen()
    {
        if (blackScreenDelay > 0)
        {
            blackScreenDelay -= Time.deltaTime;

            setBlackScreenExecuted = true;
            marioScript.Stop(false);
            EnemyAbstract_script.GlobalFreezMovement = true;
            if (noTexts)
            {
                return;
            }
            TimerText.text             = " ";
            LivesCountBlackScreen.text = "x " + Mario_script.Lives.ToString();

            if (!gameOver)// Changing level and world count
            {
                if (!firstBlackScreen)
                {
                    int    temp = 0;
                    string levelText;
                    string worldText;

                    if (setCurrent)
                    {
                        levelText = currentScene.Substring(4, 1); // Level calculated from current scene name
                        temp      = int.Parse(levelText);
                        worldText = currentScene.Substring(1, 1);
                        //   setCurrent = false;
                    }
                    else
                    {
                        levelText = previousScene.Substring(4, 1);  // Level calculated from previous scene name
                        temp      = int.Parse(levelText);
                        worldText = previousScene.Substring(1, 1);
                        temp++;
                        if (temp == 5) // Each time Mario finishes level 4, new world is loaded and level count is set to 0.
                        {
                            temp = 1;
                            int temp2 = int.Parse(worldText);
                            temp2++;
                            worldText = temp2.ToString();
                        }
                    }
                    levelText                  = temp.ToString();
                    LevelCountText.text        = worldText + " - " + levelText;
                    LevelCountBlackScreen.text = worldText + " - " + levelText;
                }

                EnableTexts(true);
            }
            else
            {
                if (Mario_script.Lives == 0)
                {
                    GameOverLabel.text    = "Game Over";
                    reloadGame            = true;
                    GameOverLabel.enabled = true;
                    audioScript.SetGameOverAudio();
                    audio.Play();
                }

                else if (timeUp)
                {
                    GameOverLabel.text    = "Time up";
                    GameOverLabel.enabled = true;
                }

                else
                {
                    EnableTexts(true);
                }
            }
        }


        else
        {
            setBlackScreen = false;
            noTexts        = false;
            timeUp         = false;
            gameOver       = false;
            marioScript.Stop(true);
            EnemyAbstract_script.GlobalFreezMovement = false;
            EnableTexts(false);
            GameOverLabel.enabled = false;
            blackScreenDelay      = BlackScreenDelay;
            firstBlackScreen      = false;
            if (reloadGame)
            {
                SceneManager.LoadScene("W1_L1_OVERWORLD");
            }
        }
    }