public ToolstripButtonAction(string groupName, string actionName, ActionEventHandler executeHandler, int imageIndex, string text, string tooltip)
     : base(groupName, actionName, executeHandler)
 {
     this.ImageIndex = imageIndex;
     this.text       = text;
     this.Tooltip    = tooltip;
 }
Beispiel #2
0
        public void RemoveActionRegister <T>(Action <T> action) where T : IEventData
        {
            var actionHandler   = new ActionEventHandler <T>(action);
            var handlerToRemove = FindRegisterToRemove(typeof(T), actionHandler.GetType());

            RemoveRegister(typeof(T), handlerToRemove);
        }
Beispiel #3
0
        public IEventHandler <TEventData> Register <TEventData>(Action <TEventData> action) where TEventData : IEventData
        {
            var result = new ActionEventHandler <TEventData>(action);

            Register(result);
            return(result);
        }
Beispiel #4
0
 // Start is called before the first frame update
 void Start()
 {
     ActionEventHandler.AddNewActionEvent(GameDungeonEvent.PrepareDugeon, PrepareDungeon);
     ActionEventHandler.AddNewActionEvent(GameDungeonEvent.StartDungeon, StartDungeon);
     ActionEventHandler.AddNewActionEvent(GameDungeonEvent.EndGame, EndLevel);
     ActionEventHandler.AddNewActionEvent(GameDungeonEvent.LoseGame, LoseGame);
 }
        public ActionEventHandlerTests()
        {
            _mockServiceProvider
            .Setup(sp => sp.GetService(typeof(TestAction)))
            .Returns(_mockAction.Object);

            _mockServiceProvider
            .Setup(sp => sp.GetService(typeof(IActionClient)))
            .Returns(_mockActionClient.Object);

            _mockServiceProvider
            .Setup(sp => sp.GetService(typeof(IServiceScopeFactory)))
            .Returns(_mockServiceScopeFactory.Object);

            _mockServiceScopeFactory
            .Setup(ssf => ssf.CreateScope())
            .Returns(_mockServiceScope.Object);

            _mockServiceScope
            .Setup(ss => ss.ServiceProvider)
            .Returns(_mockServiceProvider.Object);

            _sut = new ActionEventHandler(
                _mockServiceProvider.Object,
                _actions,
                _clientArguments);
        }
Beispiel #6
0
        protected PressureSwitch(RenderSet render_set, double x, double y,
                                 ActionEventHandler state_changed,
                                 SharedState <SwitchState> state,
                                 SharedState <double> latch_expiration,
                                 Stopwatch latch_timer, double latch_time,
                                 Texture texture) :
            base(render_set, x, y, texture)
        {
            TurnOn                     = new SpriteAnimation(Texture, 50, new int [] { 0, 1, 2, 3 });
            TurnOff                    = new SpriteAnimation(Texture, 50, new int [] { 3, 2, 1, 0 });
            _LatchTimer                = latch_timer;
            _LatchTime                 = latch_time;
            _LatchExpiration           = latch_expiration;
            _State                     = state;
            _State.SharedStateChanged += (sender, e) => {
                switch (e.CurrentState)
                {
                case SwitchState.Open:
                    PlayAnimation(TurnOff);
                    break;

                case SwitchState.Closed:
                    PlayAnimation(TurnOn);
                    break;
                }
                state_changed(sender, new ActionEventArgs(e.CurrentState, this));
            };
        }
Beispiel #7
0
        /// <summary>
        /// 订阅指定事件数据的事件处理委托
        /// </summary>
        /// <typeparam name="TEventData">事件数据类型</typeparam>
        /// <param name="action">事件处理委托</param>
        public virtual void Subscribe <TEventData>(Action <TEventData> action) where TEventData : IEventData
        {
            Check.NotNull(action, nameof(action));

            IEventHandler eventHandler = new ActionEventHandler <TEventData>(action);

            Subscribe <TEventData>(eventHandler);
        }
Beispiel #8
0
 /// <summary>
 /// Returns instance of Transition class.
 /// </summary>
 /// <param name="sourceState">Source state of transition.</param>
 /// <param name="targetState">Target state of transition.</param>
 /// <param name="symbols">Collection of transition symbols.</param>
 /// <param name="transitionAction">Delegate for TransitionAction event.</param>
 public Transition(State <TInSymbol, TOutSymbol> sourceState, State <TInSymbol, TOutSymbol> targetState, IEnumerable <TInSymbol> symbols, ActionEventHandler transitionAction)
     : this(sourceState, targetState, symbols)
 {
     if (transitionAction is not null)
     {
         TransitionAction += transitionAction;
     }
 }
