Ejemplo n.º 1
0
 /// <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(skill.Id);
         EffectModel[] effects      = skill.LvData[i].EffectData;
         skillHandler.Effects = new EffectModel[effects.Length];
         // 遍历技能效果
         for (int j = 0; j < effects.Length; j++)
         {
             EffectModel effect = effects[j];
             skillHandler.Effects[j] = effect;
             // 判断效果类型 将相应的处理添加到委托里
             EffectHandler handler = SkillHandlerData.HandlerDict.ExTryGet(effect.Type);
             if (handler != null)
             {
                 skillHandler.Handler += handler;
             }
         }
         skillHandlers[i] = skillHandler;
     }
     return(skillHandlers);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 使用技能
        /// </summary>
        /// <param name="skillId"></param>
        /// <param name="from"></param>
        /// <param name="to"></param>
        public void UseSkill(int skillId, int level, AIBaseCtrl from, AIBaseCtrl[] to = null)
        {
            if (!HandlerDict.ContainsKey(skillId))
            {
                Log.Error("没有找到技能 : " + skillId);
                return;
            }
            SkillHandler handler = HandlerDict.ExTryGet(skillId)[level - 1];

            if (handler != null)
            {
                handler.RunSkill(level, from, to);
            }
        }