Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public void Explode(Entity entity)
        {
#if COMBAT_CLIENT
            if (m_collision_sound_cfgid > 0)
            {
                PlaySoundMessage sound_msg = RenderMessage.Create <PlaySoundMessage>();
                sound_msg.Construct(GetOwnerEntityID(), m_collision_sound_cfgid, FixPoint.MinusOne);
                GetLogicWorld().AddRenderMessage(sound_msg);
            }
#endif

            ApplyGenerator(entity);

            if (entity == null || !m_pierce_entity)
            {
#if COMBAT_CLIENT
                LocomoteRenderMessage msg = RenderMessage.Create <LocomoteRenderMessage>();
                msg.ConstructAsStopMoving(ParentObject.ID, true);
                GetLogicWorld().AddRenderMessage(msg);
#endif
                if (m_task != null)
                {
                    m_task.Cancel();
                    LogicTask.Recycle(m_task);
                    m_task = null;
                }
                EntityUtil.KillEntity((Entity)ParentObject, ParentObject.ID);
            }
        }
Ejemplo n.º 3
0
        public void InitParam(ProjectileParameters param)
        {
            m_param = param;
            if (m_trajectory_type == TrajectoryTypeBezier)
            {
                m_param.m_bezier_b    = (m_param.m_start_position + m_param.m_target_position) / FixPoint.Two;
                m_param.m_bezier_b.y += m_extra_hight;
            }
            if (m_param.m_life_time <= FixPoint.Zero)
            {
                m_param.m_life_time = m_life_time;
            }

            PositionComponent position_component = ParentObject.GetComponent(PositionComponent.ID) as PositionComponent;
            GridGraph         grid_graph         = position_component.GetGridGraph();
            GridNode          node = grid_graph.Position2Node(position_component.CurrentPosition);

            m_previous_walkable = (node != null && node.Walkable);

            if (m_task == null)
            {
                m_task = LogicTask.Create <UpdateProjectileTask>();
            }
            m_task.Construct(this, m_param.m_life_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(ParentObject.ID, true);
            GetLogicWorld().AddRenderMessage(msg);
#endif
        }
Ejemplo n.º 4
0
        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);
            }
        }
        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
        }
Ejemplo n.º 6
0
        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 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
        }
        public void PlayRenderEffect()
        {
            PlayRenderEffectMessage msg = RenderMessage.Create <PlayRenderEffectMessage>();

            msg.ConstructAsPlay(GetOwnerEntityID(), m_render_effect_cfgid, FixPoint.MinusOne);
            GetLogicWorld().AddRenderMessage(msg);
        }
Ejemplo n.º 9
0
        void SendChangeDirectionRenderMessage()
        {
#if COMBAT_CLIENT
            ChangeDirectionRenderMessage msg = RenderMessage.Create <ChangeDirectionRenderMessage>();
            msg.Construct(ParentObject.ID, m_base_angle, m_head_angle);
            GetLogicWorld().AddRenderMessage(msg);
#endif
        }
Ejemplo n.º 10
0
 public void AddRenderMessage(RenderMessage render_message)
 {
     if (m_render_messages == null)
     {
         return;
     }
     m_render_messages.Add(render_message);
 }
Ejemplo n.º 11
0
        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
        }
Ejemplo n.º 12
0
        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
        }
Ejemplo n.º 13
0
        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
        }
Ejemplo n.º 14
0
        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
        }
Ejemplo n.º 15
0
        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
        }
Ejemplo n.º 18
0
        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
        }
Ejemplo n.º 20
0
        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
        }
Ejemplo n.º 22
0
        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
        }
Ejemplo n.º 23
0
        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
        }
Ejemplo n.º 24
0
        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
        }
Ejemplo n.º 25
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);
        }
Ejemplo n.º 26
0
        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
        }
Ejemplo n.º 27
0
        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;
        }
Ejemplo n.º 28
0
        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());
            }
        }
Ejemplo n.º 29
0
        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);
        }
Ejemplo n.º 30
0
        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
        }