diff --git a/Assets/Game1.unity b/Assets/Game1.unity index e8d0232..29b3bc4 100644 Binary files a/Assets/Game1.unity and b/Assets/Game1.unity differ diff --git a/Assets/Game2.unity b/Assets/Game2.unity index 12fc367..377f88d 100644 Binary files a/Assets/Game2.unity and b/Assets/Game2.unity differ diff --git a/Assets/Game3.unity b/Assets/Game3.unity index a26509c..96421d4 100644 Binary files a/Assets/Game3.unity and b/Assets/Game3.unity differ diff --git a/Assets/Game4.unity b/Assets/Game4.unity index 02d9f2c..fee0e1a 100644 Binary files a/Assets/Game4.unity and b/Assets/Game4.unity differ diff --git a/Assets/Game5.unity b/Assets/Game5.unity index 23bdfeb..1b833d6 100644 Binary files a/Assets/Game5.unity and b/Assets/Game5.unity differ diff --git a/Assets/Game6.unity b/Assets/Game6.unity index 2c609ed..ddf84ec 100644 Binary files a/Assets/Game6.unity and b/Assets/Game6.unity differ diff --git a/Assets/MusicHandler.cs b/Assets/MusicHandler.cs index 0d65d3b..2f6b57b 100644 --- a/Assets/MusicHandler.cs +++ b/Assets/MusicHandler.cs @@ -1,8 +1,9 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +using Mirror; -public class MusicHandler : MonoBehaviour +public class MusicHandler : NetworkBehaviour { public int totalNumberOfRocksInLevel = 0; @@ -18,9 +19,10 @@ public class MusicHandler : MonoBehaviour public int musicProgression = 0; bool outroQueued = false; + bool initialized = false; // Start is called before the first frame update - void Start() + public override void OnStartClient() { musicLoops = new AudioSource[musicClipLoops.Length]; @@ -46,11 +48,16 @@ void Start() // queue the first loop playing and looping after the intro musicLoops[0].loop = true; musicLoops[0].PlayScheduled(AudioSettings.dspTime + introMusic.clip.length); + + initialized = true; } // Update is called once per frame void Update() { + if (!initialized) + return; + //Debug.Log("Rocks " + RockSphere.currentRocks + " total " + RockSphere.totalRocks + " destoyed " + RockSphere.destroyedRocks); // are we done shooting rocks and have not started the outro music diff --git a/Assets/NetworkManagerRocket.cs b/Assets/NetworkManagerRocket.cs index 4d40087..5042e72 100644 --- a/Assets/NetworkManagerRocket.cs +++ b/Assets/NetworkManagerRocket.cs @@ -55,9 +55,11 @@ void NextLevel() level = 1; } + MusicHandler mh = FindObjectOfType(); + // wait for outro music + last music loop + 5 seconds before switching to the next level - Invoke("SwitchScenes", Camera.main.transform.gameObject.GetComponent().outroMusicClip.length + - Camera.main.transform.gameObject.GetComponent().musicClipLoops[Camera.main.transform.gameObject.GetComponent().musicClipLoops.Length - 1].length + Invoke("SwitchScenes", mh.outroMusicClip.length + + mh.musicClipLoops[mh.musicClipLoops.Length - 1].length + 5); } diff --git a/Assets/RockSphere.cs b/Assets/RockSphere.cs index fe6998f..4420a7b 100644 --- a/Assets/RockSphere.cs +++ b/Assets/RockSphere.cs @@ -72,7 +72,7 @@ public override void OnStartServer() totalRocks++; currentRocks++; - Debug.Log("current rocks " + currentRocks + " Rocks " + currentRocks + " total " + totalRocks + " destoyed " + destroyedRocks); + Debug.Log("OnStartServer current rocks " + currentRocks + " Rocks " + currentRocks + " total " + totalRocks + " destoyed " + destroyedRocks); rpcSetRockStats(currentRocks, totalRocks, destroyedRocks); } @@ -97,12 +97,18 @@ void OnTriggerEnter(Collider other) GameObject explosion = Instantiate(explosionPrefab, rock.transform.position, Quaternion.identity) as GameObject; NetworkServer.Spawn(explosion); - destroyed = true; - NetworkServer.Destroy(transform.gameObject); - destroyedRocks++; currentRocks--; + Debug.Log("OntriggerEnter Rocks " + currentRocks + " total " + totalRocks + " destoyed " + destroyedRocks); + + // let all the clients know the current rock counts for music + // IMPORTANT!!!!, this must be called before the detroy or the rpc will never go out. + rpcSetRockStats(currentRocks, totalRocks, destroyedRocks); + + destroyed = true; + NetworkServer.Destroy(transform.gameObject); + if (rockSpherePrefab) { for (int i = 0; i < pieces; i++) @@ -111,11 +117,6 @@ void OnTriggerEnter(Collider other) NetworkServer.Spawn(newRock); } } - - Debug.Log("Rocks " + currentRocks + " total " + totalRocks + " destoyed " + destroyedRocks); - - // let all the clients know the current rock counts for music - rpcSetRockStats(currentRocks, totalRocks, destroyedRocks); } } diff --git a/ProjectSettings/GraphicsSettings.asset b/ProjectSettings/GraphicsSettings.asset index 9861984..4794c37 100644 Binary files a/ProjectSettings/GraphicsSettings.asset and b/ProjectSettings/GraphicsSettings.asset differ