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);
            }
        }
        void ProcessRenderMessage_StopMoving(LocomoteRenderMessage msg)
        {
            RenderEntity render_entity = m_render_entity_manager.GetObject(msg.EntityID);

            if (render_entity == null)
            {
                return;
            }
            ModelComponent model_component = render_entity.GetComponent(ModelComponent.ID) as ModelComponent;

            if (model_component == null)
            {
                return;
            }
            m_render_world.UnregisterMovingEntity(model_component);
            if (msg.m_block_animation)
            {
                return;
            }
            PredictLogicComponent predic_component = render_entity.GetComponent(PredictLogicComponent.ID) as PredictLogicComponent;

            if (msg.m_reason == LocomoteRenderMessage.NotFromCommand || predic_component == null || !predic_component.HasMovementPredict)
            {
                PlayIdleAnimation(render_entity);
            }
        }
        void ProcessRenderMessage_ChangePosition(ChangePositionRenderMessage msg)
        {
            RenderEntity render_entity = m_render_entity_manager.GetObject(msg.EntityID);

            if (render_entity == null)
            {
                return;
            }
            PredictLogicComponent predic_component = render_entity.GetComponent(PredictLogicComponent.ID) as PredictLogicComponent;

            if (predic_component != null)
            {
                if (msg.m_micro_adjusting && predic_component.HasMovementPredict)
                {
                    return;
                }
                else
                {
                    predic_component.ClearAllPrediction();
                }
            }
            ModelComponent model_component = render_entity.GetComponent <ModelComponent>();

            if (model_component == null)
            {
                return;
            }
            model_component.UpdatePosition();
        }
        void PlayIdleAnimation(RenderEntity render_entity)
        {
            AnimationComponent animation_component = render_entity.GetComponent(AnimationComponent.ID) as AnimationComponent;

            if (animation_component != null)
            {
                animation_component.PlayerAnimation(AnimationName.IDLE, true);
            }
            AnimatorComponent animator_component = render_entity.GetComponent(AnimatorComponent.ID) as AnimatorComponent;

            if (animator_component != null)
            {
                animator_component.PlayAnimation(AnimationName.IDLE);
            }
        }
        void PlayLocomotorAnimation(RenderEntity render_entity)
        {
            AnimationComponent animation_component = render_entity.GetComponent(AnimationComponent.ID) as AnimationComponent;

            if (animation_component != null)
            {
                animation_component.PlayerAnimation(animation_component.LocomotorAnimationName, true);
            }
            AnimatorComponent animator_component = render_entity.GetComponent(AnimatorComponent.ID) as AnimatorComponent;

            if (animator_component != null)
            {
                animator_component.PlayAnimation(animator_component.LocomotorAnimationName);
            }
        }
        void ProcessRenderMessage_StartMoving(LocomoteRenderMessage msg)
        {
            RenderEntity render_entity = m_render_entity_manager.GetObject(msg.EntityID);

            if (render_entity == null)
            {
                return;
            }
            ModelComponent model_component = render_entity.GetComponent(ModelComponent.ID) as ModelComponent;

            if (model_component == null)
            {
                return;
            }
            m_render_world.RegisterMovingEntity(model_component);
            PredictLogicComponent predic_component = render_entity.GetComponent(PredictLogicComponent.ID) as PredictLogicComponent;

            if (msg.m_reason == LocomoteRenderMessage.NotLocomotion || msg.m_block_animation)
            {
                model_component.UpdateAngle();
                if (predic_component != null)
                {
                    predic_component.OnLogicMove();
                }
            }
            else if (msg.m_reason == LocomoteRenderMessage.NotFromCommand)
            {
                model_component.UpdateAngle();
                PlayLocomotorAnimation(render_entity);
                if (predic_component != null)
                {
                    predic_component.OnLogicMove();
                }
            }
            else if (msg.m_reason == LocomoteRenderMessage.UnblockAnimation)
            {
                model_component.UpdateAngle();
                PlayLocomotorAnimation(render_entity);
            }
            else if (predic_component == null || !predic_component.HasMovementPredict)
            {
                model_component.UpdateAngle();
                PlayLocomotorAnimation(render_entity);
            }
        }
        void ProcessRenderMessage_ChangeLocomotorSpeed(ChangeLocomotorSpeedRenderMessage msg)
        {
            RenderEntity render_entity = m_render_entity_manager.GetObject(msg.EntityID);

            if (render_entity == null)
            {
                return;
            }
            AnimationComponent animation_component = render_entity.GetComponent <AnimationComponent>();

            if (animation_component != null)
            {
                animation_component.LocomotorAnimationSpeed = (float)msg.m_animation_rate;
            }
            AnimatorComponent animator_component = render_entity.GetComponent <AnimatorComponent>();

            if (animator_component != null)
            {
                animator_component.LocomotorAnimationSpeed = (float)msg.m_animation_rate;
            }
        }
        void ProcessRenderMessage_ChangeDirection(ChangeDirectionRenderMessage msg)
        {
            //ZZWTODO 移动动作和朝向
            RenderEntity render_entity = m_render_entity_manager.GetObject(msg.EntityID);

            if (render_entity == null)
            {
                return;
            }
            PredictLogicComponent predic_component = render_entity.GetComponent(PredictLogicComponent.ID) as PredictLogicComponent;

            if (predic_component != null && predic_component.HasMovementPredict)
            {
                return;
            }
            ModelComponent model_component = render_entity.GetComponent(ModelComponent.ID) as ModelComponent;

            if (model_component == null)
            {
                return;
            }
            model_component.UpdateAngle();
        }
        void ProcessRenderMessage_Die(int entity_id)
        {
            RenderEntity render_entity = m_render_entity_manager.GetObject(entity_id);

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

            if (animation_component != null)
            {
                animation_component.PlayerAnimation(AnimationName.DIE);
            }
        }
Пример #10
0
        public virtual void OnLogicWorldHandleCommand(Command cmd, bool result)
        {
            RenderEntity render_entity = m_render_entity_manager.GetObject(cmd.m_entity_id);

            if (render_entity == null)
            {
                return;
            }
            PredictLogicComponent predict_logic_component = render_entity.GetComponent(PredictLogicComponent.ID) as PredictLogicComponent;

            if (predict_logic_component == null)
            {
                return;
            }
            predict_logic_component.ConfirmCommand(cmd, result);
        }
Пример #11
0
        protected virtual void PredictCommand(Command cmd)
        {
            RenderEntity render_entity = m_render_entity_manager.GetObject(cmd.m_entity_id);

            if (render_entity == null)
            {
                return;
            }
            PredictLogicComponent predict_logic_component = render_entity.GetComponent(PredictLogicComponent.ID) as PredictLogicComponent;

            if (predict_logic_component == null)
            {
                return;
            }
            predict_logic_component.PredictCommand(cmd);
        }
        void ProcessRenderMessage_Hide(int entity_id)
        {
            RenderEntity render_entity = m_render_entity_manager.GetObject(entity_id);

            if (render_entity == null)
            {
                return;
            }
            render_entity.Hide = true;
            PredictLogicComponent predict_component = render_entity.GetComponent <PredictLogicComponent>();

            if (predict_component != null)
            {
                predict_component.ClearAllPrediction();
            }
        }