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      = getActionFromIndex(requestedIndex);
            int          actionIndex = getActionIndex(action, requestedIndex);

            animate(action, actionIndex, repeatCount, reverse, repeat, delay, true);
        }
Exemple #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);
 }
        private void animate(MobileAction action, int actionIndex, int repeatCount, bool reverse, bool repeat, int delay, bool isRequestedAction)
        {
            if (m_action == action)
            {
                if (m_IsAnimatationPaused)
                {
                    UnPauseAnimation();
                }
            }

            if (isRequestedAction)
            {
                m_actionCanBeInteruptedByStand = true;
            }

            if ((m_action != action) || (m_actionIndex != actionIndex))
            {
                // If we are switching from any action to a stand action, then hold the last frame of the
                // current animation for a moment. Only Stand actions are held; thus when any hold ends,
                // then we know we were holding for a Stand action.
                if (!(m_action == MobileAction.None) && (action == MobileAction.Stand && m_action != MobileAction.Stand))
                {
                    if (m_action != MobileAction.None)
                    {
                        PauseAnimation();
                    }
                }
                else
                {
                    m_action = action;
                    UnPauseAnimation();
                    m_actionIndex    = actionIndex;
                    m_animationFrame = 0f;

                    // get the resource provider
                    IResourceProvider provider = ServiceRegistry.GetService <IResourceProvider>();
                    IAnimationFrame[] frames   = provider.GetAnimation(
                        Parent.Body, actionIndex, (int)Parent.Facing, Parent.Hue);
                    if (frames != null)
                    {
                        m_FrameCount = frames.Length;
                        m_FrameDelay = delay;
                        if (repeat == false)
                        {
                            m_repeatCount = 0;
                        }
                        else
                        {
                            m_repeatCount = repeatCount;
                        }
                    }
                }
            }
        }
Exemple #4
0
        private void animate(MobileAction action, int actionIndex, int repeatCount, bool reverse, bool repeat, int delay, bool isRequestedAction)
        {
            if (_action == action)
            {
                if (_isAnimatationPaused)
                {
                    UnPauseAnimation();
                }
            }

            if (isRequestedAction)
            {
                _actionCanBeInteruptedByStand = true;
            }

            if (_action != action || _actionIndex != actionIndex)
            {
                // If we are switching from any action to a stand action, then hold the last frame of the
                // current animation for a moment. Only Stand actions are held; thus when any hold ends,
                // then we know we were holding for a Stand action.
                if (!(_action == MobileAction.None) && (action == MobileAction.Stand && _action != MobileAction.Stand))
                {
                    if (_action != MobileAction.None)
                    {
                        PauseAnimation();
                    }
                }
                else
                {
                    _action = action;
                    UnPauseAnimation();
                    _actionIndex    = actionIndex;
                    _animationFrame = 0f;

                    // get the frames of the base body - we need to count the number of frames in this animation.
                    var provider = Service.Get <IResourceProvider>();
                    int body = Parent.Body, hue = 0;
                    var frames = provider.GetAnimation(body, ref hue, actionIndex, (int)Parent.DrawFacing);
                    if (frames != null)
                    {
                        _frameCount = frames.Length;
                        _frameDelay = delay;
                        if (repeat == false)
                        {
                            _repeatCount = 0;
                        }
                        else
                        {
                            _repeatCount = repeatCount;
                        }
                    }
                }
            }
        }
