/// <summary> /// 是否暂停计时器 /// </summary> static void isPause(EventPara ep) { if (ep != null && ep.Paras.Length == 1 && ep[0].GetType().Equals(typeof(bool))) { pause = (bool)ep[0]; } }
/// <summary> /// 执行事件组内指定事件 /// </summary> /// <param name="_body">指定事件</param> /// <param name="ep">所需参数</param> public void Excute(Delegate _body, EventPara ep) { lock (_excuteList) { _excuteList.Clear(); _excuteList.AddRange(_eventBodyList); EventBody eventBody = null; for (int i = 0; i < _excuteList.Count; i++) { eventBody = _excuteList[i]; if (_body.Equals(eventBody.body)) { if (eventBody.body.GetType().Equals(typeof(Action))) { ((Action)eventBody.body)(); } else if (eventBody.body.GetType().Equals(typeof(EventDele_1))) { ((EventDele_1)eventBody.body)(ep); } } } } }
/// <summary> /// 执行事件 /// </summary> /// <param name="groupID"></param> /// <param name="bodyID"></param> /// <param name="ep"></param> public void Excute(object groupID, object bodyID, EventPara ep = null) { EventGroup eg; lock (eventDic) { if (eventDic.TryGetValue(groupID, out eg)) { eg.Excute(bodyID, ep); } } }
public void BindEvent(EventPara ep) { if (ep != null && ep.Paras.Length == 2 && ep[0].GetType().Equals(typeof(InputType)) && ep[1].GetType().Equals(typeof(int)) && ep[2].GetType().Equals(typeof(Delegate))) { InputType inputType = (InputType)ep[0]; int mouseBnID = (int)ep[1]; Delegate func = (Delegate)ep[2]; BindEvent(inputType, mouseBnID, func); } else { Debug.Log("警告:参数有误..."); } }
/// <summary> /// 执行事件组所有事件 /// </summary> /// <param name="ep"></param> public void Excute(EventPara ep) { lock (_excuteList) { _excuteList.Clear(); _excuteList.AddRange(_eventBodyList); for (int i = 0; i < _excuteList.Count; i++) { if (_excuteList[i].body.GetType().Equals(typeof(Action))) { ((Action)_excuteList[i].body)(); } else if (_excuteList[i].body.GetType().Equals(typeof(EventDele_1))) { ((EventDele_1)_excuteList[i].body)(ep); } } } }
/// <summary> /// 加载场景 /// </summary> /// <param name="ep"></param> static void LoadScene(EventPara ep) { if (ep.Paras.Length == 1) { if (ep[0].GetType().Equals(typeof(string))) { try { SceneManager.LoadScene((string)ep[0]); } catch { Debug.Log("警告:加载场景失败..."); } } else if (ep[0].GetType().Equals(typeof(int))) { try { SceneManager.LoadScene((int)ep[0]); } catch { Debug.Log("警告:加载场景失败..."); } } } else if (ep.Paras.Length == 2) { if ((ep[0].GetType().Equals(typeof(string)) || ep[0].GetType().Equals(typeof(int))) && ep[1].GetType().Equals(typeof(AsynOrSync))) { if (ep[0].GetType().Equals(typeof(string))) { if ((AsynOrSync)ep[1] == AsynOrSync.SYNC) { SceneManager.LoadScene((string)ep[0]); } else if ((AsynOrSync)ep[1] == AsynOrSync.ASYN) { SceneManager.LoadSceneAsync((string)ep[0]); } else { Debug.Log("警告:传参有误..."); } } else if (ep[0].GetType().Equals(typeof(int))) { if ((AsynOrSync)ep[1] == AsynOrSync.SYNC) { SceneManager.LoadScene((int)ep[0]); } else if ((AsynOrSync)ep[1] == AsynOrSync.ASYN) { SceneManager.LoadSceneAsync((int)ep[0]); } else { Debug.Log("警告:传参有误..."); } } } } }