using System.Collections; using System.Collections.Generic; using UnityEngine; using HighlightPlus; using UnityEngine.EventSystems; using System; /// <summary> /// ³£×¤½»»¥ /// </summary> public class PermanentTriggerBase : MonoBehaviour { public int triggerID; public string triggerName; public HighlightEffect _highlight; /// <summary> /// ´ò·Öʼþ /// </summary> private Action<string, object, int, int> scoreAction; private void Awake() { OnAwake(); AddScoreAction(ScoreManager.instance.Check); } private void Start() { OnStart(); } private void SwitchSubProcessStepTriggerID(string arg0) { if (triggerName == arg0) { _highlight.SetHighlighted(true); } else { _highlight.SetHighlighted(false); } } /// <summary> /// Awake /// </summary> protected virtual void OnAwake() { if (GetComponent<HighlightEffect>()) _highlight = GetComponent<HighlightEffect>(); GameManager.EventMgr.AddEventListener<string>(Enum_EventType.SwitchSubProcessStepTriggerID, SwitchSubProcessStepTriggerID); } /// <summary> /// Start /// </summary> protected virtual void OnStart() { } private void OnMouseEnter() { if (EventSystem.current.IsPointerOverGameObject()) return; OnMEnter(); } private void OnMouseDown() { if (EventSystem.current.IsPointerOverGameObject()) return; OnMDown(); } private void OnMouseExit() { if (EventSystem.current.IsPointerOverGameObject()) return; OnMExit(); } protected virtual void OnMEnter() { } protected virtual void OnMDown() { } protected virtual void OnMExit() { } private void OnDestroy() { GameManager.EventMgr.RemoveEventListener<string>(Enum_EventType.SwitchSubProcessStepTriggerID, SwitchSubProcessStepTriggerID); } //private void OnDisable() //{ // GameManager.EventMgr.RemoveEventListener<string>(Enum_EventType.SwitchSubProcessStepTriggerID, SwitchSubProcessStepTriggerID); //} public void AddScoreAction(Action<string, object, int, int> back) { this.scoreAction = back; } /// <summary> /// µ÷Óôò·Ö¹¦ÄÜ /// </summary> /// <param name="para">²ÎÊý ĬÈϲ»´«</param> /// /// <param name="triggerName">´¥·¢µÄÎïÌåʶ±ðºÅ ĬÈÏ´«×Ô¼ºµÄ</param> /// <param name="systemcid">ϵͳid ĬÈϵ±Ç°ÏµÍ³</param> /// <param name="shchmeid">¿ÆÄ¿id ĬÈϵ±Ç°¿ÆÄ¿</param> public void CallScoreAction(object para=null ,string triggerName = null, int systemcid=0,int shchmeid=0) { scoreAction?.Invoke(triggerName==null?this.triggerName:triggerName, para, systemcid, shchmeid); } }