/*
     * private void Awake()
     * {
     *  if(instance == null)
     *      instance = this;
     *  else if(instance != this)
     *      Destroy(gameObject);
     * }
     */

    void Start()
    {
        if (ToEndGame)
        {
            EndGame(0);
        }
        if (RestartGame)
        {
            Restart();
        }

        Initialize();
        fadeScript = GetComponent <FadeOutManager>();

        AudioManager am = AudioManager.instance;

        am.Play("HUBMusic");
        Sound s = Array.Find(am.sounds, Sound => Sound.name == "HUBMusic");

        s.source.time = UnityEngine.Random.Range(0, s.clip.length);

        am.Play("HUBAmbience");

        UnityEngine.SceneManagement.SceneManager.sceneLoaded += OnLevelLoaded;

        if (IsFirstHubRun)
        {
            IsFirstHubRun = !IsFirstHubRun;
            GameObject.Find("HubTutorial").transform.GetChild(0).GetComponent <Tutorial>().Run(); // BECAUSE UNITY IS AWESOME, AND GAMEOBJECT.FIND("HUB_TUTORIAL").GETCOMPONENT<TUTORIAL>() DOESN'T WORK! YAAY! Not even mad.
        }

        PracticeSongs = Practice;
        GigSongs      = Gig;
    }
    IEnumerator Transition(string sceneName)
    {
        FadeOutManager fadeOut = FindObjectOfType <FadeOutManager>();

        fadeOut.FadeInSeconds = FadeInSeconds;
        Time.timeScale        = 1;

        fadeOut.FadeOut(false);

        yield return(new WaitForSeconds(LoadDelay));

        UnityEngine.SceneManagement.SceneManager.LoadScene(sceneName);
    }
Esempio n. 3
0
    void Awake()
    {
        if (instance != null && instance != this)
        {
            Destroy(gameObject);
            return;
        }
        else
        {
            instance = this;
        }

        DontDestroyOnLoad(gameObject);
    }
 public void LoadSleep(float energy)
 {
     fadeScript = FindObjectOfType <FadeOutManager>();
     fadeScript.FadeOut(true, ContinueSleep);
 }