Ejemplo n.º 1
0
 public void OnTick(TickMessage message)
 {
     if (_animationIndicies?.Any() ?? false)
     {
         var nextIndex = _animationIndicies.First();
         CurrentBitmapIndex = nextIndex;
         _animationIndicies.Remove(nextIndex);
         return;
     }
 }
Ejemplo n.º 2
0
 protected void OnTick(TickMessage message)
 {
     //NPCs should only move if we're in the right state
     if (GameModel.Instance.State == GameState.InMap)
     {
         if (_throttleTicks == 0)
         {
             //we're not throttling, let's see if we can move
             var moved = MovementBehavior.TryExecuteBehavior(this);
             if (moved)
             {
                 _throttleTicks = Constants.MAP_MOVE_CHARACTER_TICKS;
             }
         }
         else
         {
             //decrement the throttle counter
             _throttleTicks = Math.Max(0, _throttleTicks - 1);
         }
     }
 }
Ejemplo n.º 3
0
        protected virtual void OnTick(TickMessage message)
        {
            //decrement the throttle counter
            _throttleTicks = Math.Max(-1, _throttleTicks - 1);

            //if we're no longer throttling, see if we have anything queued / to repeat
            if (_throttleTicks == 0) //we specifically check 0 here, as we only do this for 1 tick before the value goes to -1 and 'resets'
            {
                lock (_locker) //we don't want to dequeue a message or set last handled message to null while we're handling one already
                {
                    _lastHandledMessage = null;

                    //any queued message takes precedent
                    if (_messageQueue.Count > 0)
                    {
                        var queuedMessage = _messageQueue.Dequeue();

                        //we have something in queue. Only handle it if we should be handling input at all
                        if (HandledStates.Contains(GameModel.Instance.State))
                        {
                            //we don't want to broadcast this, as it's already been broadcast, so just execute the handler
                            OnUserInput(queuedMessage);
                        }
                    }

                    //otherwise, check immediately to see if there is any key already being pressed, and broadcast that
                    else
                    {
                        //only consider rebroadcasting if we're still in the state we handled originally, and we support repeating this input automatically
                        var downInput = InputUtility.SupportedUserInput.FirstOrDefault(x =>
                            UiThread.Execute(() => Keyboard.IsKeyDown(x))
                            && HandledStates.Contains(GameModel.Instance.State)
                            && (SupportedRepeatableInput?.Contains(InputUtility.MapUserInput(x)) ?? false));
                        if (InputUtility.IsSupportedUserInput(downInput))
                        {
                            Bus.Broadcast<UserInputMessage>(
                                UserInputMessage.New(
                                    GameModel.Instance.State,
                                    InputUtility.MapUserInput(downInput)));
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
 protected void OnTick2(TickMessage message)
 {
     //only try to display characters if we're in dialog, and have a currently displayed page
     if (_currentMessage != null && HandledStates.Contains(GameModel.Instance.State))
     {
         var numberOfCharactersToShow = 0;
         switch (SettingsModel.Instance.MessageSpeed)
         {
             case MessageSpeed.Slow:
                 numberOfCharactersToShow = message.Ticks % 2 == 0 ? 1 : 0;
                 break;
             case MessageSpeed.Normal:
                 numberOfCharactersToShow = 1;
                 break;
             case MessageSpeed.Instant:
                 numberOfCharactersToShow = 99999; //just some arbitrary large number (that isn't Int32.MaxValue, because that will cause overflow)
                 break;
             default:
                 break;
         }
         _currentMessage.Model.TryDisplayNextCharacters(numberOfCharactersToShow);
     }
 }
Ejemplo n.º 5
0
        protected void OnTick(TickMessage message)
        {
            //are we in battle (as opposed to in battle dialog, or no input)
            if (GameModel.Instance.State == GameState.InBattle && BattleModel.Instance?.BattlefieldData != null)
            {
                //are we waiting on a battle ability to finish executing?
                if (BattleModel.Instance.BattlefieldData.ExecutingAbility != null)
                {
                    //we want to pause while abilities are firing. If we don't, on long-running animations, a fast character may be able to lock
                    //in an ability and have to wait 20 seconds, while a slow character would get 20 seconds of extra time to tick away and lock
                    //in as well, effectively boosting the ability of a slower character, and penalizing the fast character
                    return;
                }

                //do we have any queued abilities that need to be triggered?
                var queuedAbilityToFire = _queuedAbilities.FirstOrDefault(x => x.RemainingDelayTicks <= 0);
                if (queuedAbilityToFire != null)
                {
                    //remove from the queue, handle ability activation, set state to waiting to finish if we've activated an ability
                    _queuedAbilities.Remove(queuedAbilityToFire);
                    HandleQueuedAbilityActivation(queuedAbilityToFire);

                    return;
                }

                //do we have any enemies that are ready?
                foreach (var readyEnemy in BattleModel.Instance.BattleData.AllAliveEnemiesInBattle.Where(x => x.ActionStatus == BattleActionStatus.ReadyForInput))
                {
                    //get the enemy's next action, create a queued ability from that, and queue it up
                    var enemyAction = readyEnemy.Enemy.Ai.GetNextAction(readyEnemy, BattleModel.Instance.BattleData);

                    QueueAbility(readyEnemy, enemyAction.Ability, enemyAction.Target);
                }

                //are we waiting on user input?
                if (BattleModel.Instance.BattleData.AllAlivePartyMembersInBattle.Any(x => x.ActionStatus == BattleActionStatus.ReadyForInput) &&
                    SettingsModel.Instance.BattleSpeed == BattleSpeed.Wait)
                {
                    return;
                }

                //time ticks on
                //advance action counters
                var actionMultiplier = BattleModel.Instance.BattleData.GetActionMultiplier();
                foreach (var battleEntityInBattle in BattleModel.Instance.BattleData.AllAliveBattleEntitiesInBattle)
                {
                    battleEntityInBattle.IncreaseActionCounter(actionMultiplier);
                }

                //advance queued ability ticks
                foreach (var queuedAbility in _queuedAbilities)
                {
                    queuedAbility.RemainingDelayTicks--;
                }
            }
        }
Ejemplo n.º 6
0
 protected void OnTick(TickMessage message)
 {
     _resetStepFrameDelay = Math.Max(-1, _resetStepFrameDelay - 1);
     if (_resetStepFrameDelay == 0)
     {
         Look(_currentDirection);
     }
 }
Ejemplo n.º 7
0
 protected void OnTick(TickMessage message)
 {
     TicksPlayed++;
 }
Ejemplo n.º 8
0
 protected void OnTick(TickMessage message)
 {
     SlowBlinkOn = TimerUtility.BlinkOn(message.Ticks, Constants.TIMING_BLINK_TICKS);
     FastBlinkOn = TimerUtility.BlinkOn(message.Ticks, Constants.TIMING_QUICK_BLINK_TICKS);
 }