Exemple #5
0
        private void animate(MobileAction action, int actionIndex, int repeatCount, bool reverse, bool repeat, int delay, bool isRequestedAction)
        {
            if (m_action == action)
            {
                if (m_holdAnimation)
                {
                    unholdAnimation();
                }
            }

            if (isRequestedAction)
            {
                m_actionCanBeInteruptedByStand = true;
            }

            if ((m_action != action) || (m_actionIndex != actionIndex))
            {
                // If we are switching from any action to a stand action, then hold the last frame of the
                // current animation for a moment. Only Stand actions are held; thus when any hold ends,
                // then we know we were holding for a Stand action.
                if (!(m_action == MobileAction.None) && (action == MobileAction.Stand && m_action != MobileAction.Stand))
                {
                    if (m_action != MobileAction.None)
                    {
                        holdAnimation();
                    }
                }
                else
                {
                    m_action = action;
                    unholdAnimation();
                    m_actionIndex    = actionIndex;
                    m_animationFrame = 0f;
                    m_FrameCount     = UltimaData.Animations.GetAnimationFrameCount(
                        Parent.BodyID, actionIndex, (int)Parent.Facing, Parent.Hue);
                    m_FrameDelay = delay;
                    if (repeat == false)
                    {
                        m_repeatCount = 0;
                    }
                    else
                    {
                        m_repeatCount = repeatCount;
                    }
                }
            }
        }
        private int getActionIndex(MobileAction action, int index)
        {
            if (Parent.Body.IsHuman)
            {
                switch (action)
                {
                case MobileAction.None:
                    return(getActionIndex(MobileAction.Stand, index));

                case MobileAction.Walk:
                    if (Parent.IsMounted)
                    {
                        return((int)ActionIndexHumanoid.Mounted_RideSlow);
                    }
                    else
                    if (Parent.Flags.IsWarMode)
                    {
                        return((int)ActionIndexHumanoid.Walk_Warmode);
                    }
                    else
                    {
                        // if carrying a light source, return Walk_Armed.
                        if (Parent.LightSourceBodyID != 0)
                        {
                            return((int)ActionIndexHumanoid.Walk_Armed);
                        }
                        else
                        {
                            return((int)ActionIndexHumanoid.Walk);
                        }
                    }

                case MobileAction.Run:
                    if (Parent.IsMounted)
                    {
                        return((int)ActionIndexHumanoid.Mounted_RideFast);
                    }
                    else
                    {
                        // if carrying a light source, return Run_Armed.
                        if (Parent.LightSourceBodyID != 0)
                        {
                            return((int)ActionIndexHumanoid.Run_Armed);
                        }
                        else
                        {
                            return((int)ActionIndexHumanoid.Run);
                        }
                    }

                case MobileAction.Stand:
                    if (Parent.IsMounted)
                    {
                        return((int)ActionIndexHumanoid.Mounted_Stand);
                    }
                    else
                    if (Parent.Flags.IsWarMode)
                    {
                        // Also check if weapon type is 2h. Can be 1H or 2H
                        return((int)ActionIndexHumanoid.Stand_Warmode1H);
                    }
                    else
                    {
                        return((int)ActionIndexHumanoid.Stand);
                    }

                case MobileAction.Death:
                    // randomly select die forwards or backwards.
                    if (Utility.RandomValue(0, 1) == 0)
                    {
                        return((int)ActionIndexHumanoid.Die_Backwards);
                    }
                    else
                    {
                        return((int)ActionIndexHumanoid.Die_Forwards);
                    }

                case MobileAction.Attack:
                    if (Parent.IsMounted)
                    {
                        // check weapon type. Can be 1H, Bow, or XBow
                        return((int)ActionIndexHumanoid.Mounted_Attack_1H);
                    }
                    else
                    {
                        // check weapon type. Can be 1H, 2H across, 2H down, 2H jab, bow, xbow, or unarmed.
                        return((int)ActionIndexHumanoid.Attack_1H);
                    }

                case MobileAction.Cast_Directed:
                    if (Parent.IsMounted)
                    {
                        return(getActionIndex(MobileAction.Stand, index));
                    }
                    else
                    {
                        return((int)ActionIndexHumanoid.Cast_Directed);
                    }

                case MobileAction.Cast_Area:
                    if (Parent.IsMounted)
                    {
                        return(getActionIndex(MobileAction.Stand, index));
                    }
                    else
                    {
                        return((int)ActionIndexHumanoid.Cast_Area);
                    }

                case MobileAction.GetHit:
                    if (Parent.IsMounted)
                    {
                        return(getActionIndex(MobileAction.Stand, index));
                    }
                    else
                    {
                        return((int)ActionIndexHumanoid.Hit);
                    }

                case MobileAction.Block:
                    if (Parent.IsMounted)
                    {
                        return(getActionIndex(MobileAction.Stand, index));
                    }
                    else
                    {
                        return((int)ActionIndexHumanoid.Block_WithShield);
                    }

                case MobileAction.Emote_Fidget_1:
                    if (Parent.IsMounted)
                    {
                        return(getActionIndex(MobileAction.Stand, index));
                    }
                    else
                    {
                        return((int)ActionIndexHumanoid.Fidget_1);
                    }

                case MobileAction.Emote_Fidget_2:
                    if (Parent.IsMounted)
                    {
                        return(getActionIndex(MobileAction.Stand, index));
                    }
                    else
                    {
                        return((int)ActionIndexHumanoid.Fidget_2);
                    }

                case MobileAction.Emote_Bow:
                    if (Parent.IsMounted)
                    {
                        return(getActionIndex(MobileAction.Stand, index));
                    }
                    else
                    {
                        return((int)ActionIndexHumanoid.Emote_Bow);
                    }

                case MobileAction.Emote_Salute:
                    if (Parent.IsMounted)
                    {
                        return(getActionIndex(MobileAction.Stand, index));
                    }
                    else
                    {
                        return((int)ActionIndexHumanoid.Emote_Salute);
                    }

                case MobileAction.Emote_Eat:
                    if (Parent.IsMounted)
                    {
                        return(getActionIndex(MobileAction.Stand, index));
                    }
                    else
                    {
                        return((int)ActionIndexHumanoid.Emote_Eat);
                    }

                default:
                    return((int)-1);
                }
            }
            else if (Parent.Body.IsAnimal)
            {
                switch (action)
                {
                case MobileAction.None:
                    return(getActionIndex(MobileAction.Stand, index));

                case MobileAction.Walk:
                    return((int)ActionIndexAnimal.Walk);

                case MobileAction.Run:
                    return((int)ActionIndexAnimal.Run);

                case MobileAction.Stand:
                    return((int)ActionIndexAnimal.Stand);

                case MobileAction.Death:
                    // randomly select die forwards or backwards.
                    if (Utility.RandomValue(0, 1) == 0)
                    {
                        return((int)ActionIndexAnimal.Die_Backwards);
                    }
                    else
                    {
                        return((int)ActionIndexAnimal.Die_Forwards);
                    }

                case MobileAction.MonsterAction:
                    return(index);

                default:
                    return((int)-1);
                }
            }
            else if (Parent.Body.IsMonster)
            {
                switch (action)
                {
                case MobileAction.None:
                    return(getActionIndex(MobileAction.Stand, index));

                case MobileAction.Walk:
                    return((int)ActionIndexMonster.Walk);

                case MobileAction.Run:
                    return((int)ActionIndexMonster.Run);

                case MobileAction.Stand:
                    return((int)ActionIndexMonster.Stand);

                case MobileAction.Death:
                    // randomly select die forwards or backwards.
                    if (Utility.RandomValue(0, 1) == 0)
                    {
                        return((int)ActionIndexMonster.Die_Backwards);
                    }
                    else
                    {
                        return((int)ActionIndexMonster.Die_Forwards);
                    }

                case MobileAction.MonsterAction:
                    return(index);

                default:
                    return((int)-1);
                }
            }

            return(-1);
        }
        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    = getActionIndex(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();
                        }
                    }
                }
            }
        }
 /// <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 = getActionIndex(MobileAction.Stand);
 }
 private int getActionIndex(MobileAction action)
 {
     return(getActionIndex(action, -1));
 }
 public static int GetActionIndex(AEntity entity, MobileAction action)
 {
     return GetActionIndex(entity, action, -1);
 }
        private int getActionIndex(MobileAction action, int index)
        {
            if (Parent.Body.IsHumanoid)
            {
                switch (action)
                {
                    case MobileAction.None:
                        // this will never be called.
                        return getActionIndex(MobileAction.Stand, index);
                    case MobileAction.Walk:
                        if (Parent.IsMounted)
                            return (int)ActionIndexHumanoid.Mounted_RideSlow;
                        else
                            if (Parent.Flags.IsWarMode)
                                return (int)ActionIndexHumanoid.Walk_Warmode;
                            else
                            {
                                // if carrying a light source, return Walk_Armed.
                                if (Parent.LightSourceBodyID != 0)
                                    return (int)ActionIndexHumanoid.Walk_Armed;
                                else
                                    return (int)ActionIndexHumanoid.Walk;
                            }
                    case MobileAction.Run:
                        if (Parent.IsMounted)
                            return (int)ActionIndexHumanoid.Mounted_RideFast;
                        else
                        {
                            // if carrying a light source, return Run_Armed.
                            if (Parent.LightSourceBodyID != 0)
                                return (int)ActionIndexHumanoid.Run_Armed;
                            else
                                return (int)ActionIndexHumanoid.Run;
                        }
                    case MobileAction.Stand:
                        if (Parent.IsMounted)
                        {
                            return (int)ActionIndexHumanoid.Mounted_Stand;
                        }
                        else
                        {
                            if (Parent.IsSitting)
                            {
                                return (int)ActionIndexHumanoid.Sit;
                            }
                            else if (Parent.Flags.IsWarMode)
                            {
                                // TODO: Also check if weapon type is 2h. Can be 1H or 2H
                                return (int)ActionIndexHumanoid.Stand_Warmode1H;
                            }
                            else
                            {
                                return (int)ActionIndexHumanoid.Stand;
                            }
                        }
                    case MobileAction.Death:
                        // randomly select die forwards or backwards.
                        if (Utility.RandomValue(0, 1) == 0)
                            return (int)ActionIndexHumanoid.Die_Backwards;
                        else
                            return (int)ActionIndexHumanoid.Die_Forwards;
                    case MobileAction.Attack:
                        if (Parent.IsMounted)
                        {
                            // check weapon type. Can be 1H, Bow, or XBow
                            return (int)ActionIndexHumanoid.Mounted_Attack_1H;
                        }
                        else
                        {
                            // check weapon type. Can be 1H, 2H across, 2H down, 2H jab, bow, xbow, or unarmed.
                            return (int)ActionIndexHumanoid.Attack_1H;
                        }
                    case MobileAction.Cast_Directed:
                        if (Parent.IsMounted)
                            return getActionIndex(MobileAction.Stand, index);
                        else
                            return (int)ActionIndexHumanoid.Cast_Directed;
                    case MobileAction.Cast_Area:
                        if (Parent.IsMounted)
                            return getActionIndex(MobileAction.Stand, index);
                        else
                            return (int)ActionIndexHumanoid.Cast_Area;
                    case MobileAction.GetHit:
                        if (Parent.IsMounted)
                            return getActionIndex(MobileAction.Stand, index);
                        else
                            return (int)ActionIndexHumanoid.Hit;
                    case MobileAction.Block:
                        if (Parent.IsMounted)
                            return getActionIndex(MobileAction.Stand, index);
                        else
                            return (int)ActionIndexHumanoid.Block_WithShield;
                    case MobileAction.Emote_Fidget_1:
                        if (Parent.IsMounted)
                            return getActionIndex(MobileAction.Stand, index);
                        else
                            return (int)ActionIndexHumanoid.Fidget_1;
                    case MobileAction.Emote_Fidget_2:
                        if (Parent.IsMounted)
                            return getActionIndex(MobileAction.Stand, index);
                        else
                            return (int)ActionIndexHumanoid.Fidget_2;
                    case MobileAction.Emote_Bow:
                        if (Parent.IsMounted)
                            return getActionIndex(MobileAction.Stand, index);
                        else
                            return (int)ActionIndexHumanoid.Emote_Bow;
                    case MobileAction.Emote_Salute:
                        if (Parent.IsMounted)
                            return getActionIndex(MobileAction.Stand, index);
                        else
                            return (int)ActionIndexHumanoid.Emote_Salute;
                    case MobileAction.Emote_Eat:
                        if (Parent.IsMounted)
                            return getActionIndex(MobileAction.Stand, index);
                        else
                            return (int)ActionIndexHumanoid.Emote_Eat;
                    default:
                        return (int)-1;
                }
            }
            else if (Parent.Body.IsAnimal)
            {
                switch (action)
                {
                    case MobileAction.None:
                        return getActionIndex(MobileAction.Stand, index);
                    case MobileAction.Walk:
                        return (int)ActionIndexAnimal.Walk;
                    case MobileAction.Run:
                        return (int)ActionIndexAnimal.Run;
                    case MobileAction.Stand:
                        return (int)ActionIndexAnimal.Stand;
                    case MobileAction.Death:
                        // randomly select die forwards or backwards.
                        if (Utility.RandomValue(0, 1) == 0)
                            return (int)ActionIndexAnimal.Die_Backwards;
                        else
                            return (int)ActionIndexAnimal.Die_Forwards;
                    case MobileAction.MonsterAction:
                        return index;
                    default:
                        return (int)-1;
                }
            }
            else if (Parent.Body.IsMonster)
            {
                switch (action)
                {
                    case MobileAction.None:
                        return getActionIndex(MobileAction.Stand, index);
                    case MobileAction.Walk:
                        return (int)ActionIndexMonster.Walk;
                    case MobileAction.Run:
                        return (int)ActionIndexMonster.Walk;
                    case MobileAction.Stand:
                        return (int)ActionIndexMonster.Stand;
                    case MobileAction.Death:
                        // randomly select die forwards or backwards.
                        if (Utility.RandomValue(0, 1) == 0)
                            return (int)ActionIndexMonster.Die_Backwards;
                        else
                            return (int)ActionIndexMonster.Die_Forwards;
                    case MobileAction.MonsterAction:
                        return index;
                    default:
                        return (int)-1;
                }
            }

            return -1;
        }
