using System.Collections; using System.Collections.Generic; using BigSpace.Logic; using BigSpace.XRCore.Event; using BigSpace.XRCore.RunningScene; using Unity.XR.PXR; using UnityEngine; public class PlayJiaGuAnimator : MonoBehaviour { public List listAnimator; public GameObject handObj; public int HandType; public HandFontSelfCtr font; public GameObject catchJiaGu; public GameObject animatorJiaGu; public AudioSource audio_HuiDa; public GameObject audio_Wen; //控制文字显示时机 bool oneIsRun = false; float oneWaitTime = 26f; float oneRunTime = 0; // Start is called before the first frame update void Start() { GlobalEventMgr.Listen(GameEvent.EventHideTuchJiaGu, GameDataManage_EventHideTuchJiaGu); } private void Update() { if (oneIsRun) { oneRunTime += Time.deltaTime; if (oneRunTime >= oneWaitTime) { oneIsRun = false; oneRunTime = 0; if (font != null) //显示字 font.PlayShowJGWFont(); if (animatorJiaGu != null) animatorJiaGu.SetActive(false); if (catchJiaGu != null) catchJiaGu.SetActive(true); } } } private void OnTriggerEnter(Collider other) { if (other.gameObject.name == "PalmBox_L" || other.gameObject.name == "PalmBox_R") { if (listAnimator != null) { for (int i = 0; i < listAnimator.Count; i++) { if (HandType == 1) { listAnimator[i].Play("shaohuo_L"); } else { listAnimator[i].Play("shaohuo_R"); } } } oneIsRun = true; GlobalEventMgr.Dispatch(GameEvent.EventHideTuchJiaGu); //只能摸一次,关闭所有的可触摸甲骨碰撞 if (audio_HuiDa != null) audio_HuiDa.Play(); } } void GameDataManage_EventHideTuchJiaGu() { this.GetComponent().enabled = false; if (handObj != null) { handObj.SetActive(false); } if (audio_Wen != null) audio_Wen.SetActive(false); } }