Beispiel #1
0
        public void OnEntityEnter(int entity_id)
        {
            Entity owner = GetOwnerEntity();

            if (ObjectUtil.IsDead(owner))
            {
                return;
            }
            if (m_enter_generator == null)
            {
                return;
            }
            Entity entity = GetLogicWorld().GetEntityManager().GetObject(entity_id);

            if (entity == null)
            {
                return;
            }
            if (ObjectUtil.IsDead(entity))
            {
                return;
            }
            EffectApplicationData app_data = RecyclableObject.Create <EffectApplicationData>();

            app_data.m_original_entity_id = ParentObject.ID;
            app_data.m_source_entity_id   = ParentObject.ID;
            m_enter_generator.Activate(app_data, entity);
            RecyclableObject.Recycle(app_data);
        }
Beispiel #2
0
        public void OnEntityExit(int entity_id)
        {
            Entity owner = GetOwnerEntity();

            if (ObjectUtil.IsDead(owner))
            {
                return;
            }
            if (m_enter_generator == null)
            {
                return;
            }
            Entity entity = GetLogicWorld().GetEntityManager().GetObject(entity_id);

            if (entity == null)
            {
                return;
            }
            m_enter_generator.DeactivateOnOneTarget(entity);
        }
Beispiel #3
0
        public override void Apply()
        {
            Entity target = GetOwnerEntity();

            if (target == null)
            {
                return;
            }
            if (ObjectUtil.IsDead(target))
            {
                return;
            }
            StateComponent state_component = target.GetComponent(StateComponent.ID) as StateComponent;

            if (state_component == null)
            {
                return;
            }
            state_component.AddState(m_state, ParentObject.ID);
        }
 public void StartTargeting(Entity target, int skill_index = SkillManagerComponent.DEFAULT_SKILL_INDEX)
 {
     if (!IsEnable())
     {
         return;
     }
     if (m_current_target != null && target.ID == m_current_target.ID)
     {
         return;
     }
     if (ObjectUtil.IsDead(target))
     {
         return;
     }
     StopTargeting();
     m_current_target = target;
     m_skill_index    = skill_index;
     target.AddListener(SignalType.Die, m_listener_context);
     ScheduleTargeting(FixPoint.Zero);
 }
        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 bool UpdateProjectile(FixPoint delta_time)
        {
            PositionComponent position_component = ParentObject.GetComponent(PositionComponent.ID) as PositionComponent;

            if (m_track_mode == TrackModeLockTarget)
            {
                Entity            target = null;
                PositionComponent target_position_component = null;
                if (m_param.m_target_entity_id > 0)
                {
                    target = GetLogicWorld().GetEntityManager().GetObject(m_param.m_target_entity_id);
                    if (target != null && !ObjectUtil.IsDead(target))
                    {
                        target_position_component = target.GetComponent(PositionComponent.ID) as PositionComponent;
                        if (target_position_component != null)
                        {
                            m_param.m_target_position = target_position_component.CurrentPosition;
                        }
                    }
                    else
                    {
                        target = null;
                    }
                }
                if (m_trajectory_type == TrajectoryTypeBezier)
                {
                    FixPoint t = (GetCurrentTime() - m_param.m_start_time) / m_param.m_life_time;
                    if (t < FixPoint.One)
                    {
                        FixPoint  l_t          = FixPoint.One - t;
                        Vector3FP new_position = l_t * l_t * m_param.m_start_position + FixPoint.Two * t * l_t * m_param.m_bezier_b + t * t * m_param.m_target_position;
                        position_component.CurrentPosition = new_position;
                        return(false);
                    }
                    else
                    {
                        position_component.CurrentPosition = m_param.m_target_position;
                        Explode(target);
                        return(true);
                    }
                }
                else
                {
                    m_param.m_fixed_facing = m_param.m_target_position - position_component.CurrentPosition;
                    if (m_trajectory_type == TrajectoryTypeHorizontalLine)
                    {
                        m_param.m_fixed_facing.y = FixPoint.Zero;
                    }
                    FixPoint  distance       = m_param.m_fixed_facing.Normalize();
                    FixPoint  delta_distance = m_speed * delta_time;
                    Vector3FP new_position   = position_component.CurrentPosition + m_param.m_fixed_facing * delta_distance;
                    position_component.CurrentPosition = new_position;
                    distance = FixPoint.Abs(distance - delta_distance);
                    bool hit = false;
                    if (target_position_component != null)
                    {
                        if (distance <= position_component.Radius + target_position_component.Radius)
                        {
                            hit = true;
                        }
                    }
                    else
                    {
                        if (distance <= m_speed * LOGIC_UPDATE_INTERVAL)
                        {
                            hit = true;
                        }
                    }
                    if (hit)
                    {
                        Explode(target);
                        return(true);
                    }
                    return(false);
                }
            }
            else
            {
                Vector3FP new_position = position_component.CurrentPosition + m_param.m_fixed_facing * (m_speed * delta_time);
                position_component.CurrentPosition = new_position;
                if (DetectCollision(position_component.GetSpacePartition(), new_position, position_component.Radius))
                {
                    return(true);
                }
                GridGraph grid_graph = position_component.GetGridGraph();
                if (grid_graph != null)
                {
                    GridNode node = grid_graph.Position2Node(new_position);
                    if (node == null)
                    {
                        m_task.LockRemainTime(m_speed);
                    }
                    else if (!node.Walkable && !m_can_cross_obstacle)
                    {
                        if (m_previous_walkable)
                        {
                            m_task.LockRemainTime(m_speed);
                        }
                    }
                    else
                    {
                        m_previous_walkable = true;
                    }
                }
                return(false);
            }
        }