private void Awake() { Instance = this; scoreText.text = score.ToString(); playerMotor = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMotor>(); cameraMotor = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraMotor>(); compMotor = GameObject.FindGameObjectWithTag("Companion").GetComponent <CompanionMotor>(); isEndless = SceneController.getIsEndless(); if (Settings.isMusicOn.Value) { AudioSource[] audios = FindObjectsOfType <AudioSource>(); foreach (AudioSource audio in audios) { if (audio.CompareTag("Music")) { musicPlayer = audio; } } StartCoroutine(AudioController.FadeOut(musicPlayer, 0.5f)); } if (!isEndless) { startCutscene.Begin(); } else { informationText.text = "Touch to start"; } }
/* This method is run before the first frame update, it intialises all necessary variables */ private void Awake() { Instance = this; pollutionSlide.value = TrashSpawner.garbageMultiplier; playerMotor = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMotor>(); cameraMotor = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraMotor>(); compMotor = GameObject.FindGameObjectWithTag("Companion").GetComponent <CompanionMotor>(); scoreText.text = score.ToString("0"); garbageText.text = garbage.ToString(); isEndless = SceneController.getIsEndless(); // Initialise music if (Settings.isMusicOn.Value) { AudioSource[] audios = FindObjectsOfType <AudioSource>(); foreach (AudioSource audio in audios) { if (audio.CompareTag("Music")) { musicPlayer = audio; } } StartCoroutine(AudioController.FadeOut(musicPlayer, 0.5f)); } heart1.gameObject.SetActive(true); heart2.gameObject.SetActive(true); heart3.gameObject.SetActive(true); // If its endless you skip all cutscenes if (!isEndless) { startCutscene.Begin(); } }