Ejemplo n.º 1
0
 protected override void OnDestruct()
 {
     m_owner_component      = null;
     m_mana_component       = null;
     m_definition_component = null;
     ClearTargets();
 }
        public void OnSkillActivated(Skill skill)
        {
            SkillDefinitionComponent def_cmp = skill.GetDefinitionComponent();

            if (def_cmp.StartsActive)
            {
                return;
            }
            if (def_cmp.BlocksMovementWhenActive)
            {
                ++m_move_block_count;
                if (m_move_block_count == 1)
                {
                    if (m_locomotor_cmp != null)
                    {
                        m_locomotor_cmp.Disable();
                    }
                }
            }
            else
            {
                if (def_cmp.BlocksRotatingWhenActive)
                {
                    PositionComponent position_component = skill.GetOwnerEntity().GetComponent(PositionComponent.ID) as PositionComponent;
                    if (position_component != null)
                    {
                        position_component.DisableRotating();
                    }
                }
                if (def_cmp.DeactivateWhenMoving)
                {
                    if (m_locomotor_cmp != null)
                    {
                        m_locomotor_cmp.StopMoving();
                    }
                }
                else
                {
                    if (def_cmp.m_main_animation != null && m_locomotor_cmp != null)
                    {
                        m_locomotor_cmp.BlockAnimation();
                    }
                }
            }
            if (def_cmp.BlocksOtherSkillsWhenActive)
            {
                ++m_active_block_count;
            }
            m_active_skill_ids.Add(skill.ID);
        }
        void OnMovementStart()
        {
            SkillManager skill_manager = GetLogicWorld().GetSkillManager();

            for (int i = 0; i < m_active_skill_ids.Count; ++i)
            {
                Skill skill = skill_manager.GetObject(m_active_skill_ids[i]);
                if (skill != null)
                {
                    SkillDefinitionComponent def_cmp = skill.GetDefinitionComponent();
                    if (def_cmp.DeactivateWhenMoving)
                    {
                        m_skill_to_interrupt.Add(skill);
                    }
                }
            }
            for (int i = 0; i < m_skill_to_interrupt.Count; ++i)
            {
                m_skill_to_interrupt[i].Interrupt();
            }
            m_skill_to_interrupt.Clear();
        }
Ejemplo n.º 4
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());
            }
        }
        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
        }
        void CreateOneObject(int index)
        {
            --m_remain_attack_cnt;
            Entity owner_entity      = GetOwnerEntity();
            Skill  owner_skill       = GetOwnerSkill();
            Target projectile_target = null;

            if (!m_ignore_target)
            {
                projectile_target = owner_skill.GetMajorTarget();
            }
            Vector3FP position_offset = m_offset;
            FixPoint  angle_offset    = FixPoint.Zero;

            if (m_combo_type_crc == ComboType_Angle)
            {
                if (m_combo_attack_cnt % 2 == 1)
                {
                    angle_offset = m_combo_interval * (FixPoint)((index + 1) / 2);
                    if (index % 2 != 0)
                    {
                        angle_offset = -angle_offset;
                    }
                }
                else
                {
                    angle_offset = m_combo_interval * ((FixPoint)(index / 2) + FixPoint.Half);
                    if (index % 2 != 0)
                    {
                        angle_offset = -angle_offset;
                    }
                }
            }
            else if (m_combo_type_crc == ComboType_Circle)
            {
                if (m_combo_interval == FixPoint.Zero)
                {
                    FixPoint rotate_radian = FixPoint.TwoPi / (FixPoint)m_combo_attack_cnt * (FixPoint)index;
                    position_offset = position_offset.YRotate(rotate_radian);
                }
                else
                {
                    if (m_combo_attack_cnt % 2 == 1)
                    {
                        angle_offset = m_combo_interval * (FixPoint)((index + 1) / 2);
                        if (index % 2 != 0)
                        {
                            angle_offset = -angle_offset;
                        }
                    }
                    else
                    {
                        angle_offset = m_combo_interval * ((FixPoint)(index / 2) + FixPoint.Half);
                        if (index % 2 != 0)
                        {
                            angle_offset = -angle_offset;
                        }
                    }
                    FixPoint rotate_radian = FixPoint.Degree2Radian(angle_offset);
                    position_offset = position_offset.YRotate(rotate_radian);
                    angle_offset    = FixPoint.Zero;
                }
            }

            if (projectile_target == null && !m_ignore_target)
            {
                SkillDefinitionComponent definition_component = owner_skill.GetDefinitionComponent();
                if (definition_component.ExternalDataType == SkillDefinitionComponent.NeedExternalOffset)
                {
                    position_offset.z = definition_component.ExternalVector.Length();
                }
            }

            EntityUtil.CreateEntityForSkillAndEffect(this, owner_entity, projectile_target, position_offset, angle_offset, m_object_type_id, m_object_proto_id, m_object_life_time, m_generator);
        }
Ejemplo n.º 7
0
 protected override void PostInitializeObject(ObjectCreationContext context)
 {
     m_definition_component = GetComponent(SkillDefinitionComponent.ID) as SkillDefinitionComponent;
 }