Exemplo n.º 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.
            MobileAction action      = ActionTranslator.GetActionFromIndex(Parent.Body, requestedIndex);
            int          actionIndex = ActionTranslator.GetActionIndex(Parent, action, requestedIndex);

            animate(action, actionIndex, repeatCount, reverse, repeat, delay, true);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Immediately clears all animation data, sets mobile action to stand.
 /// </summary>
 public void Clear()
 {
     m_action              = MobileAction.Stand;
     m_animationFrame      = 0;
     m_FrameCount          = 1;
     m_FrameDelay          = 0;
     m_IsAnimatationPaused = true;
     m_repeatCount         = 0;
     m_actionIndex         = ActionTranslator.GetActionIndex(Parent, MobileAction.Stand);
 }
Exemplo n.º 3
0
        public void Animate(MobileAction action)
        {
            int actionIndex = ActionTranslator.GetActionIndex(Parent, action);

            animate(action, actionIndex, 0, false, false, 0, false);
        }
Exemplo n.º 4
0
        public void Update(double frameMS)
        {
            // create a local copy of ms since last update.
            int 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 (m_IsAnimatationPaused)
            {
                m_AnimationPausedMS -= msSinceLastUpdate;
                if (m_AnimationPausedMS >= 0)
                {
                    // we are still holding. Do not update the current Animation frame.
                    return;
                }
                else
                {
                    // hold time is over, continue to Stand animation.
                    UnPauseAnimation();
                    m_action         = MobileAction.Stand;
                    m_actionIndex    = ActionTranslator.GetActionIndex(Parent, MobileAction.Stand);
                    m_animationFrame = 0f;
                    m_FrameCount     = 1;
                    m_FrameDelay     = 0;
                }
            }

            if (m_action != MobileAction.None)
            {
                float msPerFrame = ((900f * (m_FrameDelay + 1)) / m_FrameCount);
                // Mounted movement is ~2x normal frame rate
                if (Parent.IsMounted && ((m_action == MobileAction.Walk) || (m_action == MobileAction.Run)))
                {
                    msPerFrame /= 2.272727f;
                }

                if (msPerFrame < 0)
                {
                    return;
                }

                m_animationFrame += (float)(frameMS / msPerFrame);

                if (Settings.Audio.FootStepSoundOn)
                {
                    if (m_action == MobileAction.Walk || m_action == MobileAction.Run)
                    {
                        MobileSounds.DoFootstepSounds(Parent as Mobile, m_animationFrame / m_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 (m_animationFrame >= m_FrameCount)
                {
                    if (m_repeatCount > 0)
                    {
                        m_animationFrame -= m_FrameCount;
                        m_repeatCount--;
                    }
                    else
                    {
                        // any requested actions are ended.
                        m_actionCanBeInteruptedByStand = false;
                        // Hold the last frame of the current action if animation is not Stand.
                        if (m_action == MobileAction.Stand)
                        {
                            m_animationFrame = 0;
                        }
                        else
                        {
                            // for most animations, hold the last frame. For Move animations, cycle through.
                            if (m_action == MobileAction.Run || m_action == MobileAction.Walk)
                            {
                                m_animationFrame -= m_FrameCount;
                            }
                            else
                            {
                                m_animationFrame = m_FrameCount - 0.001f;
                            }
                            PauseAnimation();
                        }
                    }
                }
            }
        }