/// ----------------------------------------------------------------------------- /// <summary> /// θΏθ‘δΊδ»Ά /// </summary> /// <param name=string.Empty></param> /// <returns></returns> /// ----------------------------------------------------------------------------- public void Run() { if (m_Mode == TIMER_MODE.DELAYTIME) { if (Time.realtimeSinceStartup - m_StartTime > m_duration) { if (this.m_TimerEvent != null && AsyncTrigger.IsTargetValid(this.m_TimerEvent.Target)) { try { this.m_TimerEvent(); } catch (System.Exception ex) { TimerManager.Destroy(this.m_Name); LogSystem.LogError("Time event catch 1", ex.ToString()); } } else if (this.m_TimerArgsEvent != null && AsyncTrigger.IsTargetValid(this.m_TimerArgsEvent.Target)) { try { this.m_TimerArgsEvent(m_Args); } catch (System.Exception ex) { TimerManager.Destroy(this.m_Name); LogSystem.LogError("Time event catch 1", ex.ToString()); } } TimerManager.Destroy(this.m_Name); } return; } else if (m_Mode == TIMER_MODE.COUNTTIME) { float lastTime = Time.realtimeSinceStartup - m_time; if (lastTime > 1.0f) { m_time = Time.realtimeSinceStartup; try { if (this.m_TimerCountArgsEvent != null && AsyncTrigger.IsTargetValid(this.m_TimerCountArgsEvent.Target)) { this.m_TimerCountArgsEvent(Mathf.CeilToInt(this.TimeLeft), m_Args); } } catch (System.Exception ex) { TimerManager.Destroy(this.m_Name); LogSystem.LogError("Time event catch2 ", ex.ToString()); } if (this.TimeLeft <= 0f) { TimerManager.Destroy(this.m_Name); } } return; } if (this.TimeLeft > 0.0f) { return; } try { if (this.m_TimerEvent != null && AsyncTrigger.IsTargetValid(this.m_TimerEvent.Target)) { this.m_TimerEvent(); } if (this.m_TimerArgsEvent != null && AsyncTrigger.IsTargetValid(this.m_TimerArgsEvent.Target)) { this.m_TimerArgsEvent(m_Args); } } catch (System.Exception ex) { TimerManager.Destroy(this.m_Name); LogSystem.LogError("Time event catch3", ex.ToString()); } if (m_Mode == TIMER_MODE.NORMAL) { Destroy(this.m_Name); } else { m_StartTime = Time.realtimeSinceStartup + this.TimeLeft; } }
public void Run() { if (this.m_Mode == TimerManager.TIMER_MODE.DELAYTIME) { if (Time.realtimeSinceStartup - this.m_StartTime > this.m_duration) { if (this.m_TimerEvent != null && AsyncTrigger.IsTargetValid(this.m_TimerEvent.Target)) { try { this.m_TimerEvent(); } catch (Exception ex) { TimerManager.DestroyTimer(this.m_Name); LogSystem.LogError(new object[] { "Time event catch 1", ex.ToString() }); } } else if (this.m_TimerArgsEvent != null && AsyncTrigger.IsTargetValid(this.m_TimerArgsEvent.Target)) { try { this.m_TimerArgsEvent(this.m_Args); } catch (Exception ex2) { TimerManager.DestroyTimer(this.m_Name); LogSystem.LogError(new object[] { "Time event catch 1", ex2.ToString() }); } } TimerManager.DestroyTimer(this.m_Name); } return; } if (this.m_Mode == TimerManager.TIMER_MODE.COUNTTIME) { float num = Time.realtimeSinceStartup - this.m_time; if (num > 1f) { this.m_time = Time.realtimeSinceStartup; try { if (this.m_TimerCountArgsEvent != null && AsyncTrigger.IsTargetValid(this.m_TimerCountArgsEvent.Target)) { this.m_TimerCountArgsEvent(Mathf.CeilToInt(this.TimeLeft), this.m_Args); } } catch (Exception ex3) { TimerManager.DestroyTimer(this.m_Name); LogSystem.LogError(new object[] { "Time event catch2 ", ex3.ToString() }); } if (this.TimeLeft <= 0f) { TimerManager.DestroyTimer(this.m_Name); } } return; } if (this.TimeLeft > 0f) { return; } try { if (this.m_TimerEvent != null && AsyncTrigger.IsTargetValid(this.m_TimerEvent.Target)) { this.m_TimerEvent(); } if (this.m_TimerArgsEvent != null && AsyncTrigger.IsTargetValid(this.m_TimerArgsEvent.Target)) { this.m_TimerArgsEvent(this.m_Args); } } catch (Exception ex4) { TimerManager.DestroyTimer(this.m_Name); LogSystem.LogError(new object[] { "Time event catch3", ex4.ToString() }); } if (this.m_Mode == TimerManager.TIMER_MODE.NORMAL) { TimerManager.DestroyTimer(this.m_Name); } else { this.m_StartTime = Time.realtimeSinceStartup; } }