160 lines
5.0 KiB
C#
160 lines
5.0 KiB
C#
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using Sirenix.OdinInspector;
|
||
using TMPro;
|
||
using UnityEditor;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
|
||
public class UI_MainTitlePanel : BasePanel
|
||
{
|
||
//public GameObject upExamBtn;
|
||
//public GameObject submitBtn;
|
||
//public GameObject timeInfo;
|
||
//public GameObject modelInfo;
|
||
//public GameObject useNameInfo;
|
||
public TextMeshProUGUI modelText;
|
||
public Timers timer;
|
||
internal void Init()
|
||
{
|
||
SwitchTitleImg();
|
||
//SwitchMode();
|
||
SwitchUserName();
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 显示
|
||
/// </summary>
|
||
public override void ShowMe()
|
||
{
|
||
GameManager.EventMgr.AddEventListener(Enum_EventType.SwitchMode, SwitchMode);
|
||
GameManager.EventMgr.AddEventListener(Enum_EventType.InitializationUI, InitializationUI);
|
||
}
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// 隐藏
|
||
/// </summary>
|
||
public override void HideMe()
|
||
{
|
||
GameManager.EventMgr.RemoveEventListener(Enum_EventType.SwitchMode, SwitchMode);
|
||
GameManager.EventMgr.RemoveEventListener(Enum_EventType.InitializationUI, InitializationUI);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 切换模式
|
||
/// </summary>
|
||
private void SwitchMode()
|
||
{
|
||
string mode = "";
|
||
switch (RunModelMgr.Instance.ModeType)
|
||
{
|
||
case E_ModeType.None:
|
||
mode = string.Empty;
|
||
break;
|
||
case E_ModeType.Study:
|
||
mode = "学习模式";
|
||
break;
|
||
case E_ModeType.Practice:
|
||
mode = "练习模式";
|
||
break;
|
||
case E_ModeType.Exam:
|
||
mode = "考试模式";
|
||
break;
|
||
}
|
||
///模式显示父物体
|
||
//GetControl<Image>("modelText").gameObject.SetActive(mode != "");//HQB 20250526
|
||
//GetControl<Image>("userName").gameObject.SetActive(mode != string.Empty && mode != "学习模式");
|
||
///模式显示text
|
||
|
||
modelText.text = mode;
|
||
|
||
}
|
||
public void InitializationUI()
|
||
{
|
||
//GetControl<Button>("upExamBtn").gameObject.SetActive(RunModelMgr.Instance.ModeType == E_ModeType.Exam);
|
||
//GetControl<Button>("submitBtn").gameObject.SetActive(RunModelMgr.Instance.ModeType == E_ModeType.Practice);
|
||
//GetControl<Image>("timeText").gameObject.SetActive(RunModelMgr.Instance.ModeType == E_ModeType.Exam);
|
||
if (GameManager.RunModelMgr.ModeType == E_ModeType.Exam)
|
||
{
|
||
timer.SetTime(GameManager.NetMgr.totalTime, modelText, (s) =>
|
||
{
|
||
GameManager.EventMgr.EventTrigger(Enum_EventType.Submit);
|
||
});
|
||
}
|
||
}
|
||
|
||
public void ResetByModeType()
|
||
{
|
||
GetControl<Button>("upExamBtn").gameObject.SetActive(false);
|
||
GetControl<Button>("submitBtn").gameObject.SetActive(false);
|
||
//GetControl<Button>("timeText").gameObject.SetActive(false);
|
||
|
||
}
|
||
|
||
//高粱不用
|
||
private void SwitchTitleImg()
|
||
{
|
||
//var systemInfo = GameManager.DataMgr.GetSystemInfo(GameManager.Instance.systemId);
|
||
//GetControl<Image>("TopBgImg").sprite =
|
||
// GameManager.ResourcesMgr.Load<Sprite>(Const.UI_MainTitlePanel + systemInfo.titleName);
|
||
//Debug.Log("加载top图片:" + Const.UI_MainTitlePanel + systemInfo.titleName);
|
||
}
|
||
|
||
private void SwitchUserName()
|
||
{
|
||
GetControl<TextMeshProUGUI>("userNameText (TMP)").text = $"{GameManager.NetMgr.userName}";
|
||
}
|
||
|
||
/// <summary>
|
||
/// 按钮点击
|
||
/// </summary>
|
||
/// <param name="btnName"></param>
|
||
protected override void OnClick(string btnName)
|
||
{
|
||
switch (btnName)
|
||
{
|
||
//TODO 退出提示框
|
||
case "closeBtn":
|
||
GameManager.UIMgr.ShowPanel<UI_MessagePanel>(E_UI_Layer.System,
|
||
(panel) =>
|
||
{
|
||
panel.Init("提示", "确定退出应用吗?", E_MessageType.Error,
|
||
() =>
|
||
{
|
||
print("退出应用");
|
||
#if !UNITY_EDITOR
|
||
Application.Quit(0);
|
||
#endif
|
||
},
|
||
() =>
|
||
{
|
||
Debug.Log("取消");
|
||
});
|
||
});
|
||
break;
|
||
case "upExamBtn":
|
||
print("交卷");
|
||
//GameManager.EventMgr.EventTrigger(Enum_EventType.UpExam);
|
||
GameManager.EventMgr.EventTrigger(Enum_EventType.Submit);
|
||
break;
|
||
case "submitBtn":
|
||
GameManager.UIMgr.ShowPanel<UI_PracticeCompletedPanel>(E_UI_Layer.Mid, (p) =>
|
||
{
|
||
p.Init();
|
||
});
|
||
print("提交");
|
||
GameManager.EventMgr.EventTrigger(Enum_EventType.Submit);
|
||
break;
|
||
}
|
||
}
|
||
private void OnApplicationQuit()
|
||
{
|
||
#if !UNITY_EDITOR
|
||
System.Diagnostics.Process.GetCurrentProcess().Kill();
|
||
#endif
|
||
}
|
||
} |