// Use this for initialization
 void Start()
 {
     audioSource  = GetComponent <AudioSource>();
     Instance     = GetComponent <AudioSource_script>();
     CurrentScene = SceneManager.GetActiveScene();
     SetBackgroundSong();
     audioSource.Play();
 }
 void Awake()
 {
     if (Instance)
     {
         Destroy(gameObject);
     }
     else
     {
         DontDestroyOnLoad(gameObject);
         Instance = this;
     }
 }
Beispiel #3
0
    // Use this for initialization
    void Start()
    {
        highscoore               = GameObject.Find("Highscore component").GetComponent <Highscore>();
        firstBlackScreen         = true;
        Selector                 = transform.Find("Selector");
        SaveLoad.MarioLevel      = "W1_L1_OVERWORLD";
        SaveLoad.LuigiLevel      = "W1_L1_OVERWORLD";
        SaveLoad.LuigiLives      = Mario_script.LivesConst;
        SaveLoad.LuigiCheckPoint = Vector2.zero;
        SaveLoad.MarioCheckPoint = Vector2.zero;
        IsMario          = true;
        previousScene    = "W1_L1_OVERWORLD";
        Mario            = GameObject.Find("Mario");
        audioScript      = audio.GetComponent <AudioSource_script>();
        currentScene     = "W1_L1_OVERWORLD";
        blackScreenDelay = BlackScreenDelay;
        texts            = GetComponentsInChildren <Text>();
        zeros            = "000000";
        foreach (Text text in texts)
        {
            if (text.name == "Time")
            {
                TimerText = text;
            }
            else if (text.name == "ScooreCount")
            {
                ScooreText = text;
            }
            else if (text.name == "Coin Count")
            {
                CoinCountText = text;
            }
            else if (text.name == "World label on black screen")
            {
                WorldLabelBlackScreen = text;
            }
            else if (text.name == "World level count on black screen")
            {
                LevelCountBlackScreen = text;
            }
            else if (text.name == "World level count")
            {
                LevelCountText = text;
            }
            else if (text.name == "Lives count")
            {
                LivesCountBlackScreen = text;
            }
            else if (text.name == "Game over label")
            {
                GameOverLabel = text;
            }
        }

        spriteRenderer                = transform.Find("Display").Find("Mario image").GetComponent <SpriteRenderer>();
        MarioImage                    = transform.Find("Display").Find("Mario image").GetComponent <SpriteRenderer>();
        LuigiImage                    = transform.Find("Display").Find("Luigi image").GetComponent <SpriteRenderer>();
        LuigiImage.enabled            = false;
        GameOverLabel.enabled         = false;
        spriteRenderer.enabled        = false;
        WorldLabelBlackScreen.enabled = false;
        LivesCountBlackScreen.enabled = false;
        LevelCountBlackScreen.enabled = false;
        GameTimer   = GameTimerValue;
        second      = secondValue;
        marioScript = Mario.GetComponent <Mario_script>();
    }