using System; using System.Collections; using System.Collections.Generic; using UnityEngine; //ÏûÏ¢¹ÜÀíÆ÷ public class EventManager : MonoSingleton<EventManager> { public delegate void EventHandler(params object[] args); private Dictionary<YogaEventType, Action> _actionDic = new Dictionary<YogaEventType, Action>(); private Dictionary<YogaEventType, EventHandler> _actionsDic = new Dictionary<YogaEventType, EventHandler>(); public void AddEventListener(YogaEventType eventName, Action handler) { if (!_actionDic.ContainsKey(eventName)) { _actionDic.Add(eventName, handler); } else { _actionDic[eventName] -= handler; _actionDic[eventName] += handler; } } public void RemoveEventListener(YogaEventType eventName, Action handler) { if (!_actionDic.ContainsKey(eventName)) return; _actionDic[eventName] -= handler; } public void Dispatch(YogaEventType eventName) { if (!_actionDic.ContainsKey(eventName)) return; _actionDic[eventName]?.Invoke(); } //´ø²ÎÊýµÄʼþ public void AddEventListener(YogaEventType eventName, EventHandler handler) { if (!_actionsDic.ContainsKey(eventName)) { _actionsDic.Add(eventName, handler); } else { _actionsDic[eventName] -= handler; _actionsDic[eventName] += handler; } } public void RemoveEventListener(YogaEventType eventName, EventHandler handler) { if (!_actionsDic.ContainsKey(eventName)) return; _actionsDic[eventName] -= handler; } public void Dispatch(YogaEventType eventName, params object[] param) { if (!_actionsDic.ContainsKey(eventName)) return; _actionsDic[eventName]?.Invoke(param); } } public enum YogaEventType { StartMotionCapture, StopMotionCapture, Action_End, UI_ScoreUpdate, Action_Start, PoseEstimate, Action_Success, Action_Fail, PlayAnimation, UpdateProgress, ShowHint, ShowMessage, ChangeCaptureCameraDevice, PlayCastVoice, DEBUG_CONSOLE_ChangeCamMode, Action_MoveDistanceExactly, Action_SpeedTooFast, Action_SpeedTooSlow, Action_MoveDistanceNotAccurate, UI_LevelFinished, Sound_CountDownAudio, Sound_CountDownEndAudio, Action_StartSampling, Action_EndSampling, Action_Evaluate, }