diff --git a/Assets/Scipts/GameMode.cs b/Assets/Scipts/GameMode.cs index e54a580..faea91d 100644 --- a/Assets/Scipts/GameMode.cs +++ b/Assets/Scipts/GameMode.cs @@ -1,6 +1,8 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +using UnityEngine.Networking; +using Multiplayer; public class GameMode : MonoBehaviour { @@ -24,6 +26,18 @@ public class GameMode : MonoBehaviour { } } + private void OnEnable() + { + ClientManager.Instance.Client.RegisterHandler(PlayerMsgID.GameWin,GameWin); + ClientManager.Instance.Client.RegisterHandler(PlayerMsgID.GameOver, GameLose); + } + + private void OnDisable() + { + ClientManager.Instance.Client.UnregisterHandler(PlayerMsgID.GameWin); + ClientManager.Instance.Client.UnregisterHandler(PlayerMsgID.GameOver); + } + void Update() { @@ -41,21 +55,21 @@ public class GameMode : MonoBehaviour { public void PreGameWin() { - + ClientManager.Instance.SendMessage(PlayerMsgID.GameWin); } public void PreGameLose() { - + ClientManager.Instance.SendMessage(PlayerMsgID.GameOver); } - public void GameWin() + public void GameWin(NetworkMessage msg) { winCanvas.SetActive(true); timer.SetActive(false); } - public void GameLose() + public void GameLose(NetworkMessage msg) { loseCanvas.SetActive(true); timer.SetActive(false);