Beispiel #1
0
        private IEnumerator RepeatDamage(SkillDeployer deployer, SkillData skillData)
        {
            float attackTime = 0;

            do
            {
                // 1 对多个目标执行伤害
                if (skillData.attackTargets != null && skillData.attackTargets.Length > 0)
                {
                    for (int i = 0; i < skillData.attackTargets.Length; i++)
                    {
                        OnceDamage(skillData, skillData.attackTargets[i]);
                    }
                }
                // 2 等待一个伤害间隔
                yield return(new WaitForSeconds(skillData.damageInterval));

                attackTime = attackTime + skillData.damageInterval;
                // ! 那么 damageInterval 不能为0
                if (skillData.damageInterval <= 0)
                {
                    YellowEvents.SendEvent(YellowEventName.error, YellowErrorText.errorSkilldamageInterval + skillData.name);
                    skillData.damageInterval = 0.1f;
                }
                // 3 攻击完一次后,重新选取目标
                skillData.attackTargets = deployer.ResetTargets();
            } while (attackTime <= skillData.durationTime);
        }
Beispiel #2
0
        //多次伤害
        private IEnumerator RepeatDamage(SkillDeployer deployer, SkillData skillData)
        {
            float attackTime = 0;

            do
            {
                if (skillData.attackTargets != null && skillData.attackTargets.Length != 0)
                {
                    //对目标执行伤害
                    for (int i = 0; i < skillData.attackTargets.Length; i++)
                    {
                        OnceDamage(skillData, skillData.attackTargets[i]);
                    }
                }

                yield return(new WaitForSeconds(skillData.damageInterval));

                attackTime += skillData.damageInterval;

                //攻击一次要重置目标
                skillData.attackTargets = deployer.ResetTargets();
            } while (attackTime < skillData.durationTime);  //防止死循环
        }