示例#1
0
    private void Start()
    {
        // For debuggin and testing (normally game starts at scene START)
        if (SceneManager.GetActiveScene().buildIndex == INGAME)
        {
            GetInGameVariables();
            pauseScreen.UnPause();
            gameOverSeq.enabled = false;
            music = GameObject.Find("Background Music").GetComponent <BackgroundMusic>();
            music.Init();
            music.StartVariatedLoop();
            showIntro        = true;
            worldMan.enabled = false;
            introSeq.enabled = true;
        }

        // Make sure this class can only be instantiated once
        if (instance == null)
        {
            SceneManager.sceneLoaded += OnSceneLoaded;
            DontDestroyOnLoad(gameObject);
            instance = this;
        }
        else
        {
            Destroy(gameObject);
        }

        //print(SceneManager.GetActiveScene().name);

        if (SceneManager.GetActiveScene().name == scenePaths[START])
        {
            startMenu = GameObject.Find("Start Menu").GetComponent <StartMenu>();
            music     = GameObject.Find("Background Music").GetComponent <BackgroundMusic>();
            music.Init();
            music.StartNormalLoop();
            startMenu.StartMenuInit();
            showIntro = true;
            diffLvl   = 1; // Set default difficult level to 1 (normal)
            //print("In active scene start in gamecontroller start");
        }
    }
示例#2
0
 /* Sets up the INGAME scene. This function is called by SceneManager when a scene
  * has finished loading. */
 private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
 {
     print("In game controller scene loaded");
     if (scene.name == scenePaths[INGAME])
     {
         GetInGameVariables();
         pauseScreen.UnPause();
         gameOverSeq.enabled = false;
         music = GameObject.Find("Background Music").GetComponent <BackgroundMusic>();
         music.Init();
         music.StartVariatedLoop();
         if (showIntro)
         {
             worldMan.enabled = false;
             introSeq.enabled = true;
         }
         else
         {
             worldMan.enabled = true;
             introSeq.enabled = false;
         }
     }
 }