Exemple #12
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();
                        }

                    }
                }
            }
        }
Exemple #13
0
 public void Animate(MobileAction action)
 {
     int actionIndex = ActionTranslator.GetActionIndex(Parent, action);
     animate(action, actionIndex, 0, false, false, 0, false);
 }
 private int getActionIndex(MobileAction action)
 {
     return getActionIndex(action, -1);
 }
        private int getActionIndex(MobileAction action, int index)
        {
            if (m_bodyType == BodyTypes.Humanoid)
            {
                switch (action)
                {
                    case MobileAction.None:
                        return getActionIndex(MobileAction.Stand, index);
                    case MobileAction.Walk:
                        if (Parent.IsMounted)
                            return (int)ActionIndexHumanoid.Mounted_RideSlow;
                        else
                            if (Parent.IsWarMode)
                                return (int)ActionIndexHumanoid.Walk_Warmode;
                            else
                            {
                                // Also check if is_armed.
                                return (int)ActionIndexHumanoid.Walk;
                            }
                    case MobileAction.Run:
                        if (Parent.IsMounted)
                            return (int)ActionIndexHumanoid.Mounted_RideFast;
                        else
                            return (int)ActionIndexHumanoid.Run;
                    case MobileAction.Stand:
                        if (Parent.IsMounted)
                            return (int)ActionIndexHumanoid.Mounted_Stand;
                        else
                            if (Parent.IsWarMode)
                            {
                                // Also check if weapon type is 2h. Can be 1H or 2H
                                return (int)ActionIndexHumanoid.Stand_Warmode1H;
                            }
                            else
                                return (int)ActionIndexHumanoid.Stand;
                    case MobileAction.Death:
                        // randomly select die forwards or backwards.
                        if (Utility.RandomValue(0, 1) == 0)
                            return (int)ActionIndexHumanoid.Die_Backwards;
                        else
                            return (int)ActionIndexHumanoid.Die_Forwards;
                    case MobileAction.Attack:
                        if (Parent.IsMounted)
                        {
                            // check weapon type. Can be 1H, Bow, or XBow
                            return (int)ActionIndexHumanoid.Mounted_Attack_1H;
                        }
                        else
                        {
                            // check weapon type. Can be 1H, 2H across, 2H down, 2H jab, bow, xbow, or unarmed.
                            return (int)ActionIndexHumanoid.Attack_1H;
                        }
                    case MobileAction.Cast_Directed:
                        if (Parent.IsMounted)
                            return getActionIndex(MobileAction.Stand, index);
                        else
                            return (int)ActionIndexHumanoid.Cast_Directed;
                    case MobileAction.Cast_Area:
                        if (Parent.IsMounted)
                            return getActionIndex(MobileAction.Stand, index);
                        else
                            return (int)ActionIndexHumanoid.Cast_Area;
                    case MobileAction.GetHit:
                        if (Parent.IsMounted)
                            return getActionIndex(MobileAction.Stand, index);
                        else
                            return (int)ActionIndexHumanoid.Hit;
                    case MobileAction.Block:
                        if (Parent.IsMounted)
                            return getActionIndex(MobileAction.Stand, index);
                        else
                            return (int)ActionIndexHumanoid.Block_WithShield;
                    case MobileAction.Emote_Fidget_1:
                        if (Parent.IsMounted)
                            return getActionIndex(MobileAction.Stand, index);
                        else
                            return (int)ActionIndexHumanoid.Fidget_1;
                    case MobileAction.Emote_Fidget_2:
                        if (Parent.IsMounted)
                            return getActionIndex(MobileAction.Stand, index);
                        else
                            return (int)ActionIndexHumanoid.Fidget_2;
                    case MobileAction.Emote_Bow:
                        if (Parent.IsMounted)
                            return getActionIndex(MobileAction.Stand, index);
                        else
                            return (int)ActionIndexHumanoid.Emote_Bow;
                    case MobileAction.Emote_Salute:
                        if (Parent.IsMounted)
                            return getActionIndex(MobileAction.Stand, index);
                        else
                            return (int)ActionIndexHumanoid.Emote_Salute;
                    case MobileAction.Emote_Eat:
                        if (Parent.IsMounted)
                            return getActionIndex(MobileAction.Stand, index);
                        else
                            return (int)ActionIndexHumanoid.Emote_Eat;
                    default:
                        return (int)-1;
                }
            }
            else if (m_bodyType == BodyTypes.LowDetail)
            {
                switch (action)
                {
                    case MobileAction.None:
                        return getActionIndex(MobileAction.Stand, index);
                    case MobileAction.Walk:
                        return (int)ActionIndexAnimal.Walk;
                    case MobileAction.Run:
                        return (int)ActionIndexAnimal.Run;
                    case MobileAction.Stand:
                        return (int)ActionIndexAnimal.Stand;
                    case MobileAction.Death:
                        // randomly select die forwards or backwards.
                        if (Utility.RandomValue(0, 1) == 0)
                            return (int)ActionIndexAnimal.Die_Backwards;
                        else
                            return (int)ActionIndexAnimal.Die_Forwards;
                    case MobileAction.MonsterAction:
                        return index;
                    default:
                        return (int)-1;
                }
            }
            else if (m_bodyType == BodyTypes.HighDetail)
            {
                switch (action)
                {
                    case MobileAction.None:
                        return getActionIndex(MobileAction.Stand, index);
                    case MobileAction.Walk:
                        return (int)ActionIndexMonster.Walk;
                    case MobileAction.Run:
                        return (int)ActionIndexMonster.Run;
                    case MobileAction.Stand:
                        return (int)ActionIndexMonster.Stand;
                    case MobileAction.Death:
                        // randomly select die forwards or backwards.
                        if (Utility.RandomValue(0, 1) == 0)
                            return (int)ActionIndexMonster.Die_Backwards;
                        else
                            return (int)ActionIndexMonster.Die_Forwards;
                    case MobileAction.MonsterAction:
                        return index;
                    default:
                        return (int)-1;
                }
            }

            return -1;
        }
        private void animate(MobileAction action, int actionIndex, int repeatCount, bool reverse, bool repeat, int delay, bool isRequestedAction)
        {
            if (m_action == action)
            {
                if (m_holdAnimation)
                {
                    unholdAnimation();
                }
            }

            if (isRequestedAction)
                m_actionCanBeInteruptedByStand = true;

            if ((m_action != action) || (m_actionIndex != actionIndex))
            {
                // If we are switching from any action to a stand action, then hold the last frame of the
                // current animation for a moment. Only Stand actions are held; thus when any hold ends,
                // then we know we were holding for a Stand action.
                if (!(m_action == MobileAction.None) && (action == MobileAction.Stand && m_action != MobileAction.Stand))
                {
                    if (m_action != MobileAction.None)
                        holdAnimation();
                }
                else
                {
                    m_action = action;
                    unholdAnimation();
                    m_actionIndex = actionIndex;
                    m_animationFrame = 0f;
                    m_FrameCount = UltimaData.AnimationData.GetAnimationFrameCount(
                        Parent.BodyID, actionIndex, (int)Parent.Facing, Parent.Hue);
                    m_FrameDelay = delay;
                    if (repeat == false)
                        m_repeatCount = 0;
                    else
                        m_repeatCount = repeatCount;
                }
            }
        }
        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_holdAnimation)
            {
                m_holdAnimationTime -= msSinceLastUpdate;
                if (m_holdAnimationTime >= 0)
                {
                    // we are still holding. Do not update the current Animation frame.
                    return;
                }
                else
                {
                    // hold time is over, continue to Stand animation.
                    unholdAnimation();
                    m_action = MobileAction.Stand;
                    m_actionIndex = getActionIndex(MobileAction.Stand);
                    m_animationFrame = 0f;
                    m_FrameCount = 1;
                    m_FrameDelay = 0;
                }
            }

            if (m_action != MobileAction.None)
            {
                // advance the animation one step, based on gametime passed.
                float animationStep = (float)((m_FrameCount * (m_FrameDelay + 1)) * 10);
                float timeStep = ((float)frameMS / animationStep) / m_FrameCount;

                float msPerFrame = (float)((1000 * (m_FrameDelay + 1)) / (float)m_FrameCount);
                // Mounted movement is 2x normal frame rate
                if (Parent.IsMounted && ((m_action == MobileAction.Walk) || (m_action == MobileAction.Run)))
                    msPerFrame /= 2;

                float frameAdvance = (float)(frameMS / msPerFrame) / m_FrameCount;
                if (msPerFrame < 0)
                    return;

                m_animationFrame += frameAdvance;

                // When animations reach their last frame, if we are queueing to stand, then
                // hold the animation on the last frame.
                if (m_animationFrame >= 1f)
                {
                    if (m_repeatCount > 0)
                    {
                        m_animationFrame %= 1f;
                        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 %= 1f;
                            else
                                m_animationFrame -= frameAdvance;
                            holdAnimation();
                        }

                    }
                }
            }
        }
 public void Animate(MobileAction action)
 {
     int actionIndex = getActionIndex(action);
     animate(action, actionIndex, 0, false, false, 0, false);
 }
