--在技能退出时 local Base = require("Battle/Logic/Entity/SkillDecorator/SkillDecorator") local SkillDecoratorQuitReplaceSkillByCount = class("SkillDecoratorQuitReplaceSkillByCount", Base) local EventSystem = require 'Event/EventSystem' function SkillDecoratorQuitReplaceSkillByCount:initialize(entity, skillID, replaceSkillID, limitCount) Base.initialize(self, entity, skillID) self.type = LuaConst.SkillDecoratorType.QuitReplaceSkillByCount self.UIType = LuaConst.UISkillBtnResetType.RecordReleaseCount self.limitCount = limitCount or -1 self.replaceSkillID = replaceSkillID if replaceSkillID == nil then logging.error(LTAG.ERROR, "【gws】 : 策划检查下,添加技能功能:释放计数后替换技能, 要替换的技能为nil了") end self.curCount = 0 if self.limitCount > 0 then EventSystem.Dispatch(EventID.UI_BattleAttack_ResetBtn, entity, self.skillID, self.UIType, self.curCount, self.limitCount) end end -- ui上面渲染的方法 function SkillDecoratorQuitReplaceSkillByCount:OnUIBtn() if self.limitCount > 0 then EventSystem.Dispatch(EventID.UI_BattleAttack_ResetBtn, self.entity, self.skillID, self.UIType, self.curCount, self.limitCount) end end -- 技能退出时 function SkillDecoratorQuitReplaceSkillByCount:OnAttackQuit() Base.OnAttackQuit(self) if self.curCount >= self.limitCount then self.curCount = 0 SystemManager.ReplaceNormalSkillBySkillID(self.entity, self.replaceSkillID) end end --region 外部接口 function SkillDecoratorQuitReplaceSkillByCount:AddCount(value) local addVal = value or 1 self.curCount = self.curCount + addVal EventSystem.Dispatch(EventID.UI_BattleAttack_ResetBtn, self.entity, self.skillID, self.UIType, self.curCount, self.limitCount) end --region 外部接口 function SkillDecoratorQuitReplaceSkillByCount.StringParamToFormat(str) local strArr = string.split(str,",") local skillID, replaceSkillID, limitCount = strArr[1], strArr[2], strArr[3] skillID = tonumber(skillID) replaceSkillID = tonumber(replaceSkillID) limitCount = tonumber(limitCount) return skillID, replaceSkillID, limitCount end return SkillDecoratorQuitReplaceSkillByCount