void ProcessRenderMessage_PlayAnimation(PlayAnimationRenderMessage msg)
        {
            RenderEntity render_entity = m_render_entity_manager.GetObject(msg.EntityID);

            if (render_entity == null)
            {
                return;
            }
            AnimationComponent animation_component = render_entity.GetComponent(AnimationComponent.ID) as AnimationComponent;

            if (animation_component != null)
            {
                if (msg.m_animation_name_2 == null)
                {
                    animation_component.PlayerAnimation(msg.m_animation_name, msg.m_loop);
                }
                else
                {
                    animation_component.PlayerAnimation(msg.m_animation_name, false);
                    animation_component.QueueAnimation(msg.m_animation_name_2, msg.m_loop);
                }
                if (!msg.m_loop)
                {
                    animation_component.QueueAnimation(AnimationName.IDLE, true);
                }
            }
            AnimatorComponent animator_component = render_entity.GetComponent(AnimatorComponent.ID) as AnimatorComponent;

            if (animator_component != null)
            {
                animator_component.PlayAnimation(msg.m_animation_name);
            }
        }
Exemplo n.º 2
0
        protected override void OnActionUpdate(FixPoint delta_time)
        {
#if COMBAT_CLIENT
            Skill skill = GetOwnerSkill();
            PlayAnimationRenderMessage msg = RenderMessage.Create <PlayAnimationRenderMessage>();
            msg.Construct(skill.GetOwnerEntityID(), m_animation, m_next_animation, m_loop, FixPoint.One);
            GetLogicWorld().AddRenderMessage(msg);
#endif
        }
Exemplo n.º 3
0
        public bool Activate(FixPoint start_time)
        {
            if (!CanActivate(false))
            {
                return(false);
            }

            Deactivate(false);

            AdjustDirection();

            SetSkillActive(true);

            var enumerator = m_components.GetEnumerator();

            while (enumerator.MoveNext())
            {
                SkillComponent cmp = enumerator.Current.Value as SkillComponent;
                if (cmp != null)
                {
                    cmp.Activate(start_time);
                }
            }

            m_definition_component.ClearTimer(SkillTimer.ExpirationTimer);
            if (m_definition_component.CastingTime > FixPoint.Zero)
            {
                m_definition_component.StartCastingTimer(start_time, m_owner_component);
            }
            else
            {
                PostActivate(start_time);
            }

            ScheduleTimers();

#if COMBAT_CLIENT
            if (m_definition_component.m_casting_animation != null)
            {
                PlayAnimationRenderMessage msg = RenderMessage.Create <PlayAnimationRenderMessage>();
                FixPoint speed = m_definition_component.NormalAttack ? m_owner_component.AttackSpeedRate : FixPoint.One;
                msg.Construct(GetOwnerEntityID(), m_definition_component.m_casting_animation, null, true, speed);
                GetLogicWorld().AddRenderMessage(msg);
            }
#endif
            return(true);
        }
        public void OnSkillDeactivated(Skill skill)
        {
            SkillDefinitionComponent def_cmp = skill.GetDefinitionComponent();

            if (def_cmp.StartsActive)
            {
                return;
            }
            bool play_idle_animation = true;

            if (def_cmp.BlocksMovementWhenActive)
            {
                --m_move_block_count;
                if (m_move_block_count == 0)
                {
                    if (m_locomotor_cmp != null)
                    {
                        m_locomotor_cmp.Enable();
                    }
                }
            }
            else
            {
                if (def_cmp.BlocksRotatingWhenActive)
                {
                    PositionComponent position_component = skill.GetOwnerEntity().GetComponent(PositionComponent.ID) as PositionComponent;
                    if (position_component != null)
                    {
                        position_component.EnableRotating();
                    }
                    if (m_locomotor_cmp != null && m_locomotor_cmp.IsMoving)
                    {
                        position_component.SetFacing(m_locomotor_cmp.GetMovementProvider().GetCurrentDirection());
                    }
                }
                if (def_cmp.DeactivateWhenMoving)
                {
                }
                else
                {
                    if (def_cmp.m_main_animation != null && m_locomotor_cmp != null)
                    {
                        m_locomotor_cmp.UnblockAnimation();
                        play_idle_animation = false;
                    }
                }
            }
            if (def_cmp.BlocksOtherSkillsWhenActive)
            {
                --m_active_block_count;
            }
            m_active_skill_ids.Remove(skill.ID);

#if COMBAT_CLIENT
            if (play_idle_animation && def_cmp.m_main_animation != null)
            {
                PlayAnimationRenderMessage msg = RenderMessage.Create <PlayAnimationRenderMessage>();
                msg.Construct(GetOwnerEntityID(), AnimationName.IDLE, null, true, FixPoint.One);
                GetLogicWorld().AddRenderMessage(msg);
            }
#endif
        }
