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.
68 lines
2.2 KiB
68 lines
2.2 KiB
3 years ago
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
using AX.MessageSystem;
|
||
|
using AX.NetworkSystem;
|
||
|
|
||
|
public class AppModeManager : MonoBehaviour {
|
||
|
|
||
|
private void Start()
|
||
|
{
|
||
|
transform.Find("Sandmodebtn").GetComponent<Toggle>().onValueChanged.AddListener(SandModeBtnClick);
|
||
|
transform.Find("Pathmodebtn").GetComponent<Toggle>().onValueChanged.AddListener(PathModeBtnClick);
|
||
|
transform.parent.Find("LoadSceneBtn").GetComponent<Button>().onClick.AddListener(LoadBtnClick);
|
||
|
MySceneManager.BackToLastSceneEvent += BackToLastSceneEvent;
|
||
|
ExamInfoHelpClass.applicationMode = ExamInfoHelpClass.ApplicationMode.SANDTABLE;
|
||
|
}
|
||
|
|
||
|
private void BackToLastSceneEvent(MyEventArgs args)
|
||
|
{
|
||
|
MySceneManager.BackToLastSceneEvent -= BackToLastSceneEvent;
|
||
|
|
||
|
if (args.sourceScene == "AppMode" && args.destinateScene == "Login")
|
||
|
{
|
||
|
// HACK: 因为代码抽风,导致这个方法有时会执行两次
|
||
|
// 特在此处做一个特殊处理
|
||
|
|
||
|
var loginSetting = GameSetting.LoginSetting;
|
||
|
|
||
|
if (!loginSetting.Contains(NetworkManager.Default.RemoteEndPoint))
|
||
|
{
|
||
|
var ip = default(string);
|
||
|
var port = default(short);
|
||
|
|
||
|
GameSetting.LoginSetting.GetLoginAddress(out ip, out port);
|
||
|
|
||
|
NetworkManager.DestroySession(NetworkManager.Default);
|
||
|
NetworkManager.CreateDefaultSession(ip, port);
|
||
|
NetworkManager.Default.Start();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
private void LoadBtnClick()
|
||
|
{
|
||
|
if(ExamInfoHelpClass.applicationMode == ExamInfoHelpClass.ApplicationMode.NONE)
|
||
|
{
|
||
|
MessageDispatcher.SendMessage("Operatinghints", (object)"请选择模式!");
|
||
|
return;
|
||
|
}
|
||
|
MySceneManager.MyLoadScene("ModeSelect");
|
||
|
}
|
||
|
|
||
|
private void SandModeBtnClick(bool value)
|
||
|
{
|
||
|
if (value)
|
||
|
{
|
||
|
ExamInfoHelpClass.applicationMode = ExamInfoHelpClass.ApplicationMode.SANDTABLE;
|
||
|
}
|
||
|
}
|
||
|
private void PathModeBtnClick(bool value)
|
||
|
{
|
||
|
if (value)
|
||
|
{
|
||
|
ExamInfoHelpClass.applicationMode = ExamInfoHelpClass.ApplicationMode.PATHFINDING;
|
||
|
}
|
||
|
}
|
||
|
}
|