75 lines
1.8 KiB
C#
75 lines
1.8 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using XUI;
|
|
|
|
public class ConPanel : UIBehaviour
|
|
{
|
|
public Common.State PanelState;
|
|
public Transform Page2;
|
|
|
|
public GameObject IPBtn;
|
|
|
|
public List<IPBtn> IPBtns;
|
|
public bool IsInit = false;
|
|
|
|
|
|
public static void Show()
|
|
{
|
|
WorldUIManager.Ins.Cover("UI/ConPanel", false);
|
|
}
|
|
|
|
public void Start()
|
|
{
|
|
for (int i = 0; i < 50; i++)
|
|
{
|
|
IPBtn btn = Instantiate(IPBtn, Page2).GetComponent<IPBtn>();
|
|
btn.gameObject.SetActive(false);
|
|
IPBtns.Add(btn);
|
|
}
|
|
IsInit = true;
|
|
}
|
|
|
|
public void Update()
|
|
{
|
|
if (IsInit && MRNetworkManager.Ins.NeedFresh > 0)
|
|
{
|
|
MRNetworkManager.Ins.NeedFresh--;
|
|
FreshServers();
|
|
}
|
|
}
|
|
|
|
public void OnClickHost()
|
|
{
|
|
WorldUIManager.Ins.Back();
|
|
MRNetworkManager.Ins.CreateAndJoinRoom();
|
|
MRNetworkManager.Ins.networkDiscovery.AdvertiseServer();
|
|
}
|
|
|
|
public void OnClickFindServer()
|
|
{
|
|
MRNetworkManager.Ins.DiscoveredServers.Clear();
|
|
MRNetworkManager.Ins.DiscoveredServersList.Clear();
|
|
MRNetworkManager.Ins.networkDiscovery.StartDiscovery();
|
|
PanelState.StateChange(1);
|
|
}
|
|
|
|
public void FreshServers()
|
|
{
|
|
for (int j = 0; j < IPBtns.Count; j++)
|
|
{
|
|
IPBtns[j].gameObject.SetActive(false);
|
|
}
|
|
for (int i = 0; i < MRNetworkManager.Ins.DiscoveredServersList.Count; i++)
|
|
{
|
|
IPBtns[i].Init(i + 1, MRNetworkManager.Ins.DiscoveredServersList[i]);
|
|
IPBtns[i].gameObject.SetActive(true);
|
|
}
|
|
}
|
|
|
|
public void OnClickServer()
|
|
{
|
|
WorldUIManager.Ins.Back();
|
|
MRNetworkManager.Ins.CreateRoom();
|
|
}
|
|
}
|