Exemple #19
0
 public static int GetActionIndex(AEntity entity, MobileAction action)
 {
     return(GetActionIndex(entity, action, -1));
 }
Exemple #20
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_holdAnimation)
            {
                m_holdAnimationTime -= msSinceLastUpdate;
                if (m_holdAnimationTime >= 0)
                {
                    // we are still holding. Do not update the current Animation frame.
                    return;
                }
                else
                {
                    // hold time is over, continue to Stand animation.
                    unholdAnimation();
                    m_action         = MobileAction.Stand;
                    m_actionIndex    = getActionIndex(MobileAction.Stand);
                    m_animationFrame = 0f;
                    m_FrameCount     = 1;
                    m_FrameDelay     = 0;
                }
            }

            if (m_action != MobileAction.None)
            {
                // advance the animation one step, based on gametime passed.
                float animationStep = (float)((m_FrameCount * (m_FrameDelay + 1)) * 10);
                float timeStep      = ((float)frameMS / animationStep) / m_FrameCount;

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

                float frameAdvance = (float)(frameMS / msPerFrame) / m_FrameCount;
                if (msPerFrame < 0)
                {
                    return;
                }

                m_animationFrame += frameAdvance;

                // When animations reach their last frame, if we are queueing to stand, then
                // hold the animation on the last frame.
                if (m_animationFrame >= 1f)
                {
                    if (m_repeatCount > 0)
                    {
                        m_animationFrame %= 1f;
                        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 %= 1f;
                            }
                            else
                            {
                                m_animationFrame -= frameAdvance;
                            }
                            holdAnimation();
                        }
                    }
                }
            }
        }
