Browse Source

Added networking to gamemode

master
JoshuaReason 5 years ago
parent
commit
f44e3d96fd
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;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.Networking;
using Multiplayer;
public class GameMode : MonoBehaviour { 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() void Update()
{ {
@ -41,21 +55,21 @@ public class GameMode : MonoBehaviour {
public void PreGameWin() public void PreGameWin()
{ {
ClientManager.Instance.SendMessage(PlayerMsgID.GameWin);
} }
public void PreGameLose() public void PreGameLose()
{ {
ClientManager.Instance.SendMessage(PlayerMsgID.GameOver);
} }
public void GameWin()
public void GameWin(NetworkMessage msg)
{ {
winCanvas.SetActive(true); winCanvas.SetActive(true);
timer.SetActive(false); timer.SetActive(false);
} }
public void GameLose()
public void GameLose(NetworkMessage msg)
{ {
loseCanvas.SetActive(true); loseCanvas.SetActive(true);
timer.SetActive(false); timer.SetActive(false);

Loading…
Cancel
Save