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 ProcessRenderMessage_ChangeHealth(ChangeHealthRenderMessage msg) { RenderEntity render_entity = m_render_entity_manager.GetObject(msg.EntityID); if (render_entity == null) { return; } }
void ProcessRenderMessage_Show(int entity_id) { RenderEntity render_entity = m_render_entity_manager.GetObject(entity_id); if (render_entity == null) { return; } render_entity.Hide = false; }
void ProcessRenderMessage_TakeDamage(TakeDamageRenderMessage msg) { RenderEntity render_entity = m_render_entity_manager.GetObject(msg.EntityID); if (render_entity == null) { return; } //ZZWTODO }
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_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); } }
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); } }
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); }
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); }
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(); } }
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(); }
public virtual bool OnEntityOutOfEdge(RenderEntity render_entity) { return(false); }
void UpdateKeyboardEvent() { if (m_current_operate_entityi_id < 0) { return; } int old_state = m_wsad_state; if (Input.GetKeyDown(KeyCode.W)) { m_wsad_state |= W_STATE; } if (Input.GetKeyDown(KeyCode.S)) { m_wsad_state |= S_STATE; } if (Input.GetKeyDown(KeyCode.A)) { m_wsad_state |= A_STATE; } if (Input.GetKeyDown(KeyCode.D)) { m_wsad_state |= D_STATE; } if (Input.GetKeyUp(KeyCode.W)) { m_wsad_state &= ~W_STATE; } if (Input.GetKeyUp(KeyCode.S)) { m_wsad_state &= ~S_STATE; } if (Input.GetKeyUp(KeyCode.A)) { m_wsad_state &= ~A_STATE; } if (Input.GetKeyUp(KeyCode.D)) { m_wsad_state &= ~D_STATE; } if (m_wsad_state == old_state) { return; } if (m_wsad_state == 0) { EntityMoveCommand cmd = Command.Create <EntityMoveCommand>(); cmd.ConstructAsStopMove(m_current_operate_entityi_id); PushLocalCommand(cmd); } else { RenderEntity render_entity = m_render_entity_manager.GetObject(m_current_operate_entityi_id); if (render_entity == null) { return; } m_direction.MakeZero(); if ((m_wsad_state & W_STATE) != 0) { m_direction.z += FixPoint.One; } if ((m_wsad_state & S_STATE) != 0) { m_direction.z -= FixPoint.One; } if ((m_wsad_state & A_STATE) != 0) { m_direction.x -= FixPoint.One; } if ((m_wsad_state & D_STATE) != 0) { m_direction.x += FixPoint.One; } m_direction.Normalize(); EntityMoveCommand cmd = Command.Create <EntityMoveCommand>(); cmd.ConstructAsDirection(m_current_operate_entityi_id, m_direction); PushLocalCommand(cmd); } }
void OnPick(RaycastHit hit) { GameObject go = hit.transform.gameObject; UnityObjectBinding binding = go.GetComponent <UnityObjectBinding>(); if (binding == null) { Debug.Log("RenderWorld.OnPick(), YOU CHOOSE A POINT" + hit.point.ToString()); if (m_current_operate_entityi_id < 0) { return; } RenderEntity render_entity = m_render_entity_manager.GetObject(m_current_operate_entityi_id); if (render_entity == null) { return; } LocomotorComponent locomotor_component = render_entity.GetLogicEntity().GetComponent(LocomotorComponent.ID) as LocomotorComponent; if (locomotor_component == null || !locomotor_component.IsEnable()) { return; } EntityMoveCommand cmd = Command.Create <EntityMoveCommand>(); cmd.ConstructAsDestination(m_current_operate_entityi_id, Vector3_To_Vector3FP(hit.point)); PushLocalCommand(cmd); #if UNITY_EDITOR if (m_draw_grid && m_grid_graph != null) { PositionComponent position_component = render_entity.GetLogicEntity().GetComponent(PositionComponent.ID) as PositionComponent; if (!m_grid_graph.FindPath(position_component.CurrentPosition, Vector3_To_Vector3FP(hit.point))) { Debug.LogError("FindPath Failed!"); } else { List <Vector3FP> path = m_grid_graph.GetPath(); m_current_path.Clear(); for (int i = 0; i < path.Count; ++i) { m_current_path.Add(Vector3FP_To_Vector3(path[i])); } } } #endif } else { RenderEntity render_entity = m_render_entity_manager.GetObject(binding.EntityID); if (render_entity == null) { return; } if (m_combat_client.LocalPlayerPstid == m_logic_world.GetPlayerManager().Objectid2Pstid(render_entity.GetOwnerPlayerID())) { m_current_operate_entityi_id = binding.EntityID; Debug.Log("RenderWorld.OnPick(), YOU CHOOSE YOUR ENTITY " + hit.transform.parent.name); } else { Debug.Log("RenderWorld.OnPick(), YOU CHOOSE AN ENEMY " + hit.transform.parent.name); if (m_current_operate_entityi_id < 0) { return; } EntityTargetCommand cmd = Command.Create <EntityTargetCommand>(); cmd.Construct(m_current_operate_entityi_id, render_entity.ID); PushLocalCommand(cmd); #if UNITY_EDITOR if (m_draw_grid && m_grid_graph != null) { RenderEntity self_entity = m_render_entity_manager.GetObject(m_current_operate_entityi_id); PositionComponent self_position_component = self_entity.GetLogicEntity().GetComponent(PositionComponent.ID) as PositionComponent; PositionComponent target_position_component = render_entity.GetLogicEntity().GetComponent(PositionComponent.ID) as PositionComponent; if (!m_grid_graph.FindPath(self_position_component.CurrentPosition, target_position_component.CurrentPosition)) { Debug.LogError("FindPath Failed!"); } else { List <Vector3FP> path = m_grid_graph.GetPath(); m_current_path.Clear(); for (int i = 0; i < path.Count; ++i) { m_current_path.Add(Vector3FP_To_Vector3(path[i])); } } } #endif } } }