Exemple #21
0
        public static int GetActionIndex(AEntity entity, MobileAction action, int index)
        {
            Body body = 0;
            bool isMounted = false, isWarMode = false, isSitting = false, dieForwards = false;
            int  lightSourceBodyID = 0;

            if (entity is Corpse)
            {
                body        = (entity as Corpse).Body;
                dieForwards = (entity as Corpse).DieForwards;
            }
            else if (entity is Mobile)
            {
                Mobile mobile = entity as Mobile;
                body              = mobile.Body;
                isMounted         = mobile.IsMounted;
                isWarMode         = mobile.Flags.IsWarMode;
                isSitting         = mobile.IsSitting;
                lightSourceBodyID = mobile.LightSourceBodyID;
            }
            else
            {
                Tracer.Critical("Entity of type {0} cannot get an action index.", entity.ToString());
            }

            if (body.IsHumanoid)
            {
                switch (action)
                {
                case MobileAction.None:
                    // this will never be called.
                    return(GetActionIndex(entity, MobileAction.Stand, index));

                case MobileAction.Walk:
                    if (isMounted)
                    {
                        return((int)ActionIndexHumanoid.Mounted_RideSlow);
                    }
                    else
                    if (isWarMode)
                    {
                        return((int)ActionIndexHumanoid.Walk_Warmode);
                    }
                    else
                    {
                        // if carrying a light source, return Walk_Armed.
                        if (lightSourceBodyID != 0)
                        {
                            return((int)ActionIndexHumanoid.Walk_Armed);
                        }
                        else
                        {
                            return((int)ActionIndexHumanoid.Walk);
                        }
                    }

                case MobileAction.Run:
                    if (isMounted)
                    {
                        return((int)ActionIndexHumanoid.Mounted_RideFast);
                    }
                    else
                    {
                        // if carrying a light source, return Run_Armed.
                        if (lightSourceBodyID != 0)
                        {
                            return((int)ActionIndexHumanoid.Run_Armed);
                        }
                        else
                        {
                            return((int)ActionIndexHumanoid.Run);
                        }
                    }

                case MobileAction.Stand:
                    if (isMounted)
                    {
                        return((int)ActionIndexHumanoid.Mounted_Stand);
                    }
                    else
                    {
                        if (isSitting)
                        {
                            return((int)ActionIndexHumanoid.Sit);
                        }
                        else if (isWarMode)
                        {
                            // TODO: Also check if weapon type is 2h. Can be 1H or 2H
                            return((int)ActionIndexHumanoid.Stand_Warmode1H);
                        }
                        else
                        {
                            return((int)ActionIndexHumanoid.Stand);
                        }
                    }

                case MobileAction.Death:
                    if (dieForwards)
                    {
                        return((int)ActionIndexHumanoid.Die_Backwards);
                    }
                    else
                    {
                        return((int)ActionIndexHumanoid.Die_Forwards);
                    }

                case MobileAction.Attack:
                    if (isMounted)
                    {
                        // check weapon type. Can be 1H, Bow, or XBow
                        return((int)ActionIndexHumanoid.Mounted_Attack_1H);
                    }
                    else
                    {
                        // check weapon type. Can be 1H, 2H across, 2H down, 2H jab, bow, xbow, or unarmed.
                        return((int)ActionIndexHumanoid.Attack_1H);
                    }

                case MobileAction.Cast_Directed:
                    if (isMounted)
                    {
                        return(GetActionIndex(entity, MobileAction.Stand, index));
                    }
                    else
                    {
                        return((int)ActionIndexHumanoid.Cast_Directed);
                    }

                case MobileAction.Cast_Area:
                    if (isMounted)
                    {
                        return(GetActionIndex(entity, MobileAction.Stand, index));
                    }
                    else
                    {
                        return((int)ActionIndexHumanoid.Cast_Area);
                    }

                case MobileAction.GetHit:
                    if (isMounted)
                    {
                        return(GetActionIndex(entity, MobileAction.Stand, index));
                    }
                    else
                    {
                        return((int)ActionIndexHumanoid.Hit);
                    }

                case MobileAction.Block:
                    if (isMounted)
                    {
                        return(GetActionIndex(entity, MobileAction.Stand, index));
                    }
                    else
                    {
                        return((int)ActionIndexHumanoid.Block_WithShield);
                    }

                case MobileAction.Emote_Fidget_1:
                    if (isMounted)
                    {
                        return(GetActionIndex(entity, MobileAction.Stand, index));
                    }
                    else
                    {
                        return((int)ActionIndexHumanoid.Fidget_1);
                    }

                case MobileAction.Emote_Fidget_2:
                    if (isMounted)
                    {
                        return(GetActionIndex(entity, MobileAction.Stand, index));
                    }
                    else
                    {
                        return((int)ActionIndexHumanoid.Fidget_2);
                    }

                case MobileAction.Emote_Bow:
                    if (isMounted)
                    {
                        return(GetActionIndex(entity, MobileAction.Stand, index));
                    }
                    else
                    {
                        return((int)ActionIndexHumanoid.Emote_Bow);
                    }

                case MobileAction.Emote_Salute:
                    if (isMounted)
                    {
                        return(GetActionIndex(entity, MobileAction.Stand, index));
                    }
                    else
                    {
                        return((int)ActionIndexHumanoid.Emote_Salute);
                    }

                case MobileAction.Emote_Eat:
                    if (isMounted)
                    {
                        return(GetActionIndex(entity, MobileAction.Stand, index));
                    }
                    else
                    {
                        return((int)ActionIndexHumanoid.Emote_Eat);
                    }

                default:
                    return((int)-1);
                }
            }
            else if (body.IsAnimal)
            {
                switch (action)
                {
                case MobileAction.None:
                    return(GetActionIndex(entity, MobileAction.Stand, index));

                case MobileAction.Walk:
                    return((int)ActionIndexAnimal.Walk);

                case MobileAction.Run:
                    return((int)ActionIndexAnimal.Run);

                case MobileAction.Stand:
                    return((int)ActionIndexAnimal.Stand);

                case MobileAction.Death:
                    if (dieForwards)
                    {
                        return((int)ActionIndexAnimal.Die_Backwards);
                    }
                    else
                    {
                        return((int)ActionIndexAnimal.Die_Forwards);
                    }

                case MobileAction.MonsterAction:
                    return(index);

                default:
                    return((int)-1);
                }
            }
            else if (body.IsMonster)
            {
                switch (action)
                {
                case MobileAction.None:
                    return(GetActionIndex(entity, MobileAction.Stand, index));

                case MobileAction.Walk:
                    return((int)ActionIndexMonster.Walk);

                case MobileAction.Run:
                    return((int)ActionIndexMonster.Walk);

                case MobileAction.Stand:
                    return((int)ActionIndexMonster.Stand);

                case MobileAction.Death:
                    if (dieForwards)
                    {
                        return((int)ActionIndexMonster.Die_Backwards);
                    }
                    else
                    {
                        return((int)ActionIndexMonster.Die_Forwards);
                    }

                case MobileAction.MonsterAction:
                    return(index);

                default:
                    return((int)-1);
                }
            }

            return(-1);
        }
        public void Animate(MobileAction action)
        {
            int actionIndex = getActionIndex(action);

            animate(action, actionIndex, 0, false, false, 0, false);
        }
