示例#1
0
    //技能计时、判断和伤害
    public void AttackDamage(EntityBase entity, int skillId)
    {
        SkillCfg   skillData      = resSvc.GetSkillCfg(skillId);
        List <int> skillActionLst = skillData.skillActionLst;

        long timeSum = 0;

        //计算多段伤害
        for (int i = 0; i < skillActionLst.Count; i++)
        {
            SkillActionCfg sac   = resSvc.GetSkillActionCfg(skillActionLst[i]);
            int            index = i;
            timeSum += sac.delayTime;
            if (sac.delayTime > 0)
            {
                //有延迟
                int taskId = timerSvc.AddTimeTask((id) =>
                {
                    AttackAction(entity, skillData, index);
                    entity.RemoveActionTask(id);
                }, timeSum /*延迟时间*/);
                entity.AddActionTask(taskId);
            }
            else
            {
                //无延迟
                AttackAction(entity, skillData, index);
            }
        }
    }