- LocalizationManager: 新增翻译表(SetFormatted/SetDuration/LocalizeOperateMsg) - LoginPanel: InputField placeholder本地化、字体颜色保持 - HistoryPanel: 用时数据本地化、placeholder本地化 - RecordDetailPanel: 操作详情消息本地化(LanguageChanged重建) - AppraiseWindowBase: 评价等级本地化、操作消息重建 - EditorAppraiser: 所有评估消息改用InjectOperateMsgLocalized - StudentOperateRecorder: 新增InjectOperateMsgLocalized方法 - LocalizationLanguageTestBar: 单例模式、ScreenSpaceOverlay筛选 - 字体切换时保留颜色和verticalOverflow
122 lines
3.4 KiB
Plaintext
122 lines
3.4 KiB
Plaintext
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using DevelopEngine;
|
|
using System;
|
|
using ETModel;
|
|
using XFramework;
|
|
|
|
/// <summary>
|
|
/// 空场景游戏入口类 持久化存在
|
|
/// </summary>
|
|
public class GameMain : MonoSingleton<GameMain>
|
|
{
|
|
public RunState runState = RunState.student;
|
|
|
|
public bool isTest;//测试模式 可跳过某些逻辑 便于测试
|
|
|
|
//记录UI 控制器
|
|
public UIManager UIManager;//当前显示的UI控制器
|
|
|
|
//当前在线的学员
|
|
public Dictionary<string,OnlineStudent> onlineStudents = new Dictionary<string, OnlineStudent>();
|
|
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
Application.runInBackground = true;
|
|
GameObject.DontDestroyOnLoad(this.gameObject);
|
|
if (runState == RunState.teacher)
|
|
{
|
|
DBManager.Instance.InitDBManager(Application.streamingAssetsPath + "/Config/VirtualRepairSql.db");
|
|
TcpServer tcpServer = new TcpServer();
|
|
string thisIP = NetHelper.GetAddressIPV4();
|
|
tcpServer.Start(thisIP, 8087);
|
|
SceneSystem.Instance.SetScene(new TeacherScene());
|
|
TCPManager.Instance.InitNetWork(tcpServer);
|
|
TCPManager.Instance.RegisterConnCloseEvent(StudentConnChanged);
|
|
EventCenter.Instance.AddEventListener<string, string>("StudentLoginOn", StudntLoginOn);
|
|
EventCenter.Instance.AddEventListener<string>("StudentQuit", StudentQuit);
|
|
}
|
|
else
|
|
{
|
|
TCPManager.Instance.InitNetWork(new TcpClient(ClientConnectChanged));
|
|
SceneSystem.Instance.SetScene(new StudentLoginScene(LoadSceneType.unLogin));
|
|
}
|
|
//dBManager.CreatTable("AssetBundle", new string[] { "Name", "Type", "FilePath", "ParentName" }, new string[] {"TEXT", "INTEGER", "TEXT", "TEXT" });
|
|
}
|
|
|
|
public bool CheckUserIsLoginon(string ip)
|
|
{
|
|
foreach (var item in onlineStudents)
|
|
{
|
|
if (item.Value.user == ip)
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
//客户端登录成功
|
|
private void StudntLoginOn(string ip, string user)
|
|
{
|
|
if (!onlineStudents.ContainsKey(ip))
|
|
{
|
|
onlineStudents.Add(ip, new OnlineStudent());
|
|
}
|
|
onlineStudents[ip].user = user;
|
|
onlineStudents[ip].ip = ip;
|
|
|
|
}
|
|
/// <summary>
|
|
/// 学员端退出登录
|
|
/// </summary>
|
|
private void StudentQuit(string ip)
|
|
{
|
|
if (onlineStudents.ContainsKey(ip))
|
|
{
|
|
onlineStudents.Remove(ip);
|
|
}
|
|
}
|
|
|
|
|
|
//客户端网络连接状态变化
|
|
private void StudentConnChanged(string IP,bool value)
|
|
{
|
|
if (!value)//断开连接时
|
|
{
|
|
onlineStudents.Remove(IP);
|
|
EventCenter.Instance.EventTrigger<string>("StudentQuit",IP);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
private void Update()
|
|
{
|
|
TCPManager.Instance.ExtractingMsg();
|
|
}
|
|
|
|
private void ClientConnectChanged(bool a)
|
|
{
|
|
if (!a)//断开链接时 返回初始场景
|
|
{
|
|
SceneSystem.Instance.SetScene(new StudentLoginScene(LoadSceneType.unLogin));
|
|
}
|
|
else
|
|
{
|
|
//EventCenter.Instance.EventTrigger<>
|
|
}
|
|
}
|
|
|
|
//程序退出时执行
|
|
private void OnApplicationQuit()
|
|
{
|
|
Debug.Log("Quit");
|
|
TCPManager.Instance?.Close();
|
|
DBManager.Instance?.CloseSqlConnectionDB();
|
|
}
|
|
|
|
|
|
}
|