CultivationOfBrewing-2/Assets/Scripts/Project/Manager/OfficeManager.cs

175 lines
6.7 KiB
C#

using HighlightPlus;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// create by adam
/// </summary>
public class OfficeManager : SingletonMono<OfficeManager>
{
public GameObject currentTool;
public Transform spawnToolPos;
public Transform tMDTips;
/// <summary>
/// 手机
/// </summary>
//public MobileController mobileController;
//private FirstPersonController firstPersonController;
private void Start()
{
//firstPersonController = GameObject.FindGameObjectWithTag("Player").GetComponent<FirstPersonController>();
//firstPersonController.gameObject.SetActive(false);
//GameManager.EventMgr.AddEventListener(Enum_EventType.OfficeTimeLineOver, OfficeTimeLineOver);
//GameManager.EventMgr.AddEventListener<bool>(Enum_EventType.PlayerCanMove, SwitchFirstPersonControllerMove);
GameManager.EventMgr.AddEventListener(Enum_EventType.InitializationUI, InitializationUI);
GameManager.RunModelMgr.SceneType = E_SceneType.Site;
GameManager.RunModelMgr.ModeType = E_ModeType.Study;
if (GameManager.RunModelMgr.ModeType == E_ModeType.Study)//学习模式下提示步骤
{
GameManager.EventMgr.AddEventListener<int>(Enum_EventType.SwitchSubProcess, SwitchSubProcess);
}
InitializationUI();
GameManager.EventMgr.AddEventListener<GameObject>(Enum_EventType.TakeOutAndRetrievingTheTools, SetSpawnToolInfo);
}
public void SwitchFirstPersonControllerMove(bool isMove)
{
//firstPersonController.playerCanMove = isMove;
}
private void SwitchSubProcess(int subProcess)
{
//if (!GameManager.UIMgr.GetPanel<UI_TopTipPanel>())
//{
// GameManager.UIMgr.ShowPanel<UI_TopTipPanel>(E_UI_Layer.Mid, (panel) =>
// {
// panel.Init($"{GameManager.ProcessMgr.d_Scheme.CurrentProcess.processName}:<color=#00EEE6>{GameManager.ProcessMgr.d_Scheme.CurrentProcess.CurrentSubProcess.subProcessName}</color>", $"{GameManager.ProcessMgr.d_Scheme.CurrentProcess.CurrentSubProcess.tips}", false);
// });
//}
//else
//{
// GameManager.UIMgr.GetPanel<UI_TopTipPanel>().Init($"{GameManager.ProcessMgr.d_Scheme.CurrentProcess.processName}:<color=#00EEE6>{GameManager.ProcessMgr.d_Scheme.CurrentProcess.CurrentSubProcess.subProcessName}</color>", $"{GameManager.ProcessMgr.d_Scheme.CurrentProcess.CurrentSubProcess.tips}", false);
//}
}
private void OfficeTimeLineOver()
{
if (!GameManager.UIMgr.GetPanel<UI_MaskPanel>())
{
GameManager.UIMgr.ShowPanel<UI_MaskPanel>(E_UI_Layer.System, (panel) =>
{
panel.Init();
GameManager.EventMgr.EventTrigger(Enum_EventType.HideMask);
});
}
}
private void InitializationUI()
{
if (!GameManager.UIMgr.GetPanel<UI_TaskListPanel>())
{
GameManager.UIMgr.ShowPanel<UI_TaskListPanel>(E_UI_Layer.Bot, (panel) =>
{
panel.Init(GameManager.ProcessMgr.subProcessId);
});
}
if (GameManager.RunModelMgr.ModeType == E_ModeType.Study)
{
GameManager.EventMgr.EventTrigger<string>(Enum_EventType.SwitchSubProcessStepTriggerID, ProcessManager.Instance.subProcessStepTriggerID);
GameManager.EventMgr.EventTrigger(Enum_EventType.SwitchSubProcess, GameManager.ProcessMgr.subProcessId);
}
if (!GameManager.UIMgr.GetPanel<UI_MenuBar>())
{
GameManager.UIMgr.ShowPanel<UI_MenuBar>(E_UI_Layer.Mid, (panel) =>
{
panel.Init();
GameManager.EventMgr.EventTrigger(Enum_EventType.SwitchScene, GameManager.RunModelMgr.SceneType);
});
}
if (!GameManager.UIMgr.GetPanel<UI_GrowthPeriodPanel>())
{
GameManager.UIMgr.ShowPanel<UI_GrowthPeriodPanel>(E_UI_Layer.Mid, (panel) =>
{
panel.Init();
});
}
//firstPersonController.gameObject.SetActive(true);
}
private void OnDestroy()
{
//GameManager.EventMgr.RemoveEventListener(Enum_EventType.OfficeTimeLineOver, OfficeTimeLineOver);
GameManager.EventMgr.RemoveEventListener(Enum_EventType.InitializationUI, InitializationUI);
GameManager.EventMgr.RemoveEventListener<GameObject>(Enum_EventType.TakeOutAndRetrievingTheTools, SetSpawnToolInfo);
//GameManager.EventMgr.RemoveEventListener<bool>(Enum_EventType.PlayerCanMove, SwitchFirstPersonControllerMove);
if (GameManager.UIMgr.GetPanel<UI_MiddleTipPanel>())
{
GameManager.UIMgr.HidePanel<UI_MiddleTipPanel>();
}
Debug.Log("OfficeManager OnDestroy");
//GameManager.EventMgr.RemoveEventListener<int>(Enum_EventType.SwitchSubProcess, SwitchSubProcess);
}
//移植于LiveSceneManager
public void SetSpawnToolInfo(GameObject tool)
{
if (tool == null)
return;
currentTool = tool;
currentTool.transform.parent = Camera.main.transform;
currentTool.transform.localPosition = spawnToolPos.localPosition;
currentTool.transform.localEulerAngles = spawnToolPos.localEulerAngles;
if (currentTool.GetComponent<Tool_Base>())
{
currentTool.GetComponent<Tool_Base>().SetHeadPosAndEulerang(currentTool.transform.localPosition, currentTool.transform.localEulerAngles);
currentTool.GetComponent<Tool_Base>().AddStartAction(() =>
{
tMDTips.gameObject.SetActive(false);
});
currentTool.GetComponent<Tool_Base>().AddEndAction(() =>
{
tMDTips.gameObject.SetActive(true);
});
}
if (currentTool.GetComponent<Device_Base>())
{
currentTool.GetComponent<Device_Base>().SetHeadPosAndEulerang(currentTool.transform.localPosition, currentTool.transform.localEulerAngles);
}
tMDTips.gameObject.SetActive(true);
}
public void OnCheckSubProcess(bool ifdestroy = true)
{
if (currentTool != null)
{
if (tMDTips != null)
tMDTips.gameObject.SetActive(false);
if (ifdestroy)
DestroyImmediate(currentTool);
currentTool = null;
GameManager.EventMgr.EventTrigger<GameObject>(Enum_EventType.TakeOutAndRetrievingTheTools, null);
}
}
private void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
if (currentTool != null)
{
Debug.Log("Escape");
OnCheckSubProcess();
}
}
}
}