Ejemplo n.º 1
0
    public override void Execute(CharacterMono speller, Vector3 position)
    {
        base.Execute(speller, position);

        //========================================
        // 为延迟技能(只能对非指向型技能)增加监听事件
        for (int i = 0; i < ActiveSkills.Count(); i++)
        {
            var skill          = ActiveSkills[i];
            var delayAttribute = SkillDelayAttributes[i];
            if (delayAttribute.isDelay && !skill.IsMustDesignation)
            {
                var activeSkill = ActiveSkills[delayAttribute.index];
                if (!activeSkill.IsMustDesignation)
                {
                    OnSkillCompeleteHandler delayExcute = null;
                    delayExcute = () => {
                        skill.Execute(speller, position);
                    };
                    activeSkill.OnCompelte += delayExcute;
                }
            }
        }



        // 首先遍历技能组,释放该技能组中的所有无需对目标单位释放的技能
        for (int i = 0; i < ActiveSkills.Count(); i++)
        {
            var skill          = ActiveSkills[i];
            var delayAttribute = SkillDelayAttributes[i];
            if (!skill.IsMustDesignation && !delayAttribute.isDelay)
            {
                skill.Execute(speller, position);
            }
        }

        // 在目标地点产生一个球形检测区域,半径由skillInflence决定,
        // 对检测区域内所有CharacterMono单位释放技能组中的单体技能
        Collider[] colliders = Physics.OverlapSphere(position, skillModel.SkillInfluenceRadius);
        foreach (var collider in colliders)
        {
            CharacterMono target = collider.GetComponent <CharacterMono>();
            if (target != null)
            {
                foreach (var skill in ActiveSkills)
                {
                    if (skill.IsMustDesignation)
                    {
                        skill.Execute(speller, target);
                    }
                }
            }
        }
    }
Ejemplo n.º 2
0
    public override void Execute(CharacterMono speller, CharacterMono target)
    {
        base.Execute(speller, target);

        //========================================
        // 为延迟技能增加监听事件
        for (int i = 0; i < ActiveSkills.Count(); i++)
        {
            var skill          = ActiveSkills[i];
            var delayAttribute = SkillDelayAttributes[i];
            if (delayAttribute.isDelay)
            {
                var activeSkill = ActiveSkills[delayAttribute.index];

                OnSkillCompeleteHandler delayExcute = null;
                delayExcute = () => {
                    if (skill.IsMustDesignation)
                    {
                        skill.Execute(speller, target);
                    }
                    else
                    {
                        skill.Execute(speller, target.transform.position);
                    }
                };
                activeSkill.OnCompelte += delayExcute;
            }
        }

        //=============================================
        // 执行每一个非延迟技能
        for (int i = 0; i < ActiveSkills.Count(); i++)
        {
            var skill          = ActiveSkills[i];
            var delayAttribute = SkillDelayAttributes[i];
            if (!delayAttribute.isDelay)
            {
                if (skill.IsMustDesignation)
                {
                    skill.Execute(speller, target);
                }
                else
                {
                    skill.Execute(speller, target.transform.position);
                }
            }
        }
    }