Exemple #23
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);
 }
        public static int GetActionIndex(AEntity entity, MobileAction action, int index)
        {
            Body body = 0;
            bool isMounted = false, isWarMode = false, isSitting = false, dieForwards = false;
            int lightSourceBodyID = 0;

            if (entity is Corpse)
            {
                body = (entity as Corpse).Body;
                dieForwards = (entity as Corpse).DieForwards;
            }
            else if (entity is Mobile)
            {
                Mobile mobile = entity as Mobile;
                body = mobile.Body;
                isMounted = mobile.IsMounted;
                isWarMode = mobile.Flags.IsWarMode;
                isSitting = mobile.IsSitting;
                lightSourceBodyID = mobile.LightSourceBodyID;
            }
            else
            {
                Tracer.Critical("Entity of type {0} cannot get an action index.", entity.ToString());
            }

            if (body.IsHumanoid)
            {
                switch (action)
                {
                    case MobileAction.None:
                        // this will never be called.
                        return GetActionIndex(entity, MobileAction.Stand, index);
                    case MobileAction.Walk:
                        if (isMounted)
                            return (int)ActionIndexHumanoid.Mounted_RideSlow;
                        else
                            if (isWarMode)
                            return (int)ActionIndexHumanoid.Walk_Warmode;
                        else
                        {
                            // if carrying a light source, return Walk_Armed.
                            if (lightSourceBodyID != 0)
                                return (int)ActionIndexHumanoid.Walk_Armed;
                            else
                                return (int)ActionIndexHumanoid.Walk;
                        }
                    case MobileAction.Run:
                        if (isMounted)
                            return (int)ActionIndexHumanoid.Mounted_RideFast;
                        else
                        {
                            // if carrying a light source, return Run_Armed.
                            if (lightSourceBodyID!= 0)
                                return (int)ActionIndexHumanoid.Run_Armed;
                            else
                                return (int)ActionIndexHumanoid.Run;
                        }
                    case MobileAction.Stand:
                        if (isMounted)
                        {
                            return (int)ActionIndexHumanoid.Mounted_Stand;
                        }
                        else
                        {
                            if (isSitting)
                            {
                                return (int)ActionIndexHumanoid.Sit;
                            }
                            else if (isWarMode)
                            {
                                // TODO: Also check if weapon type is 2h. Can be 1H or 2H
                                return (int)ActionIndexHumanoid.Stand_Warmode1H;
                            }
                            else
                            {
                                return (int)ActionIndexHumanoid.Stand;
                            }
                        }
                    case MobileAction.Death:
                        if (dieForwards)
                            return (int)ActionIndexHumanoid.Die_Backwards;
                        else
                            return (int)ActionIndexHumanoid.Die_Forwards;
                    case MobileAction.Attack:
                        if (isMounted)
                        {
                            // check weapon type. Can be 1H, Bow, or XBow
                            return (int)ActionIndexHumanoid.Mounted_Attack_1H;
                        }
                        else
                        {
                            // check weapon type. Can be 1H, 2H across, 2H down, 2H jab, bow, xbow, or unarmed.
                            return (int)ActionIndexHumanoid.Attack_1H;
                        }
                    case MobileAction.Cast_Directed:
                        if (isMounted)
                            return GetActionIndex(entity, MobileAction.Stand, index);
                        else
                            return (int)ActionIndexHumanoid.Cast_Directed;
                    case MobileAction.Cast_Area:
                        if (isMounted)
                            return GetActionIndex(entity, MobileAction.Stand, index);
                        else
                            return (int)ActionIndexHumanoid.Cast_Area;
                    case MobileAction.GetHit:
                        if (isMounted)
                            return GetActionIndex(entity, MobileAction.Stand, index);
                        else
                            return (int)ActionIndexHumanoid.Hit;
                    case MobileAction.Block:
                        if (isMounted)
                            return GetActionIndex(entity, MobileAction.Stand, index);
                        else
                            return (int)ActionIndexHumanoid.Block_WithShield;
                    case MobileAction.Emote_Fidget_1:
                        if (isMounted)
                            return GetActionIndex(entity, MobileAction.Stand, index);
                        else
                            return (int)ActionIndexHumanoid.Fidget_1;
                    case MobileAction.Emote_Fidget_2:
                        if (isMounted)
                            return GetActionIndex(entity, MobileAction.Stand, index);
                        else
                            return (int)ActionIndexHumanoid.Fidget_2;
                    case MobileAction.Emote_Bow:
                        if (isMounted)
                            return GetActionIndex(entity, MobileAction.Stand, index);
                        else
                            return (int)ActionIndexHumanoid.Emote_Bow;
                    case MobileAction.Emote_Salute:
                        if (isMounted)
                            return GetActionIndex(entity, MobileAction.Stand, index);
                        else
                            return (int)ActionIndexHumanoid.Emote_Salute;
                    case MobileAction.Emote_Eat:
                        if (isMounted)
                            return GetActionIndex(entity, MobileAction.Stand, index);
                        else
                            return (int)ActionIndexHumanoid.Emote_Eat;
                    default:
                        return (int)ActionIndexHumanoid.Walk;
                }
            }
            else if (body.IsAnimal)
            {
                switch (action)
                {
                    case MobileAction.None:
                        return GetActionIndex(entity, MobileAction.Stand, index);
                    case MobileAction.Walk:
                        return (int)ActionIndexAnimal.Walk;
                    case MobileAction.Run:
                        return (int)ActionIndexAnimal.Run;
                    case MobileAction.Stand:
                        return (int)ActionIndexAnimal.Stand;
                    case MobileAction.Death:
                        if (dieForwards)
                            return (int)ActionIndexAnimal.Die_Backwards;
                        else
                            return (int)ActionIndexAnimal.Die_Forwards;
                    case MobileAction.MonsterAction:
                        return index;
                    default:
                        return (int)ActionIndexHumanoid.Walk;
                }
            }
            else if (body.IsMonster)
            {
                switch (action)
                {
                    case MobileAction.None:
                        return GetActionIndex(entity, MobileAction.Stand, index);
                    case MobileAction.Walk:
                        return (int)ActionIndexMonster.Walk;
                    case MobileAction.Run:
                        return (int)ActionIndexMonster.Walk;
                    case MobileAction.Stand:
                        return (int)ActionIndexMonster.Stand;
                    case MobileAction.Death:
                        if (dieForwards)
                            return (int)ActionIndexMonster.Die_Backwards;
                        else
                            return (int)ActionIndexMonster.Die_Forwards;
                    case MobileAction.MonsterAction:
                        return index;
                    default:
                        return (int)ActionIndexHumanoid.Walk;
                }
            }

            return (int)ActionIndexHumanoid.Walk;
        }