Exemplo n.º 5
0
        bool PostActivate(FixPoint start_time)
        {
            if (m_definition_component.NeedGatherTargets)
            {
                BuildSkillTargets();
                if (!CheckTargetRange())
                {
                    Deactivate(false);
                    return(false);
                }
            }

            FixPoint mana_cost = m_definition_component.ManaCost;

            if (mana_cost > FixPoint.Zero)
            {
                if (!m_mana_component.ChangeMana(m_definition_component.ManaType, -mana_cost))
                {
                    Deactivate(false);
                    return(false);
                }
            }

            var enumerator = m_components.GetEnumerator();

            while (enumerator.MoveNext())
            {
                SkillComponent cmp = enumerator.Current.Value as SkillComponent;
                if (cmp != null)
                {
                    cmp.PostActivate(start_time);
                }
            }

            m_definition_component.StartCooldownTimer(start_time, m_owner_component);

            if (m_definition_component.InflictTime > FixPoint.Zero)
            {
                m_definition_component.StartInflictingTimer(start_time, m_owner_component);
            }
            else
            {
                Inflict(start_time);
            }

            if (m_definition_component.NormalAttack)
            {
                GetOwnerEntity().SendSignal(SignalType.CastNormalAttack);
            }
            else if (!m_definition_component.StartsActive)
            {
                GetOwnerEntity().SendSignal(SignalType.CastSkill);
            }

            string main_animation = m_definition_component.GenerateMainActionNameLogicly();

#if COMBAT_CLIENT
            if (main_animation != null)
            {
                PlayAnimationRenderMessage msg = RenderMessage.Create <PlayAnimationRenderMessage>();
                FixPoint speed = m_definition_component.NormalAttack ? m_owner_component.AttackSpeedRate : FixPoint.One;
                if (m_definition_component.m_expiration_animation == null)
                {
                    msg.Construct(GetOwnerEntityID(), main_animation, AnimationName.IDLE, true, speed);
                }
                else
                {
                    msg.Construct(GetOwnerEntityID(), main_animation, m_definition_component.m_expiration_animation, true, speed);
                }
                GetLogicWorld().AddRenderMessage(msg);
            }
            int render_effect_cfgid = m_definition_component.GetMainRenderEffectConfigID();
            if (render_effect_cfgid > 0)
            {
                PlayRenderEffectMessage msg = RenderMessage.Create <PlayRenderEffectMessage>();
                msg.ConstructAsPlay(GetOwnerEntityID(), render_effect_cfgid, FixPoint.MinusOne);
                GetLogicWorld().AddRenderMessage(msg);
            }
            if (m_definition_component.m_main_sound > 0)
            {
                PlaySoundMessage msg = RenderMessage.Create <PlaySoundMessage>();
                msg.Construct(GetOwnerEntityID(), m_definition_component.m_main_sound, FixPoint.MinusOne);
                GetLogicWorld().AddRenderMessage(msg);
            }
#endif
            return(true);
        }