MB 5 years ago
parent
commit
d6ef5eb620
1 changed files with 18 additions and 4 deletions
  1. +18
    -4
      Assets/Scipts/GameMode.cs

+ 18
- 4
Assets/Scipts/GameMode.cs View File

@ -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()
{
@ -44,21 +58,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.enabled = false;
}
public void GameLose()
public void GameLose(NetworkMessage msg)
{
loseCanvas.SetActive(true);
timer.enabled = false;

Loading…
Cancel
Save