Beispiel #9
0
 public override void Consume()
 {
     TimeManipulator.GetInstance().InvokeRepeatAction(0.25f, 5, () =>
     {
         ActionEventHandler.Invoke(PlayerCombatEvent.HealEvent, new object[] { healthAmount / 5 }, null);
     }, null);
     Destroy(gameObject);
 }
Beispiel #10
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Helper method that can be used to add an ActionEventHandler to the Skin for this
 /// Module Control
 /// </summary>
 /// <remarks>
 /// </remarks>
 /// <history>
 ///   [cnurse] 17/9/2004  Added Documentation
 /// </history>
 /// -----------------------------------------------------------------------------
 protected void AddActionHandler(ActionEventHandler e)
 {
     UI.Skins.Skin ParentSkin = UI.Skins.Skin.GetParentSkin(this);
     if (ParentSkin != null)
     {
         ParentSkin.RegisterModuleActionEvent(ModuleId, e);
     }
 }
 public ToolstripButtonStateAction(string groupName, string actionName, ActionEventHandler executHandler, int imageIndex, string text, ActionStateEventHandler <T, bool> enableDisableHandler)
     : base(groupName, actionName, executHandler)
 {
     this.GetImageIndex = new ActionStateEventHandler <T, int>((s, e) => imageIndex);
     this.GetText       = new ActionStateEventHandler <T, string>((s, e) => text);
     this.GetToolTip    = new ActionStateEventHandler <T, string>((s, e) => string.Empty);
     this.EnableDisable = enableDisableHandler;
 }
Beispiel #12
0
 protected PressureSwitch(RenderSet render_set, double x, double y,
                          ActionEventHandler state_changed,
                          SharedState <SwitchState> state,
                          SharedState <double> latch_expiration,
                          Stopwatch latch_timer, double latch_time) :
     this(render_set, x, y, state_changed, state, latch_expiration, latch_timer, latch_time, Texture.Get("sprite_floor_switch"))
 {
 }
