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.
 
 
 

55 lines
1.2 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using Multiplayer;
using UnityEngine.UI;
public class LobbyUIController : MonoBehaviour {
public Button StartGame;
private float lastTime;
private void Start()
{
}
private void OnEnable()
{
Multiplayer.ClientManager.Instance.Client.RegisterHandler(LoginMsgID.QueryGameRunning, isGameRunning);
}
private void OnDisable()
{
ClientManager.Instance.Client.UnregisterHandler(LoginMsgID.QueryGameRunning);
}
public void Update()
{
if (Time.time - lastTime > 1)
{
ClientManager.Instance.SendMessage(LoginMsgID.QueryGameRunning);
lastTime = Time.time;
}
}
public void OnClickStartGame()
{
Multiplayer.ClientManager.Instance.SendMessage(Multiplayer.PlayerMsgID.GameStart, new Multiplayer.PlayerMsg(Multiplayer.ClientManager.Instance.ID));
}
public void isGameRunning(NetworkMessage msg)
{
BoolMsg boolMsg;
if (!Multiplayer.Utility.ReadMessage<BoolMsg>(msg, out boolMsg))
return;
StartGame.interactable = !boolMsg.boolean;
}
}