You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

71 lines
1.5 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using Multiplayer;
public class GameMode : MonoBehaviour {
public Recipe recipe;
public CharacterMovement charMove;
public Timer timer;
public GameObject winCanvas;
public GameObject loseCanvas;
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()
{
//CheckValues();
if (charMove.CheckNearby())
{
if (recipe.CheckVictory())
{
PreGameWin();
}
}
}
public void EndGame()
{
Multiplayer.ClientManager.Instance.SendMessage(Multiplayer.PlayerMsgID.Lobby);
}
public void PreGameWin()
{
ClientManager.Instance.SendMessage(PlayerMsgID.GameWin);
}
public void PreGameLose()
{
ClientManager.Instance.SendMessage(PlayerMsgID.GameOver);
}
public void GameWin(NetworkMessage msg)
{
winCanvas.SetActive(true);
timer.enabled = false;
}
public void GameLose(NetworkMessage msg)
{
loseCanvas.SetActive(true);
timer.enabled = false;
}
}