/// <summary>
        /// View 发出的Action
        /// </summary>
        public void DoAction(EventArgs args)
        {
            if (args is ICardEventArgs)
            {
                (args as ICardEventArgs).CardRID = RuntimeID;
                (args as ICardEventArgs).CardDID = CardID;
            }

            OnActionEvent?.Invoke(this, args);
        }
예제 #2
0
 private void update()
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         spaceCount++;
         OnspacePressed?.Invoke(this, new OnSpacePressedEventArgs {
             spaceCount = spaceCount
         });
         OnFloatEvent?.Invoke(5.5f);
         OnActionEvent?.Invoke(true, 56);
         OnUnityEvent?.Invoke();
     }
 }
예제 #3
0
 protected virtual async Task <ActionEvent> NotifyActionEventAsync(ActionEvent actionEvent)
 {
     try
     {
         if (OnActionEvent != null)
         {
             await OnActionEvent.Invoke(this, actionEvent);
         }
         if (actionEvent.Type == ActionEventType.EvtRetry)
         {
             ++RetryTimes;
         }
         else
         {
             RetryTimes = 0;
         }
         return(actionEvent);
     }
     catch (Exception ex)
     {
         ++RetryTimes;
         return(await HandleExceptionAsync(ex));
     }
 }
예제 #4
0
        private static void _TestDelegateEvent()
        {
            //声明委托,这个委托是一个类,类名叫做delegateAction,他有一个参数类型是方法的构造函数
            //委托定义了方法的参数和返回类型,可以把符合定义的方法赋值给委托
            //同时委托delegateAction中提供了一个实例方法Invoke,可以用来触发委托的执行
            //也就是说第一句声明委托就可以像一个类一样的使用它
            delegateAction test = new delegateAction(_Test2);

            test(0);
            test.Invoke(0);

            //测试已定义好的委托Action
            Action <int, string> method = new Action <int, string>(_Test);

            method(1, "字符串1");
            method.Invoke(1, "字符串1");

            //测试自己定义的事件
            OnActionEvent += _Test2;
            OnActionEvent += _Test22;

            OnActionEvent(2);
            OnActionEvent.Invoke(2);

            //Action委托作为一个函数参数,并且省略定义_Test方法
            _Test3("test3", (i, str) =>
            {
                Console.WriteLine($"test Action委托作为一个函数参数,i={i},str={str}");
            });
            _Test3("test3", _Test);

            daNew += _Test2;
            //daNew -= _Test2;//如果减去了,说明事件不带有任何方法,是空的
            daNew(4);
            daNew.Invoke(4);
        }
예제 #5
0
 /// <summary>
 /// Handle an action event
 /// </summary>
 /// <param name="action">The action being triggered</param>
 private void HandleActionEvent(TPAction action)
 {
     OnActionEvent?.Invoke(action.ActionId, action.Data);
 }
예제 #6
0
 public void EnqueueAction(IVectorActionPlus action)
 {
     Actions.Enqueue(action);
     OnActionEvent?.Invoke(action, ActionEvent.Add);
     ResumeActionExecutor();
 }
예제 #7
0
 public void OnAction(Dictionary <string, object> data)
 {
     OnActionEvent?.Invoke(data);
 }
예제 #8
0
 public void NotifyActionEvent(QQActionEventType type, object target)
 {
     OnActionEvent?.Invoke(this, new QQActionEvent(type, target));
 }