Example #1
0
        public void Animate(int requestedIndex, int frameCount, int repeatCount, bool reverse, bool repeat, int delay)
        {
            // note that frameCount is NOT used. Not sure if this counts as a bug.
            var action      = ActionTranslator.GetActionFromIndex(Parent.Body, requestedIndex);
            var actionIndex = ActionTranslator.GetActionIndex(Parent, action, requestedIndex);

            animate(action, actionIndex, repeatCount, reverse, repeat, delay, true);
        }
Example #2
0
 /// <summary>
 /// Immediately clears all animation data, sets mobile action to stand.
 /// </summary>
 public void Clear()
 {
     _action              = MobileAction.Stand;
     _animationFrame      = 0;
     _frameCount          = 1;
     _frameDelay          = 0;
     _isAnimatationPaused = true;
     _repeatCount         = 0;
     _actionIndex         = ActionTranslator.GetActionIndex(Parent, MobileAction.Stand);
 }
Example #3
0
        public void Update(double frameMS)
        {
            // create a local copy of ms since last update.
            var msSinceLastUpdate = (int)frameMS;

            // If we are holding the current animation, then we should wait until our hold time is over
            // before switching to the queued Stand animation.
            if (_isAnimatationPaused)
            {
                _animationPausedMS -= msSinceLastUpdate;
                if (_animationPausedMS >= 0)
                {
                    // we are still holding. Do not update the current Animation frame.
                    return;
                }
                else
                {
                    // hold time is over, continue to Stand animation.
                    UnPauseAnimation();
                    _action         = MobileAction.Stand;
                    _actionIndex    = ActionTranslator.GetActionIndex(Parent, MobileAction.Stand);
                    _animationFrame = 0f;
                    _frameCount     = 1;
                    _frameDelay     = 0;
                }
            }

            if (_action != MobileAction.None)
            {
                var msPerFrame = ((900f * (_frameDelay + 1)) / _frameCount);
                // Mounted movement is ~2x normal frame rate
                if (Parent.IsMounted && ((_action == MobileAction.Walk) || (_action == MobileAction.Run)))
                {
                    msPerFrame /= 2.272727f;
                }
                if (msPerFrame < 0)
                {
                    return;
                }
                _animationFrame += (float)(frameMS / msPerFrame);
                if (UltimaGameSettings.Audio.FootStepSoundOn)
                {
                    if (_action == MobileAction.Walk || _action == MobileAction.Run)
                    {
                        MobileSounds.DoFootstepSounds(Parent as Mobile, _animationFrame / _frameCount);
                    }
                    else
                    {
                        MobileSounds.ResetFootstepSounds(Parent as Mobile);
                    }
                }

                // When animations reach their last frame, if we are queueing to stand, then
                // hold the animation on the last frame.
                if (_animationFrame >= _frameCount)
                {
                    if (_repeatCount > 0)
                    {
                        _animationFrame -= _frameCount;
                        _repeatCount--;
                    }
                    else
                    {
                        // any requested actions are ended.
                        _actionCanBeInteruptedByStand = false;
                        // Hold the last frame of the current action if animation is not Stand.
                        if (_action == MobileAction.Stand)
                        {
                            _animationFrame = 0;
                        }
                        else
                        {
                            // for most animations, hold the last frame. For Move animations, cycle through.
                            if (_action == MobileAction.Run || _action == MobileAction.Walk)
                            {
                                _animationFrame -= _frameCount;
                            }
                            else
                            {
                                _animationFrame = _frameCount - 0.001f;
                            }
                            PauseAnimation();
                        }
                    }
                }
            }
        }
Example #4
0
        public void Animate(MobileAction action)
        {
            var actionIndex = ActionTranslator.GetActionIndex(Parent, action);

            animate(action, actionIndex, 0, false, false, 0, false);
        }