YanCheng_Metrology/Assets/Scripts/Project/Manager/LiveSceneManager.cs

115 lines
4.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LiveSceneManager : SingletonMono<LiveSceneManager>
{
[HideInInspector]
public FirstPersonController firstPersonController;
//[HideInInspector]
public GameObject currentTool;
public Transform spawnToolPos;
public Transform tMDTips;
public string triggerName;
protected override void Awake()
{
base.Awake();
firstPersonController = GameObject.FindGameObjectWithTag("Player").GetComponent<FirstPersonController>();
tMDTips.gameObject.SetActive(false);
firstPersonController.zoomAction += OnZoom;
}
private void OnZoom(float value)
{
tMDTips.localScale = new Vector3(value, value, value);
}
public void SetSpawnToolInfo(GameObject tool)
{
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);
currentTool.GetComponent<Device_Base>().AddStartAction(() =>
{
});
currentTool.GetComponent<Device_Base>().AddEndAction(() =>
{
});
}
tMDTips.gameObject.SetActive(true);
if (currentTool.name.Equals("<22><><EFBFBD><EFBFBD>֤"))
{
GameManager.UIMgr.ShowPanel<UI_PlayerSessionPanel>(E_UI_Layer.Mid, (p) =>
{
p.Init(currentTool.name, "<22><><EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD>xx<78><78><EFBFBD>繫˾Ա<CBBE><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵĹ<D2B5><C4B9><EFBFBD>֤<EFBFBD><D6A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>Թ󻧸<D4B9><F3BBA7B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܼ<EFBFBD><DCBC><EFBFBD><EFBFBD><EFBFBD>", (intTemp) =>
{
GameManager.ProcessMgr.IsRightSubProcessStepsTriggerID(intTemp, true);
ScoreManager.instance.Check(currentTool.name, null);
OnCheckSubProcess();
});
});
tMDTips.gameObject.SetActive(false);
currentTool.transform.localEulerAngles = new Vector3(90, 0, 0);
}
if (currentTool.name.Equals("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD><DFB5>ܱ<EFBFBD>"))
{
tMDTips.gameObject.SetActive(false);
currentTool.transform.localEulerAngles = new Vector3(-90, 0, -180);
}
if (GameManager.RunModelMgr.ModeType != E_ModeType.Study)
GameManager.EventMgr.EventTrigger<bool>(Enum_EventType.TakeOutAndRetrievingTheTools, false);
}
private void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
if (currentTool != null)
{
if (GameManager.ProcessMgr.IsRightSubProcessStepsTriggerID(triggerName, true) == 0)
{
Debug.Log("Escape");
OnCheckSubProcess();
}
}
}
}
public void OnCheckSubProcess(bool ifdestroy = true)
{
if (tMDTips != null)
tMDTips.gameObject.SetActive(false);
if (ifdestroy)
Destroy(currentTool);
currentTool = null;
if (GameManager.RunModelMgr.ModeType != E_ModeType.Study)
GameManager.EventMgr.EventTrigger<bool>(Enum_EventType.TakeOutAndRetrievingTheTools, true);
}
private void OnDestroy()
{
firstPersonController.zoomAction -= OnZoom;
}
private void OnDisable()
{
firstPersonController.zoomAction -= OnZoom;
}
}