using System.Collections; using System.Collections.Generic; using BigSpace.Logic; using BigSpace.XRCore.Event; using System; using UnityEngine; using BigSpace.XRCore.RunningScene; public class HandShowFontCtr : MonoBehaviour { public List fontList; //文字集合 //public GameObject leftFont_obj; //public GameObject rightFont_obj; private Transform leftHandPalmPosition; private Transform rightHandPalmPosition; Dictionary showFontList = new Dictionary();//已经显示过的文字 // Start is called before the first frame update void Start() { leftHandPalmPosition = HandHelp.Instance.leftHandPalmPosition; rightHandPalmPosition = HandHelp.Instance.rightHandPalmPosition; GlobalEventMgr.Listen(GameEvent.EventShowCatchFont, GameDataManage_EventShowCatchFont); GlobalEventMgr.Listen(GameEvent.EventHideCatchFont, GameDataManage_EventHideCatchFont); } void GameDataManage_EventShowCatchFont(bool isCatchOk,int handType,int fontIndex) { Debug.Log("显示什么字:"+fontIndex); ShowFont(handType, fontIndex); //DateTime time; //if (showFontList.TryGetValue(fontIndex,out time)) //{ // TimeSpan time1 = DateTime.Now - time; // double second = time1.TotalSeconds; // if (second > 5) //5秒内不能重复 // { // showFontList[fontIndex] = DateTime.Now; // ShowFont(handType, fontIndex); // } //} //else //{ // showFontList.Add(fontIndex, DateTime.Now); // ShowFont(handType, fontIndex); //} } void ShowFont(int handType, int fontIndex) { if (handType == 1) { fontList[fontIndex - 1].transform.position = new Vector3(leftHandPalmPosition.position.x, leftHandPalmPosition.position.y + 0.2f, leftHandPalmPosition.position.z); fontList[fontIndex - 1].GetComponent().PlayShowJGWFont(); fontList[fontIndex - 1].transform.LookAt(Camera.main.transform); } else { //fontList[fontIndex - 1].transform.position = Camera.main.transform.position + Camera.main.transform.forward * 1; fontList[fontIndex - 1].transform.position = HandHelp.Instance.rightFrowardPosition.position;//new Vector3(rightHandPalmPosition.position.x-0.5f, rightHandPalmPosition.position.y + 0.2f, rightHandPalmPosition.position.z+0.5f); fontList[fontIndex - 1].GetComponent().PlayShowJGWFont(); fontList[fontIndex - 1].transform.LookAt(Camera.main.transform); } } //转场时,隐藏抓取的字 void GameDataManage_EventHideCatchFont() { //Debug.Log("可以隐藏场景几的文字:"+RunningSceneMgr.Instance._runningSceneData.id); if (RunningSceneMgr.Instance._runningSceneData.id == 10000) { fontList[0].gameObject.SetActive(false); fontList[1].gameObject.SetActive(false); } else if (RunningSceneMgr.Instance._runningSceneData.id == 10002) { fontList[2].gameObject.SetActive(false); fontList[3].gameObject.SetActive(false); fontList[4].gameObject.SetActive(false); fontList[5].gameObject.SetActive(false); } else if (RunningSceneMgr.Instance._runningSceneData.id == 10005) { fontList[6].gameObject.SetActive(false); } else if (RunningSceneMgr.Instance._runningSceneData.id == 10006) { fontList[7].gameObject.SetActive(false); fontList[8].gameObject.SetActive(false); } } }