187 lines
6.4 KiB
C#
187 lines
6.4 KiB
C#
using Adam;
|
||
using Newtonsoft.Json;
|
||
using System.Threading.Tasks;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
using TMPro;
|
||
//============================================================
|
||
//支持中文,文件使用UTF-8编码
|
||
//@author #AUTHOR#
|
||
//@create #CREATEDATE#
|
||
//@company #COMPANY#
|
||
//
|
||
//@description:总控
|
||
//============================================================
|
||
|
||
public class UIManager : MonoSingleton<UIManager>
|
||
{
|
||
public ToolsItemManager toolsItemManager;
|
||
public MobileTerminalController mobileTerminalController;
|
||
public AssignmentController assignmentController;
|
||
public BottomController bottomCotroller;
|
||
public JobCardController jobCardController;
|
||
public ExitCheckController exitCheckController;
|
||
public ToolModelManager toolModelManager;
|
||
public LoginController loginController;
|
||
public Reconnection Reconnection;
|
||
public GoToSceneController goToScene;
|
||
//public UIS uis;
|
||
public Canvas canvas;
|
||
public Button exitBtn;
|
||
public Button overTaskBtn;
|
||
public Button backToToolBtn;
|
||
public TMP_Text threeDTip;
|
||
public Timers timers;
|
||
public GanTanHao ganTanHao;
|
||
public bool isGongZuoZhengBox = false;
|
||
|
||
public MessageData messageData = new MessageData();
|
||
public NewSceneDataRoot newSceneDataRoot = new NewSceneDataRoot();
|
||
|
||
|
||
public async void Init(int examID, string jsonFileName)
|
||
{
|
||
string examUrl = WebIPAdress.Instance.dicAdresses["试卷信息"];
|
||
FractionManager.Instance.examData = await AsyncWebReq.Get<ExamRoot>($"{examUrl}{examID}");
|
||
|
||
//FractionManager.Instance.examData = JsonConvert.DeserializeObject<ExamRoot>(examData);
|
||
FractionManager.Instance.GetExamData();
|
||
|
||
if (string.IsNullOrEmpty(FractionManager.Instance.examData.data.sceneScriptId))
|
||
{
|
||
string json = FileUtil.ReadFromLocal($"{jsonFileName}.json");
|
||
messageData = JsonConvert.DeserializeObject<MessageData>(json);
|
||
}
|
||
else
|
||
{
|
||
string sceneInfoUrl = WebIPAdress.Instance.dicAdresses["场景信息"];
|
||
newSceneDataRoot = await AsyncWebReq.Get<NewSceneDataRoot>($"{sceneInfoUrl}{FractionManager.Instance.examData.data.sceneScriptId}");
|
||
messageData = JsonConvert.DeserializeObject<MessageData>(newSceneDataRoot.data.scriptBase);
|
||
}
|
||
assignmentController.Init();
|
||
FractionManager.Instance.OnInit();
|
||
ExamusersController.Instance.Init();
|
||
mobileTerminalController.OnInit();
|
||
}
|
||
// Use this for initialization
|
||
private void Start()
|
||
{
|
||
exitBtn.onClick.AddListener(() =>
|
||
{
|
||
if (exitCheckController.num_click != 2)
|
||
{
|
||
//if (GlobalFlag.isRecord == "1")
|
||
//{
|
||
// uis.OnStopRecorad();
|
||
//}
|
||
exitCheckController.ResetPlane();
|
||
exitCheckController.ExitCheckPanel.SetActive(true);
|
||
}
|
||
else
|
||
{
|
||
//if (GlobalFlag.isRecord == "1")
|
||
//{
|
||
// uis.OnStopRecorad();
|
||
//}
|
||
Application.Quit();
|
||
}
|
||
bottomCotroller.functionBtn.isOn = false;
|
||
bottomCotroller.systemBtn.isOn = false;
|
||
});
|
||
overTaskBtn.onClick.AddListener(() =>
|
||
{
|
||
if (exitCheckController.num_click != 2)
|
||
{
|
||
//if (GlobalFlag.isRecord == "1")
|
||
//{
|
||
// uis.OnStopRecorad();
|
||
//}
|
||
exitCheckController.ResetPlane();
|
||
exitCheckController.ExitCheckPanel.SetActive(true);
|
||
}
|
||
else
|
||
{
|
||
//if (GlobalFlag.isRecord == "1")
|
||
//{
|
||
// uis.OnStopRecorad();
|
||
//}
|
||
Application.Quit();
|
||
}
|
||
bottomCotroller.functionBtn.isOn = false;
|
||
bottomCotroller.systemBtn.isOn = false;
|
||
});
|
||
|
||
overTaskBtn.gameObject.SetActive(false);
|
||
exitBtn.gameObject.SetActive(false);
|
||
backToToolBtn.onClick.AddListener(() =>
|
||
{
|
||
bottomCotroller.functionBtn.isOn = false;
|
||
bottomCotroller.systemBtn.isOn = false;
|
||
toolsItemManager.recoverEvent.RemoveAllListeners();
|
||
toolsItemManager.ResetState(true);
|
||
if (toolsItemManager.recoverBtn.gameObject.activeSelf)
|
||
{
|
||
toolsItemManager.recoverBtn.onClick?.Invoke();
|
||
}
|
||
backToToolBtn.gameObject.SetActive(false);
|
||
bottomCotroller.updownLadder.isOn = false;
|
||
bottomCotroller.updownLadder.gameObject.SetActive(false);
|
||
//if (GlobalFlag.isRecord == "1")
|
||
//{
|
||
// uis.OnStopRecorad();
|
||
//}
|
||
BackToTool();
|
||
});
|
||
backToToolBtn.gameObject.SetActive(false);
|
||
DontDestroyOnLoad(this);
|
||
}
|
||
|
||
private async void BackToTool()
|
||
{
|
||
SceneLoad.Instance.SceneChange("工具间场景");
|
||
await Task.Delay(1000);
|
||
toolModelManager.GetAllToolModels();
|
||
for (int i = 0; i < toolsItemManager.toolItems.Count; i++)
|
||
{
|
||
for (int j = 0; j < toolModelManager.toolModelClicks.Length; j++)
|
||
{
|
||
if (toolsItemManager.toolItems[i].originPos == toolModelManager.toolModelClicks[j].transform.localPosition)
|
||
{
|
||
Destroy(toolModelManager.toolModelClicks[j].gameObject);
|
||
}
|
||
}
|
||
}
|
||
FractionManager.Instance.testPen.Clear();
|
||
|
||
}
|
||
|
||
public void SetThreeDTip(GameObject obj, Vector3 mousePos)
|
||
{
|
||
if (obj == null)
|
||
{
|
||
threeDTip.transform.parent.gameObject.SetActive(false);
|
||
}
|
||
else
|
||
{
|
||
//Vector3 worldToScreenPoint = Camera.main.WorldToScreenPoint(new Vector3(obj.transform.position.x, obj.transform.position.y, obj.transform.position.z));
|
||
//threeDTip.transform.parent.GetComponent<RectTransform>().position = new Vector3(worldToScreenPoint.x, worldToScreenPoint.y, 0);
|
||
threeDTip.transform.parent.position = mousePos;
|
||
threeDTip.transform.parent.gameObject.SetActive(true);
|
||
threeDTip.text = obj.name;
|
||
}
|
||
}
|
||
private void OnDestroy()
|
||
{
|
||
FileUtil.WriteToLocal("0", "start.ini");
|
||
}
|
||
private void OnDisable()
|
||
{
|
||
FileUtil.WriteToLocal("0", "start.ini");
|
||
}
|
||
|
||
private void OnApplicationQuit()
|
||
{
|
||
FileUtil.WriteToLocal("0", "start.ini");
|
||
}
|
||
}
|