Add basic background music behavior
This commit is contained in:
parent
3bc7c9c7ee
commit
03f1bbc599
7 changed files with 395 additions and 11 deletions
|
@ -30,6 +30,9 @@ public sealed class GameSystem : MonoBehaviour
|
|||
float slowScale = 0.5f; //Default scale for slow mode
|
||||
private float fixedDeltaTime;
|
||||
|
||||
//Sound
|
||||
BGMusic BGmusic=null; //Background Music
|
||||
|
||||
//TODO : Effect on gold change
|
||||
//Money
|
||||
private int gold;
|
||||
|
@ -101,6 +104,15 @@ public sealed class GameSystem : MonoBehaviour
|
|||
{
|
||||
// Make a copy of the fixedDeltaTime, it defaults to 0.02f, but it can be changed in the editor
|
||||
this.fixedDeltaTime = Time.fixedDeltaTime;
|
||||
|
||||
//Get BG music
|
||||
GameObject musicObj = GameObject.Find("/GameSystem/AudioManager/BackgroundMusic");
|
||||
if(musicObj != null)
|
||||
BGmusic = musicObj.GetComponent<BGMusic>();
|
||||
if(BGmusic is null)
|
||||
Debug.LogWarning("No background music found");
|
||||
|
||||
//Get UI Service Timer
|
||||
GameObject timerObj = GameObject.Find("/UI/Canvas/ServiceTimer");
|
||||
if(timerObj is null)
|
||||
{
|
||||
|
@ -108,11 +120,10 @@ public sealed class GameSystem : MonoBehaviour
|
|||
UIServiceTimer=null;
|
||||
}
|
||||
else
|
||||
{
|
||||
UIServiceTimer=timerObj.GetComponent<UITimer>();
|
||||
}
|
||||
|
||||
if(ClientManager.Instance.ready && StockManager.Instance.ready)
|
||||
//Check that all systems are ready
|
||||
if(ClientManager.Instance.ready && StockManager.Instance.ready && EventManager.Instance.ready)
|
||||
{
|
||||
ready=true;
|
||||
Debug.Log("All GameSystems are ready");
|
||||
|
@ -151,7 +162,10 @@ public sealed class GameSystem : MonoBehaviour
|
|||
toggleSlowMode(2.0f);
|
||||
Debug.Log("Time scale: "+Time.timeScale);
|
||||
}
|
||||
// Debug.Log("Service timer : "+(int)serviceTimer);
|
||||
|
||||
//Basic background music modification
|
||||
if(ClientManager.Instance.clientList.Count>2 && BGmusic.intensity<1)
|
||||
BGmusic.changeIntensity(1);
|
||||
}
|
||||
|
||||
// simple Singleton implementation
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue