Пример #1
0
 protected override void GetCommands(Entity entity)
 {
     commandQueue.Clear();
     if (InputSource == null)
     {
         return;
     }
     if (entity.CanExecuteActionOfType(GameInfo.ActionType.Move))
     {
         if (InputSource.DashKeyPressed && _dashCooldownTimer <= 0)
         {
             uint            duration = 2;
             Vector2         velocity = InputSource.MoveVector * 4;
             Action <Entity> dash     = (dashingEntity) => {
                 if (!entity.CanExecuteActionOfType(GameInfo.ActionType.Move))
                 {
                     return;
                 }
                 entity.LockActionType(GameInfo.ActionType.Move, 1);
                 entity.Velocity = velocity;
                 uint            _counter      = 0;
                 Action <Entity> OnFixedUpdate = null;
                 OnFixedUpdate = (e) => {
                     if (_counter == duration)
                     {
                         entity.Velocity = Vector2.zero;
                         entity.UnlockActionType(GameInfo.ActionType.Move, 1);
                         entity.OnFixedUpdate -= OnFixedUpdate;
                         return;
                     }
                     _counter++;
                 };
                 entity.OnFixedUpdate += OnFixedUpdate;
                 _dashCooldownTimer    = (int)DashCooldown;
             };
             commandQueue.Issue(dash);
             return;
         }
         commandQueue.Issue(Behaviours.GetEntityMoveCommandFromInput(entity, InputSource));
     }
     _dashCooldownTimer--;
 }