private void Func1() { DebugUtils.Info("TestInst", "Func1"); // 第一次 还是会 执行 Func2 // 后一次 才不会 被执行 EnumEventDispatcher.RemoveEventListener(EnumEventType.JoystickRelease, Func2); }
public void AddEvent() { // 按照 先后顺序 触发执行 EnumEventDispatcher.AddEventListener(EnumEventType.JoystickPress, Func1); EnumEventDispatcher.AddEventListener(EnumEventType.JoystickPress, Func2); EnumEventDispatcher.AddEventListener(EnumEventType.JoystickPress, Func3); }
private void Start() { IsAutoTargetPlayer = true; UpdateType = FollowUpdateType.LateUpdate; EnumEventDispatcher.AddEventListener <Vector2>(EnumEventType.JoystickPress, JoystickPress); EnumEventDispatcher.AddEventListener <Vector2>(EnumEventType.JoystickRelease, JoystickRelease); }
public void Release() { if (IsStillCountingDown) { EnumEventDispatcher.RemoveEventListener(EnumEventType.SecondPast, CountDown); } IsRelease = true; }
public void AddListeners() { // 按照 先后顺序 触发执行 // 这里 this 会被 Action 的 Target 引用,必须 RemoveListeners EnumEventDispatcher.AddEventListener(EnumEventType.JoystickRelease, Func1); EnumEventDispatcher.AddEventListener(EnumEventType.JoystickRelease, Func2); EnumEventDispatcher.AddEventListener(EnumEventType.JoystickRelease, Func3); }
/// <summary> /// 倒计时结束 /// </summary> public void EndCountDown() { IsStillCountingDown = false; EnumEventDispatcher.RemoveEventListener(EnumEventType.SecondPast, CountDown); if (mText != null) { mText.text = mEndText; } }
public override void OnPointerUp(PointerEventData eventData) { if (FingerId != eventData.pointerId) { return; } ResetJoystick(); mReleaseEvent.Invoke(eventData.position); EnumEventDispatcher.TriggerEvent(EnumEventType.JoystickRelease, eventData.position); }
public override void OnPointerDown(PointerEventData eventData) { if (eventData.pointerId < -1 || IsDraging) { return; } IsDraging = true; FingerId = eventData.pointerId; InitializedPos = eventData.position; mPressEvent.Invoke(eventData.position); EnumEventDispatcher.TriggerEvent(EnumEventType.JoystickPress, eventData.position); }
private void GetTimeFromServer() { Second++; EscapeSecond++; mCurSyncTime++; mDateTime = mDefaultFixServerTime.AddMinutes(mTimeZone).AddSeconds(Second); EnumEventDispatcher.TriggerEvent(EnumEventType.SecondPast); if (mCurSyncTime >= mDefalutSyncTime) { mCurSyncTime = 0; mTimeSync.GetServerTimeStampReq(); } mTimerId = TimerTaskQueue.Instance.AddTimer(1000, 0, GetTimeFromServer); }
/// <summary> /// CD构造函数 /// </summary> /// <param name="theLabel"></param> /// <param name="theHours"></param> /// <param name="theMinutes"></param> /// <param name="theSeconds"></param> /// <param name="theEndAction">CD结束时回调</param> public AutoCountDown(Text theLabel, int theHours, int theMinutes, int theSeconds, Action theEndAction = null) { mText = theLabel; mCountingText = ""; mStopText = ""; mEndText = ""; mDays = 0; mHours = theHours; mMinutes = theMinutes; mSeconds = theSeconds; IsStillCountingDown = true; mEndAction = theEndAction; mTimeType = TimeStringType.UpToMinutes; mText.text = FormatTime(); EnumEventDispatcher.AddEventListener(EnumEventType.SecondPast, CountDown); }
/// <summary> /// CD构造函数 /// </summary> /// <param name="theLabel"></param> /// <param name="secondsNum">CD秒数</param> /// <param name="theCountingText"></param> /// <param name="theStopText"></param> /// <param name="theEndText"></param> /// <param name="theTimeStringType"></param> /// <param name="theEndAction">CD结束时回调</param> public AutoCountDown(Text theLabel, int secondsNum, string theCountingText, string theStopText, string theEndText, TimeStringType theTimeStringType, Action theEndAction = null) { mText = theLabel; mCountingText = theCountingText; mStopText = theStopText; mEndText = theEndText; mDays = secondsNum / SECONDS_DAY; mHours = secondsNum % SECONDS_DAY / SECONDS_HOUR; mMinutes = secondsNum % SECONDS_HOUR / SECONDS_MINUTE; mSeconds = secondsNum % SECONDS_MINUTE; IsStillCountingDown = true; mEndAction = theEndAction; mTimeType = theTimeStringType; mText.text = FormatTime(); EnumEventDispatcher.AddEventListener(EnumEventType.SecondPast, CountDown); }
/// <summary> /// 倒计时 /// </summary> public void CountDown() { if (IsStillCountingDown) { mSeconds--; if (mSeconds < 0) { mSeconds = 59; mMinutes--; if (mMinutes < 0) { mMinutes = 59; mHours--; if (mHours < 0) { mDays--; if (mDays < 0) { IsStillCountingDown = false; EnumEventDispatcher.RemoveEventListener(EnumEventType.SecondPast, CountDown); if (mText != null) { mText.text = mEndText; } if (mEndAction != null) { mEndAction(); } return; } else { mHours = 23; } } } } } if (mText != null) { mText.text = FormatTime(); } }
// Update is called once per frame void Send() { EnumEventDispatcher.TriggerEvent(EnumEventType.JoystickPress); EnumEventDispatcher.TriggerEvent(EnumEventType.JoystickRelease); }
public void RemoveListeners() { EnumEventDispatcher.RemoveEventListener(EnumEventType.JoystickRelease, Func1); EnumEventDispatcher.RemoveEventListener(EnumEventType.JoystickRelease, Func2); EnumEventDispatcher.RemoveEventListener(EnumEventType.JoystickRelease, Func3); }
private void OnDestroy() { EnumEventDispatcher.RemoveEventListener <Vector2>(EnumEventType.JoystickPress, JoystickPress); EnumEventDispatcher.RemoveEventListener <Vector2>(EnumEventType.JoystickRelease, JoystickRelease); }