Ejemplo n.º 1
0
 private void Func1()
 {
     DebugUtils.Info("TestInst", "Func1");
     // 第一次 还是会 执行 Func2
     // 后一次 才不会 被执行
     EnumEventDispatcher.RemoveEventListener(EnumEventType.JoystickRelease, Func2);
 }
Ejemplo n.º 2
0
 public void AddEvent()
 {
     // 按照 先后顺序 触发执行
     EnumEventDispatcher.AddEventListener(EnumEventType.JoystickPress, Func1);
     EnumEventDispatcher.AddEventListener(EnumEventType.JoystickPress, Func2);
     EnumEventDispatcher.AddEventListener(EnumEventType.JoystickPress, Func3);
 }
Ejemplo n.º 3
0
 private void Start()
 {
     IsAutoTargetPlayer = true;
     UpdateType         = FollowUpdateType.LateUpdate;
     EnumEventDispatcher.AddEventListener <Vector2>(EnumEventType.JoystickPress, JoystickPress);
     EnumEventDispatcher.AddEventListener <Vector2>(EnumEventType.JoystickRelease, JoystickRelease);
 }
Ejemplo n.º 4
0
 public void Release()
 {
     if (IsStillCountingDown)
     {
         EnumEventDispatcher.RemoveEventListener(EnumEventType.SecondPast, CountDown);
     }
     IsRelease = true;
 }
Ejemplo n.º 5
0
 public void AddListeners()
 {
     // 按照 先后顺序 触发执行
     // 这里 this 会被 Action 的 Target 引用,必须 RemoveListeners
     EnumEventDispatcher.AddEventListener(EnumEventType.JoystickRelease, Func1);
     EnumEventDispatcher.AddEventListener(EnumEventType.JoystickRelease, Func2);
     EnumEventDispatcher.AddEventListener(EnumEventType.JoystickRelease, Func3);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 倒计时结束
 /// </summary>
 public void EndCountDown()
 {
     IsStillCountingDown = false;
     EnumEventDispatcher.RemoveEventListener(EnumEventType.SecondPast, CountDown);
     if (mText != null)
     {
         mText.text = mEndText;
     }
 }
Ejemplo n.º 7
0
        public override void OnPointerUp(PointerEventData eventData)
        {
            if (FingerId != eventData.pointerId)
            {
                return;
            }

            ResetJoystick();
            mReleaseEvent.Invoke(eventData.position);
            EnumEventDispatcher.TriggerEvent(EnumEventType.JoystickRelease, eventData.position);
        }
Ejemplo n.º 8
0
 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);
 }
Ejemplo n.º 9
0
 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);
 }
Ejemplo n.º 10
0
 /// <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);
 }
Ejemplo n.º 11
0
 /// <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);
 }
Ejemplo n.º 12
0
 /// <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();
     }
 }
Ejemplo n.º 13
0
 // Update is called once per frame
 void Send()
 {
     EnumEventDispatcher.TriggerEvent(EnumEventType.JoystickPress);
     EnumEventDispatcher.TriggerEvent(EnumEventType.JoystickRelease);
 }
Ejemplo n.º 14
0
 public void RemoveListeners()
 {
     EnumEventDispatcher.RemoveEventListener(EnumEventType.JoystickRelease, Func1);
     EnumEventDispatcher.RemoveEventListener(EnumEventType.JoystickRelease, Func2);
     EnumEventDispatcher.RemoveEventListener(EnumEventType.JoystickRelease, Func3);
 }
Ejemplo n.º 15
0
 private void OnDestroy()
 {
     EnumEventDispatcher.RemoveEventListener <Vector2>(EnumEventType.JoystickPress, JoystickPress);
     EnumEventDispatcher.RemoveEventListener <Vector2>(EnumEventType.JoystickRelease, JoystickRelease);
 }