Esempio n. 1
0
 /// <summary>
 /// 對 ccUpdateEvent 註冊 Update 事件 ,
 /// 將會返回一個為int類型的 iEventId 解除事件(f_UnRegEvent)使用,如需使用請自行作變數紀錄。
 /// </summary>
 /// <param name="fDelayTime">一開始Delay的時間,預設為0秒</param>
 /// <param name="fRunTime">總共執行中的時間</param>
 /// <param name="tccCallback">每幀會被呼叫的函數</param>
 /// <param name="tccCallbackComplete">最後一幀結束後會被呼叫的函數,如果為空,則預設與tccCallback同函數</param>
 /// <param name="oData">可提供一個可以回傳的參數,如int,GameObject等,可不填,預設為Null</param>
 /// <param name="bUsePause">此事件是否可以被暫停,可不填,預設為不可被暫停</param>
 /// <param name="bCallBackSurplusTime">是否傳回剩餘的時間,預設為回傳剩餘時間,如果oData不為null則此值為 true </param>
 /// <returns></returns>
 public int f_RegEvent(float fRunTime, ccCallbackV2 tccCallbackV2,
                       float fDelayTime = 0, ccCallbackV2 tccCallbackV2Complete = null,
                       object oData     = null, bool bUsePause = false)
 {
     return(this.f_RegEventForTeam(fDelayTime, fRunTime, oData, tccCallbackV2,
                                   tccCallbackV2Complete, bUsePause));
 }
Esempio n. 2
0
        private int f_RegEventForTeam(float fDelayTime, float fRunTime, object oData,
                                      ccCallbackV2 tccCallbackV2, ccCallbackV2 tccCallbackV2Complete, bool bUsePause)
        {
            if ((tccCallbackV2 != null) && (fDelayTime >= 0f))
            {
                //額外條件
                //如果complete為空,則指定給tccCallback
                if (tccCallbackV2Complete == null)
                {
                    tccCallbackV2Complete = tccCallbackV2;
                }

                sTimeEvent tClass1 = new sTimeEvent
                {
                    iId                    = ++iKeyId,
                    m_fDelayTime           = fDelayTime,
                    m_fSurplusTime         = fRunTime,
                    m_oData                = oData,
                    m_ccCallbackV2         = tccCallbackV2,
                    m_ccCallbackV2Complete = tccCallbackV2Complete,
                    m_bUsePause            = bUsePause,
                };
                _aTimeEventList.Add(tClass1);

                if (this.enabled == false)
                {
                    this.enabled = true;
                }
                return(( int )tClass1.iId);
            }
            return(-99);
        }
Esempio n. 3
0
 /// <summary>
 /// 用來註冊有時限的ccUpdateEvent,例如 畫面中 UI文字 5秒內不斷倒數的功能;
 /// 用來註冊時間內不斷作判斷的事件,例如 遊戲開始後30秒內不斷確定分數有沒有達到一百分
 /// Ex: 5秒內是否有鍵盤按下等
 /// 預設為可以被暫停
 /// </summary>
 /// <param name="fRunTime">總執行時間</param>
 /// <param name="tCCcallback">每次的fun與結束fun都會註冊相同的fun</param>
 public sTimeEvent(float fRunTime, ccCallbackV2 tCCcallbackV2)
 {
     m_fSurplusTime         = fRunTime;
     m_ccCallbackV2         = tCCcallbackV2;
     m_ccCallbackV2Complete = tCCcallbackV2;
     m_bUsePause            = true;
 }