Beispiel #13
0
 public virtual void AddHandler(ActionIdentifier actionId, ActionEventHandler handler)
 {
     if (!Handlers.TryGetValue(actionId, out var handlersList))
     {
         handlersList = new List <ActionEventHandler>();
         Handlers.Add(actionId, handlersList);
     }
     handlersList.Add(handler);
 }
 public ToolstripButtonStateAction(string groupName, string actionName, ActionEventHandler executeHandler, ActionStateEventHandler <T, int> imageHandler, ActionStateEventHandler <T, string> textHandler, ActionStateEventHandler <T, string> tooltipHandler, ActionStateEventHandler <T, bool> enableDisableHandler, ActionStateEventHandler <T, bool> visibilityHandler)
     : base(groupName, actionName, executeHandler)
 {
     this.GetText       = textHandler;
     this.GetImageIndex = imageHandler;
     this.GetToolTip    = tooltipHandler ?? new ActionStateEventHandler <T, string>((s, e) => string.Empty);
     this.EnableDisable = enableDisableHandler;
     this.GetVisibility = visibilityHandler;
 }
        /// <summary>
        /// 触发删除成功事件
        /// </summary>
        /// <param name="e">参数</param>
        protected virtual void OnDeleted(ActionEventArgs <TEntity> e)
        {
            ActionEventHandler <TEntity> handler = Deleted;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Beispiel #16
0
 protected ProjectileSwitch(RenderSet render_set, double x, double y,
                            ActionEventHandler state_changed,
                            SharedState <SwitchState> state,
                            SharedState <double> latch_expiration,
                            Stopwatch latch_timer, double latch_time) :
     base(render_set, x, y, state_changed, state, latch_expiration, latch_timer, latch_time, Texture.Get("sprite_projectile_switch"))
 {
     Theta = 0.0;
 }
Beispiel #17
0
 protected override void OnDied()
 {
     base.OnDied();
     isDeath = true;
     // Add animation death here
     animator?.SetTrigger("onDie");
     transform.position += offset;
     ActionEventHandler.Invoke(GameDungeonEvent.EndGame);
 }
Beispiel #18
0
 protected ProjectileSwitch(RenderSet render_set, double x, double y,
                        ActionEventHandler state_changed,
                        SharedState<SwitchState> state,
                        SharedState<double> latch_expiration,
                        Stopwatch latch_timer, double latch_time)
     : base(render_set, x, y, state_changed, state, latch_expiration, latch_timer, latch_time, Texture.Get("sprite_projectile_switch"))
 {
     Theta = 0.0;
 }
Beispiel #19
0
        protected virtual void onActionStart(TaskEventArgs e)
        {
            ActionEventHandler handler = actionEventHandler;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Beispiel #20
0
        public virtual void AddHandler <T>(ActionEventHandler handler) where T : IAction
        {
            var actionIds = IAction.GetActionIdentifiers <T>();

            foreach (var id in actionIds)
            {
                AddHandler(id, handler);
            }
        }
        /// <summary>
        /// 触发更新前事件
        /// </summary>
        /// <param name="e">参数</param>
        protected virtual void OnUpdating(ActionEventArgs <TEntity> e)
        {
            ActionEventHandler <TEntity> handler = Updating;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Beispiel #22
0
 public override void Consume()
 {
     // Instantiate bullet to use
     // Prevent instantiate too much
     if (ObjectPool.GetObject(pfBullet.GetBulletCode()) == null)
     {
         ObjectPool.RegisterObjectPoolItem(pfBullet.GetBulletCode(), pfBullet.gameObject, 10);
     }
     ActionEventHandler.Invoke(PlayerCombatEvent.PickBulletItem, new object[] { pfBullet, sprite, gameObject }, null);
 }
 private void SwapBullet()
 {
     if (listBullet.Count < 2)
     {
         // Invoke event display error behaviour
         //ActionEventHandler.Invoke(PlayerCombatEvent.DisplayErrorBehaviour)
         return;
     }
     currentBullet = currentBullet == 0 ? 1 : 0;
     ActionEventHandler.Invoke(PlayerCombatEvent.SwapBullet, new object[] { currentBullet }, null);
 }
        protected ClientActionBase(string actionName, ActionEventHandler executeHandler)
        {
            if (string.IsNullOrWhiteSpace(actionName))
                throw new ArgumentNullException("actionName");

            if (executeHandler == null)
                throw new ArgumentNullException("executeHandler");

            this.ActionName = actionName;
            this.Execute = executeHandler;
        }
Beispiel #25
0
 /// <summary>
 /// Unbind your void of button action, identified by buttonName & EActionEvent.
 /// </summary>
 /// <param name="buttonName"></param>
 /// <param name="m_Handler"></param>
 /// <param name="EActionEvent"></param>
 public static void UnbindAction(string buttonName, EActionEvent m_Event, ActionEventHandler m_Handler)
 {
     foreach (TCKButton button in buttons)
     {
         if (button.MyName == buttonName)
         {
             button.UnBindAction(m_Handler, m_Event);
             return;
         }
     }
     Debug.LogError("Button: " + buttonName + " Not Found.");
 }
Beispiel #26
0
 /// <summary>
 /// Bind your void to button action, identified by buttonName. Called established event in actionPhase.
 /// </summary>
 /// <param name="buttonName"></param>
 /// <param name="m_Handler"></param>
 /// <param name="actionPhase"></param>
 public static void BindAction(string buttonName, ActionEventHandler m_Handler, ActionPhase actionPhase)
 {
     foreach (TCKButton button in buttons)
     {
         if (button.MyName == buttonName)
         {
             button.BindAction(m_Handler, actionPhase);
             return;
         }
     }
     Debug.LogError("Button: " + buttonName + " Not Found.");
 }
Beispiel #27
0
 /// <summary>
 /// Returns instance of State class.
 /// </summary>
 /// <param name="isAccept">True if state is accept state.</param>
 /// <param name="isTrap">True if state is trap state.</param>
 /// <param name="output">Token carried by state.</param>
 /// <param name="entryAction">Delegate for EtryActoin event.</param>
 /// <param name="exitAction">Delegate for ExitAction event.</param>
 public State(bool isAccept, bool isTrap, TOutSymbol output, ActionEventHandler entryAction, ActionEventHandler exitAction)
     : this(isAccept, isTrap, output)
 {
     if (entryAction is not null)
     {
         EntryAction += entryAction;
     }
     if (entryAction is not null)
     {
         ExitAction += exitAction;
     }
 }
Beispiel #28
0
 /// <summary>
 /// Helper method that can be used to add an ActionEventHandler to the Skin for this
 /// Module Control
 /// </summary>
 /// <remarks>
 /// </remarks>
 protected void AddActionHandler(ActionEventHandler e)
 {
     //This finds a reference to the containing skin
     UI.Skins.Skin ParentSkin = UI.Skins.Skin.GetParentSkin(this);
     //We should always have a ParentSkin, but need to make sure
     if (ParentSkin != null)
     {
         //Register our EventHandler as a listener on the ParentSkin so that it may tell us
         //when a menu has been clicked.
         ParentSkin.RegisterModuleActionEvent(this.ModuleId, e);
     }
 }
Beispiel #29
0
        public void Register <TEventData>(Action <TEventData> action) where TEventData : IEventData
        {
            //1.构造ActionEventHandler
            var actionHandler = new ActionEventHandler <TEventData>(action);

            //2.将ActionEventHandler的实例注入到Ioc容器
            IocContainer.Register(
                Component.For <IEventHandler <TEventData> >()
                .UsingFactoryMethod(() => actionHandler));

            //注册到事件总线
            Register <TEventData>(actionHandler);
        }
Beispiel #30
0
    private void PrepareDungeon()
    {
        var spawnPosition = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height / 2));

        spawnPosition.z   = 0f;
        pfGoPopup         = Instantiate(pfGoPopup, spawnPosition, Quaternion.identity);
        pfGoPopupParticle = Instantiate(pfGoPopupParticle, spawnPosition, Quaternion.identity);

        AstarPath.active.Scan(AstarPath.active.data.gridGraph);
        TimeManipulator.GetInstance().InvokeActionAfterSeconds(2f, () =>
        {
            ActionEventHandler.Invoke(GameDungeonEvent.StartDungeon);
        });
    }
        protected ClientActionBase(string actionName, ActionEventHandler executeHandler)
        {
            if (string.IsNullOrWhiteSpace(actionName))
            {
                throw new ArgumentNullException("actionName");
            }

            if (executeHandler == null)
            {
                throw new ArgumentNullException("executeHandler");
            }

            this.ActionName = actionName;
            this.Execute    = executeHandler;
        }
        // Start is called before the first frame update
        void Start()
        {
            dim.DOFade(0f, 0f);
            textPause.DOFade(0, 0f);
            exitButton.transform.DOScale(Vector3.zero, 0f);
            resumeButton.transform.DOScale(Vector3.zero, 0f);
            restartButton.transform.DOScale(Vector3.zero, 0f);
            exitText.DOFade(0f, 0f);
            resumeText.DOFade(0f, 0f);
            restartText.DOFade(0f, 0f);

            // Register action event
            ActionEventHandler.AddNewActionEvent(PlayerCombatEvent.SwapBullet, SwapBulletEvent);
            ActionEventHandler.AddNewActionEvent(PlayerCombatEvent.PickBulletItem, PickBulletItemEvent);
            ActionEventHandler.AddNewActionEvent(SkillCastEvent.UIChangeEvent, CastSkill);
        }
Beispiel #33
0
 public ProjectileSwitch(RenderSet render_set, double x, double y, ActionEventHandler state_changed, double latch_time = double.PositiveInfinity)
     : this(render_set, x, y, state_changed, new SharedState<SwitchState>(SwitchState.Open), new SharedState<double>(latch_time), new Stopwatch(), latch_time)
 {
 }
Beispiel #34
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// RegisterModuleActionEvent registers a Module Action Event
 /// </summary>
 /// <param name="moduleId">The ID of the module</param>
 /// <param name="e">An Action Event Handler</param>
 /// <history>
 /// 	[cnurse]	12/04/2007  documented
 /// </history>
 /// -----------------------------------------------------------------------------
 public void RegisterModuleActionEvent(int moduleId, ActionEventHandler e)
 {
     ActionEventListeners.Add(new ModuleActionEventListener(moduleId, e));
 }
 public ModuleActionEventListener(int ModID, ActionEventHandler e)
 {
     _moduleID = ModID;
     _actionEvent = e;
 }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Helper method that can be used to add an ActionEventHandler to the Skin for this 
 /// Module Control
 /// </summary>
 /// <remarks>
 /// </remarks>
 /// <history>
 ///   [cnurse] 17/9/2004  Added Documentation
 /// </history>
 /// -----------------------------------------------------------------------------
 protected void AddActionHandler(ActionEventHandler e)
 {
     UI.Skins.Skin ParentSkin = UI.Skins.Skin.GetParentSkin(this);
     if (ParentSkin != null)
     {
         ParentSkin.RegisterModuleActionEvent(ModuleId, e);
     }
 }
 /// <summary>
 /// Helper method that can be used to add an ActionEventHandler to the Skin for this
 /// Module Control
 /// </summary>
 /// <remarks>
 /// </remarks>
 protected void AddActionHandler(ActionEventHandler e)
 {
     //This finds a reference to the containing skin
     UI.Skins.Skin ParentSkin = UI.Skins.Skin.GetParentSkin(this);
     //We should always have a ParentSkin, but need to make sure
     if (ParentSkin != null)
     {
         //Register our EventHandler as a listener on the ParentSkin so that it may tell us
         //when a menu has been clicked.
         ParentSkin.RegisterModuleActionEvent(this.ModuleId, e);
     }
 }
Beispiel #38
0
 public void RegisterModuleActionEvent( int ModuleID, ActionEventHandler e )
 {
     this.ActionEventListeners.Add( new ModuleActionEventListener( ModuleID, e ) );
 }
Beispiel #39
0
 public ProjectileSwitch(RenderSet render_set, double x, double y, ActionEventHandler state_changed, PressureSwitch sync_switch, double latch_time)
     : this(render_set, x, y, state_changed, new SharedState<SwitchState>(SwitchState.Open), new SharedState<double>(latch_time), new Stopwatch(), latch_time)
 {
 }
Beispiel #40
0
 public ProjectileSwitch(RenderSet render_set, double x, double y, ActionEventHandler state_changed, PressureSwitch sync_switch)
     : this(render_set, x, y, state_changed, sync_switch, sync_switch.LatchTime)
 {
 }
Beispiel #41
0
    /// <summary>
    /// Nettoyage des instances
    /// </summary>
    /// <param name="disposing">true si les ressources non managées doivent être libérées</param>
    protected override void Dispose( bool disposing ) {
      if (disposing && (state != State.disposing) && (state != State.disposed) ) {
        //Psl.Tracker.Tracker.Track( "ActionList.Disposing" ); 
        state = State.disposing;
        try {

          // désabonnements propres à la liste d'action
          if (!DesignMode) {
            Application.Idle -= new EventHandler( Application_Idle );
            ActionGlobalBeforeEvent -= new ActionEventHandler( OnActionGlobalBefore );
            ActionGlobalAfterEvent -= new ActionEventHandler( OnActionGlobalAfter );
            DoSetContainerControl( null );
          }

          // destruction de toutes les actions de la liste
          while (actions.Count > 0) {
            Action action = actions[ actions.Count - 1 ];
            actions.RemoveAt( actions.Count - 1 );
            action.Dispose();
          }
          //Psl.Tracker.Tracker.Track( "ActionList.Disposed" );
        }
        finally { state = State.disposed; }
      }
      base.Dispose( disposing );
    }
        public static void RemoveHandler(IActionProvider provider, ActionEventHandler handler)
        {
            if (!map.ContainsKey(provider))
            {
                return;
            }

            ActionDispatcher dispatcher = map[provider];
            dispatcher.ActionEvent -= handler;
            if (dispatcher.ActionEvent.GetInvocationList().Length == 0)
            {
                dispatcher.Release();
                map.Remove(provider);
            }
        }
 public static void AddHandler(IActionProvider provider, ActionEventHandler handler)
 {
     ActionDispatcher dispatcher;
     if (map.ContainsKey(provider))
     {
         dispatcher = map[provider];
     }
     else
     {
         dispatcher = new ActionDispatcher(provider);
         map.Add(provider, dispatcher);
     }
     dispatcher.ActionEvent += handler;
 }
Beispiel #44
0
    /// <summary>
    /// Constructeur
    /// </summary>
    public ActionList() {
      //Psl.Tracker.Tracker.Track( "ActionList.cctor.3 (empty)" );

      // initialisation dans tous les cas
      actions = new ActionCollection( this );

      // initialisations hors mode conception
      if (DesignMode) return;
      Application.Idle += new EventHandler( Application_Idle );
      ActionGlobalBeforeEvent += new ActionEventHandler( OnActionGlobalBefore );
      ActionGlobalAfterEvent += new ActionEventHandler( OnActionGlobalAfter );
    }