From a6034ac8ffa28af91662fef4a04481ed6953b6bc Mon Sep 17 00:00:00 2001 From: JonatanRek Date: Sat, 1 Feb 2020 23:25:24 +0100 Subject: [PATCH] Update MusicManager.cs --- Assets/Scripts/MusicManager.cs | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/MusicManager.cs b/Assets/Scripts/MusicManager.cs index 8795542..0accd9a 100644 --- a/Assets/Scripts/MusicManager.cs +++ b/Assets/Scripts/MusicManager.cs @@ -5,17 +5,35 @@ using UnityEngine; public class MusicManager : MonoBehaviour { public AudioSource musicSource = new AudioSource(); - public AudioClip Music; + public AudioClip DayMusic; + public AudioClip NightMusic; + private bool night = false; + public GameObject Sun = new GameObject(); // Start is called before the first frame update void Start() { - musicSource.PlayOneShot(Music); + musicSource.PlayOneShot(DayMusic); } // Update is called once per frame void Update() { - + float sunRotationX = Sun.transform.localEulerAngles.x; + sunRotationX = (sunRotationX > 180) ? sunRotationX - 360 : sunRotationX; + + Debug.Log(sunRotationX.ToString()); + if (sunRotationX < 0) + { + musicSource.PlayOneShot(NightMusic); + Debug.Log("It is a Night"); + night = true; + } + else + { + musicSource.PlayOneShot(DayMusic); + Debug.Log("It is a Day"); + night = false; + } } }