/// <summary> /// 使用技能,这个需要手动调用 /// </summary> /// <param name="self"></param> /// <param name="skillId"></param> /// <returns></returns> public static UseSkillRet UseSkill(SkillObj self, int skillId) { UseSkillRet ret = UseSkillRet.Success; if (BattleModule.IsActionLimited(self, ActionLimitType.UseSkill)) { return(UseSkillRet.ActionLimit); } if (self.IsDead()) { return(UseSkillRet.Dead); } //检查特殊状态 if (!self.CanUseSkill(skillId)) { return(UseSkillRet.None); } SkillConfig_New skillConfig = self.GetSkillConfig(skillId); if (skillConfig == null) { return(UseSkillRet.None); } //检查技能消耗 if (!UseSkillCheckDeplete(self, skillConfig)) { return(UseSkillRet.Deplete); } string skillLogicId = self.GetSkillLogicId(skillConfig); if (!SkillLogics.ContainsKey(skillLogicId)) { return(UseSkillRet.None); } SkillLogic skillLogic = SkillLogics[skillLogicId]; if (skillLogic != null) { //检查CD if (!skillLogic.CheckCD(self, skillConfig)) { string key = self.GetSkillCDKey(skillConfig); self.LogInfo("skill:[{0}] CD ing [{1}]:[{2}]".F(self.GetSkillID(skillConfig), key, self.GetCD(key))); return(UseSkillRet.CD); } SkillInfo_New skillInfo = skillLogic.Begin(self, skillConfig); if (skillInfo != null) { skillLogic.BeginCD(self, skillInfo, skillConfig); self.AddSkillList(skillInfo); self.LogInfo("Skill Begin Successed [{0}]".F(skillId)); } else { self.LogInfo("Skill Begin Failed [{0}]".F(skillId)); } } return(ret); }
private static SkillLogic GetSkillLogic(SkillInfo_New skillInfo, SkillObj logObj) { int skillId = logObj.GetSkillID(skillInfo); SkillConfig_New buffConfig = logObj.GetSkillConfig(skillId); if (buffConfig == null) { logObj.LogInfo("SkillConfig not found skillid[{0}]".F(skillId)); return(null); } string skillLogicId = logObj.GetSkillLogicId(buffConfig); if (!SkillLogics.ContainsKey(skillLogicId)) { logObj.LogInfo("SkillLogic not found skillid[{0}] SkillLogicId[{1}]".F(skillId, skillLogicId)); return(null); } SkillLogic skillLogic = SkillLogics[skillLogicId]; return(skillLogic); }