public void PlayRenderEffect() { PlayRenderEffectMessage msg = RenderMessage.Create <PlayRenderEffectMessage>(); msg.ConstructAsPlay(GetOwnerEntityID(), m_render_effect_cfgid, FixPoint.MinusOne); GetLogicWorld().AddRenderMessage(msg); }
public void Impact() { m_remain_attack_cnt = m_combo_attack_cnt; if (m_combo_type_crc == ComboType_Time) { CreateOneObject(0); if (m_combo_attack_cnt > 1) { if (m_task == null) { m_task = LogicTask.Create <ComponentCommonTask>(); m_task.Construct(this); } var schedeler = GetLogicWorld().GetTaskScheduler(); schedeler.Schedule(m_task, GetCurrentTime(), m_combo_interval, m_combo_interval); } } else if (m_combo_type_crc == ComboType_Angle || m_combo_type_crc == ComboType_Circle) { for (int i = 0; i < m_combo_attack_cnt; ++i) { CreateOneObject(i); } } #if COMBAT_CLIENT if (m_render_effect_cfgid > 0) { PlayRenderEffectMessage msg = RenderMessage.Create <PlayRenderEffectMessage>(); msg.ConstructAsPlay(GetOwnerEntityID(), m_render_effect_cfgid, FixPoint.MinusOne); GetLogicWorld().AddRenderMessage(msg); } #endif }
void ChangeHealth(FixPoint delta_health, int source_id) { if (delta_health > 0) { if (m_current_health + delta_health > m_current_max_health) { delta_health = m_current_max_health - m_current_health; } } else { if (-delta_health > m_current_health) { delta_health = -m_current_health; } } if (delta_health == 0) { return; } m_current_health += delta_health; #if COMBAT_CLIENT ChangeHealthRenderMessage msg = RenderMessage.Create <ChangeHealthRenderMessage>(); msg.Construct(ParentObject.ID, delta_health, m_current_health); GetLogicWorld().AddRenderMessage(msg); #endif if (m_current_health <= 0) { EntityUtil.KillEntity(ParentObject as Entity, source_id); } }
bool Deactivate(bool force) { if (!m_is_active) { return(false); } m_definition_component.ClearTimer(SkillTimer.CastingTimer); m_definition_component.ClearTimer(SkillTimer.InflictingTimer); m_definition_component.ClearTimer(SkillTimer.ExpirationTimer); var enumerator = m_components.GetEnumerator(); while (enumerator.MoveNext()) { SkillComponent cmp = enumerator.Current.Value as SkillComponent; if (cmp != null) { cmp.Deactivate(force); } } SetSkillActive(false); #if COMBAT_CLIENT int render_effect_cfgid = m_definition_component.GetMainRenderEffectConfigID(); if (render_effect_cfgid > 0) { PlayRenderEffectMessage msg = RenderMessage.Create <PlayRenderEffectMessage>(); msg.ConstructAsStop(GetOwnerEntityID(), render_effect_cfgid); GetLogicWorld().AddRenderMessage(msg); } #endif return(true); }
public bool ChangeMana(int mana_type, FixPoint delta_mana) { if (delta_mana == FixPoint.Zero) { return(true); } FixPoint previous_mana = m_current_mana; m_current_mana += delta_mana; if (m_current_mana < FixPoint.Zero) { m_current_mana = FixPoint.Zero; } else if (m_current_mana > m_current_max_mana) { m_current_mana = m_current_max_mana; } delta_mana = m_current_mana - previous_mana; #if COMBAT_CLIENT ChangeManaRenderMessage msg = RenderMessage.Create <ChangeManaRenderMessage>(); msg.Construct(ParentObject.ID, mana_type, delta_mana, m_current_mana); GetLogicWorld().AddRenderMessage(msg); #endif return(true); }
public override void Apply() { if (m_task == null) { m_task = LogicTask.Create <ComponentCommonTaskWithLastingTime>(); } EffectDefinitionComponent definition_component = ((Effect)ParentObject).GetDefinitionComponent(); Entity entity = GetLogicWorld().GetEntityManager().GetObject(definition_component.SourceEntityID); if (entity != null) { PositionComponent position_component = entity.GetComponent(PositionComponent.ID) as PositionComponent; if (position_component != null) { m_direction = position_component.Facing3D; } } m_task.Construct(this, m_time); var schedeler = GetLogicWorld().GetTaskScheduler(); schedeler.Schedule(m_task, GetCurrentTime(), LOGIC_UPDATE_INTERVAL, LOGIC_UPDATE_INTERVAL); #if COMBAT_CLIENT LocomoteRenderMessage msg = RenderMessage.Create <LocomoteRenderMessage>(); msg.ConstructAsStartMoving(GetOwnerEntityID(), true, LocomoteRenderMessage.NotLocomotion); GetLogicWorld().AddRenderMessage(msg); #endif }
void SendChangeDirectionRenderMessage() { #if COMBAT_CLIENT ChangeDirectionRenderMessage msg = RenderMessage.Create <ChangeDirectionRenderMessage>(); msg.Construct(ParentObject.ID, m_base_angle, m_head_angle); GetLogicWorld().AddRenderMessage(msg); #endif }
protected override void OnActionUpdate(FixPoint delta_time) { #if COMBAT_CLIENT Skill skill = GetOwnerSkill(); PlaySoundMessage msg = RenderMessage.Create <PlaySoundMessage>(); msg.Construct(skill.GetOwnerEntityID(), m_sound, FixPoint.MinusOne); GetLogicWorld().AddRenderMessage(msg); #endif }
public override void ClearRunningTrace() { #if COMBAT_CLIENT Skill skill = GetOwnerSkill(); PlayRenderEffectMessage stop_msg = RenderMessage.Create <PlayRenderEffectMessage>(); stop_msg.ConstructAsStop(skill.GetOwnerEntityID(), m_render_effect_cfgid); GetLogicWorld().AddRenderMessage(stop_msg); #endif }
protected override void OnActionUpdate(FixPoint delta_time) { #if COMBAT_CLIENT Skill skill = GetOwnerSkill(); PlayRenderEffectMessage start_msg = RenderMessage.Create <PlayRenderEffectMessage>(); start_msg.ConstructAsPlay(skill.GetOwnerEntityID(), m_render_effect_cfgid, FixPoint.MinusOne); GetLogicWorld().AddRenderMessage(start_msg); #endif }
protected void OnMovementStopped(bool from_command) { ParentObject.SendSignal(SignalType.StopMoving); #if COMBAT_CLIENT LocomoteRenderMessage msg = RenderMessage.Create <LocomoteRenderMessage>(); msg.ConstructAsStopMoving(ParentObject.ID, IsAnimationBlocked, from_command ? 0 : LocomoteRenderMessage.NotFromCommand); GetLogicWorld().AddRenderMessage(msg); #endif }
public void Impact() { #if COMBAT_CLIENT if (m_render_effect_cfgid > 0) { if (m_remain_attack_cnt != m_combo_attack_cnt) { PlayRenderEffectMessage stop_msg = RenderMessage.Create <PlayRenderEffectMessage>(); stop_msg.ConstructAsStop(GetOwnerEntityID(), m_render_effect_cfgid); GetLogicWorld().AddRenderMessage(stop_msg); } PlayRenderEffectMessage start_msg = RenderMessage.Create <PlayRenderEffectMessage>(); start_msg.ConstructAsPlay(GetOwnerEntityID(), m_render_effect_cfgid, FixPoint.MinusOne); GetLogicWorld().AddRenderMessage(start_msg); } #endif --m_remain_attack_cnt; if (m_remain_attack_cnt <= 0) { if (m_combo_task != null) { m_combo_task.Cancel(); } } Skill skill = GetOwnerSkill(); if (!skill.GetDefinitionComponent().NeedGatherTargets) { skill.BuildSkillTargets(); } Entity attacker = GetOwnerEntity(); List <Target> targets = skill.GetTargets(); LogicWorld logic_world = GetLogicWorld(); for (int i = 0; i < targets.Count; ++i) { m_current_target = targets[i].GetEntity(logic_world); if (m_current_target == null) { continue; } DamagableComponent damageable_component = m_current_target.GetComponent(DamagableComponent.ID) as DamagableComponent; if (damageable_component == null) { continue; } Damage damage = RecyclableObject.Create <Damage>(); damage.m_attacker_id = attacker.ID; damage.m_defender_id = m_current_target.ID; damage.m_damage_type = m_damage_type_id; damage.m_damage_amount = m_damage_amount.Evaluate(this); damage.m_damage_amount = DamageSystem.Instance.CalculateDamageAmount(m_damage_type_id, damage.m_damage_amount, attacker, m_current_target); damage.m_render_effect_cfgid = m_damage_render_effect_cfgid; damage.m_sound_cfgid = m_damage_sound_cfgid; damageable_component.TakeDamage(damage); } m_current_target = null; }
public override void Unapply() { m_task.Cancel(); LogicTask.Recycle(m_task); m_task = null; #if COMBAT_CLIENT LocomoteRenderMessage msg = RenderMessage.Create <LocomoteRenderMessage>(); msg.ConstructAsStopMoving(GetOwnerEntityID(), false, LocomoteRenderMessage.NotFromCommand); GetLogicWorld().AddRenderMessage(msg); #endif }
public override void Apply() { #if COMBAT_CLIENT if (m_render_effect_cfgid > 0) { PlayRenderEffectMessage msg = RenderMessage.Create <PlayRenderEffectMessage>(); msg.ConstructAsPlay(GetOwnerEntityID(), m_render_effect_cfgid, FixPoint.MinusOne); GetLogicWorld().AddRenderMessage(msg); } #endif }
public void AddSimpleRenderMessage(int type, int entity_id = -1, int simple_data = 0) { if (m_render_messages == null) { return; } SimpleRenderMessage render_message = RenderMessage.Create <SimpleRenderMessage>(); render_message.Construct(type, entity_id, simple_data); m_render_messages.Add(render_message); }
public override void Unapply() { #if COMBAT_CLIENT if (m_render_effect_cfgid > 0) { PlayRenderEffectMessage stop_msg = RenderMessage.Create <PlayRenderEffectMessage>(); stop_msg.ConstructAsStop(GetOwnerEntityID(), m_render_effect_cfgid); GetLogicWorld().AddRenderMessage(stop_msg); } #endif }
public void UnblockAnimation() { --m_animation_block_cnt; #if COMBAT_CLIENT if (m_animation_block_cnt == 0 && m_is_moving) { LocomoteRenderMessage msg = RenderMessage.Create <LocomoteRenderMessage>(); msg.ConstructAsStartMoving(ParentObject.ID, IsAnimationBlocked, LocomoteRenderMessage.UnblockAnimation); GetLogicWorld().AddRenderMessage(msg); } #endif }
public override void Deactivate(bool force) { m_generator.Deactivate(); #if COMBAT_CLIENT if (m_render_effect_cfgid > 0) { PlayRenderEffectMessage stop_msg = RenderMessage.Create <PlayRenderEffectMessage>(); stop_msg.ConstructAsStop(GetOwnerEntityID(), m_render_effect_cfgid); GetLogicWorld().AddRenderMessage(stop_msg); } #endif }
protected override void OnActionUpdate(FixPoint delta_time) { LogicWorld logic_world = GetLogicWorld(); var schedeler = logic_world.GetTaskScheduler(); schedeler.Schedule(m_task, logic_world.GetCurrentTime(), LOGIC_UPDATE_INTERVAL, LOGIC_UPDATE_INTERVAL); m_remain_time = m_time; #if COMBAT_CLIENT Skill skill = GetOwnerSkill(); LocomoteRenderMessage msg = RenderMessage.Create <LocomoteRenderMessage>(); msg.ConstructAsStartMoving(skill.GetOwnerEntityID(), true, LocomoteRenderMessage.NotLocomotion); GetLogicWorld().AddRenderMessage(msg); #endif }
public void UpdateLocomotorSpeedRate() { DeleteLocomotorSpeedRateTask(); if (m_previous_max_speed == m_current_max_speed) { return; } m_previous_max_speed = m_current_max_speed; CalculateLocomotorSpeedrate(); #if COMBAT_CLIENT ChangeLocomotorSpeedRenderMessage msg = RenderMessage.Create <ChangeLocomotorSpeedRenderMessage>(); msg.Construct(ParentObject.ID, m_locomotor_speed_rate); GetLogicWorld().AddRenderMessage(msg); #endif }
void StopSpurt() { if (m_task == null) { return; } m_task.Cancel(); LogicTask.Recycle(m_task); m_task = null; #if COMBAT_CLIENT LocomoteRenderMessage msg = RenderMessage.Create <LocomoteRenderMessage>(); msg.ConstructAsStopMoving(GetOwnerEntityID(), false, LocomoteRenderMessage.NotFromCommand); GetLogicWorld().AddRenderMessage(msg); #endif }
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); }
void ActivateState(StateData data) { for (int i = 0; i < data.m_disable_componnets.Count; ++i) { Component component = ParentObject.GetComponent(data.m_disable_componnets[i]); if (component != null) { component.Disable(); } } #if COMBAT_CLIENT if (data.m_render_effect_cfgid > 0) { PlayRenderEffectMessage msg = RenderMessage.Create <PlayRenderEffectMessage>(); msg.ConstructAsPlay(GetOwnerEntityID(), data.m_render_effect_cfgid, FixPoint.MinusOne); GetLogicWorld().AddRenderMessage(msg); } #endif }
void StopSpurt() { if (m_collision_target_generator != null) { m_collision_target_generator.Deactivate(); } if (m_task != null) { m_task.Cancel(); } #if COMBAT_CLIENT Skill skill = GetOwnerSkill(); LocomoteRenderMessage msg = RenderMessage.Create <LocomoteRenderMessage>(); msg.ConstructAsStopMoving(skill.GetOwnerEntityID(), false, LocomoteRenderMessage.NotFromCommand); GetLogicWorld().AddRenderMessage(msg); #endif if (m_collided_targets != null) { m_collided_targets.Clear(); } m_remain_time = FixPoint.Zero; }
public override void Inflict(FixPoint start_time) { Skill owner_skill = GetOwnerSkill(); SkillDefinitionComponent definition_component = owner_skill.GetDefinitionComponent(); m_actual_distance = m_distance; if (m_distance == FixPoint.Zero) { if (definition_component.ExternalDataType == SkillDefinitionComponent.NeedExternalOffset) { m_actual_distance = definition_component.ExternalVector.Length(); } } m_actual_time = m_time; if (definition_component.NormalAttack) { m_actual_time = m_time / owner_skill.GetSkillManagerComponent().AttackSpeedRate; } if (m_task == null) { m_task = LogicTask.Create <ComponentCommonTaskWithLastingTime>(); } m_task.Construct(this, m_actual_time); var schedeler = GetLogicWorld().GetTaskScheduler(); schedeler.Schedule(m_task, GetCurrentTime(), LOGIC_UPDATE_INTERVAL, LOGIC_UPDATE_INTERVAL); #if COMBAT_CLIENT LocomoteRenderMessage msg = RenderMessage.Create <LocomoteRenderMessage>(); msg.ConstructAsStartMoving(GetOwnerEntityID(), true, LocomoteRenderMessage.NotLocomotion); GetLogicWorld().AddRenderMessage(msg); #endif if (m_enable_hide) { GetLogicWorld().AddSimpleRenderMessage(RenderMessageType.Hide, GetOwnerEntityID()); } }
public void TakeDamage(Damage damage) { if (ObjectUtil.IsDead(ParentObject)) { RecyclableObject.Recycle(damage); return; } if (damage.m_damage_amount < 0) { ChangeHealth(-damage.m_damage_amount, damage.m_attacker_id); RecyclableObject.Recycle(damage); return; } if (!IsEnable()) { RecyclableObject.Recycle(damage); return; } Entity attacker = GetLogicWorld().GetEntityManager().GetObject(damage.m_attacker_id); LastDamage = damage; FixPoint original_damage_amount = damage.m_damage_amount; FixPoint final_damage_amount = CalculateFinalDamageAmount(damage, attacker); ChangeHealth(-final_damage_amount, damage.m_attacker_id); ParentObject.SendSignal(SignalType.TakeDamage, damage); #if COMBAT_CLIENT TakeDamageRenderMessage msg = RenderMessage.Create <TakeDamageRenderMessage>(); msg.Construct(GetOwnerEntityID(), original_damage_amount, final_damage_amount, damage.m_render_effect_cfgid, damage.m_sound_cfgid); GetLogicWorld().AddRenderMessage(msg); #endif if (m_current_health <= 0) { ApplyExperience(attacker); } GetLogicWorld().OnCauseDamage(attacker, (Entity)ParentObject, damage); }
public void Teleport(SceneSpace space, Vector3FP new_position) { if (m_collision_sender) { if (space != m_current_space) { if (m_current_space != null) { m_current_space.m_paitition.RemoveEntity(this); } m_current_position = new_position; m_current_space = space; if (m_current_space != null) { m_current_space.m_paitition.AddEntiy(this); } } else { if (m_current_space != null) { m_current_space.m_paitition.UpdateEntity(this, new_position); } m_current_position = new_position; } } else { m_current_position = new_position; } #if COMBAT_CLIENT ChangePositionRenderMessage msg = RenderMessage.Create <ChangePositionRenderMessage>(); msg.Construct(GetOwnerEntityID(), new_position); GetLogicWorld().AddRenderMessage(msg); #endif }
public void AdjustPosition2Walkable() { GridGraph graph = null; if (m_current_space != null) { graph = m_current_space.m_graph; } else { graph = GetLogicWorld().GetDefaultSceneSpace().m_graph; } if (graph == null) { return; } CurrentPosition = graph.AdjustPosition2Walkable(m_current_position); #if COMBAT_CLIENT ChangePositionRenderMessage msg = RenderMessage.Create <ChangePositionRenderMessage>(); msg.Construct(GetOwnerEntityID(), m_current_position, true); GetLogicWorld().AddRenderMessage(msg); #endif }
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 }
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); }