Exemple #25
0
        private void animate(MobileAction action, int actionIndex, int repeatCount, bool reverse, bool repeat, int delay, bool isRequestedAction)
        {
            if (m_action == action)
            {
                if (m_IsAnimatationPaused)
                {
                    UnPauseAnimation();
                }
            }

            if (isRequestedAction)
                m_actionCanBeInteruptedByStand = true;

            if ((m_action != action) || (m_actionIndex != actionIndex))
            {
                // If we are switching from any action to a stand action, then hold the last frame of the
                // current animation for a moment. Only Stand actions are held; thus when any hold ends,
                // then we know we were holding for a Stand action.
                if (!(m_action == MobileAction.None) && (action == MobileAction.Stand && m_action != MobileAction.Stand))
                {
                    if (m_action != MobileAction.None)
                        PauseAnimation();
                }
                else
                {
                    m_action = action;
                    UnPauseAnimation();
                    m_actionIndex = actionIndex;
                    m_animationFrame = 0f;

                    // get the frames of the base body - we need to count the number of frames in this animation.
                    IResourceProvider provider = Service.Get<IResourceProvider>();
                    int body = Parent.Body, hue = 0;
                    AAnimationFrame[] frames = provider.GetAnimation(body, ref hue, actionIndex, (int)Parent.DrawFacing);
                    if (frames != null)
                    {
                        m_FrameCount = frames.Length;
                        m_FrameDelay = delay;
                        if (repeat == false)
                            m_repeatCount = 0;
                        else
                            m_repeatCount = repeatCount;
                    }
                }
            }
        }
Exemple #26
0
        public void Animate(MobileAction action)
        {
            int actionIndex = ActionTranslator.GetActionIndex(Parent, action);

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