Update MusicManager.cs

This commit is contained in:
JonatanRek 2020-02-01 23:25:24 +01:00
parent abfb416e35
commit a6034ac8ff
1 changed files with 21 additions and 3 deletions

View File

@ -5,17 +5,35 @@ using UnityEngine;
public class MusicManager : MonoBehaviour public class MusicManager : MonoBehaviour
{ {
public AudioSource musicSource = new AudioSource(); 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 // Start is called before the first frame update
void Start() void Start()
{ {
musicSource.PlayOneShot(Music); musicSource.PlayOneShot(DayMusic);
} }
// Update is called once per frame // Update is called once per frame
void Update() 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;
}
} }
} }