/// <summary> /// 分析技能效果 转换为处理对象 /// </summary> /// <param name="key"></param> /// <param name="skill"></param> private SkillHandler[] ParseSkill(SkillModel skill) { // 创建处理对象数组 保存不同的等级 SkillHandler[] skillHandlers = new SkillHandler[skill.LvData.Length]; for (int i = 0; i < skillHandlers.Length; i++) { // 创建每一级的处理对象 SkillHandler skillHandler = new SkillHandler(); skillHandler.SkillId = skill.Id; EffectModel[] effects = skill.LvData[i].EffectData; skillHandler.Data = new EffectModel[effects.Length]; // 遍历技能效果 for (int j = 0; j < effects.Length; j++) { EffectModel effect = effects[j]; skillHandler.Data[j] = effect; // 判断效果类型 将相应的处理添加到委托里 if (effect.Type.StartsWith(SkillData.DamageType)) { DamageHandler handler = SkillHandlerData.DamageDict.ExTryGet(effect.Type); if (handler != null) { skillHandler.Damage += handler; } } else if (effect.Type.StartsWith(SkillData.EffectType)) { EffectHandler handler = SkillHandlerData.EffectDict.ExTryGet(effect.Type); if (handler != null) { skillHandler.Effect += handler; } } } skillHandlers[i] = skillHandler; } return(skillHandlers); }
/// <summary> /// 计算伤害 /// </summary> /// <param name="skillId"></param> /// <param name="level"></param> /// <param name="from"></param> /// <param name="to"></param> /// <param name="room"></param> /// <returns></returns> public DtoDamage[] Damage(RoomBase <MobaPeer> room, int skillId, int level, DtoMinion from, DtoMinion[] to) { SkillHandler skillHandler = HandlerDict.ExTryGet(skillId)[level - 1]; return(skillHandler.RunDamage(room, from, to)); }
/// <summary> /// 使用技能 /// </summary> /// <param name="skillId"></param> /// <param name="level"></param> /// <param name="room"></param> /// <param name="from"></param> /// <param name="to"></param> /// <returns></returns> public void UseSkill(int skillId, int level, DtoMinion from, DtoMinion[] to = null, RoomBase <MobaPeer> room = null) { SkillHandler skillHandler = HandlerDict.ExTryGet(skillId)[level - 1]; skillHandler.RunSkill(room, from, to); }