コード例 #1
0
        private IEnumerator TimeLimitGlobalEvent(float duration, GlobalEventArgs globalEventArgs)
        {
            Debug.Log("Event Start");
            yield return(new WaitForSeconds(duration));

            Debug.Log("Event End");
            GlobalEventFinish(globalEventArgs);
        }
コード例 #2
0
        private IEnumerator DelayGlobalEvent(float delayTime, GlobalEventArgs globalEventArgs)
        {
            Debug.Log("Delay Start");
            yield return(new WaitForSeconds(delayTime));

            Debug.Log("Delay End");
            globalEventArgsList.Add(globalEventArgs);
            GlobalEventInit(globalEventArgs);
        }
コード例 #3
0
 private void GlobalEventFinish(GlobalEventArgs globalEventArgs)
 {
     if (globalEventArgsList.Contains(globalEventArgs))
     {
         globalEventArgs.FinishEventFunction(aSide, bSide, globalEventArgs.Args);
         globalEventArgs.State = EventState.Finished;
         globalEventArgsList.Remove(globalEventArgs);
     }
     else
     {
         throw new Exception("事件表中找不到目标事件");
     }
 }
コード例 #4
0
 /// <summary>
 ///     注册全局事件
 /// </summary>
 /// <param name="globalEventArgs"></param>
 public void RegisterGlobalEvent(GlobalEventArgs globalEventArgs)
 {
     //启动延时检查
     if (!globalEventArgs.IsDelay)
     {
         globalEventArgsList.Add(globalEventArgs);
         GlobalEventInit(globalEventArgs);
     }
     else
     {
         StartCoroutine(DelayGlobalEvent(globalEventArgs.DelayTime, globalEventArgs));
     }
 }
コード例 #5
0
 private void GlobalEventInit(GlobalEventArgs globalEventArgs)
 {
     if (globalEventArgsList.Contains(globalEventArgs))
     {
         globalEventArgs.InitEventFunction(aSide, bSide, globalEventArgs.Args);
         globalEventArgs.State = EventState.OnGoing;
         if (globalEventArgs.IsTimeLimitation)
         {
             StartCoroutine(TimeLimitGlobalEvent(globalEventArgs.LimitTime, globalEventArgs));
         }
     }
     else
     {
         throw new Exception("事件表中找不到目标事件");
     }
 }