--- 为技能统计额外的CD . --- 策划目前的需求是这个额外CD ,但是不需要收到 "百分比减少单位所有技能的CD" 的影响 。如以后需要,可做个新的Decorator local Base = require("Battle/Logic/Entity/SkillDecorator/SkillDecorator") local SkillDecoratorExtraCD = class("SkillDecoratorExtraCD", Base) local EventSystem = require 'Event/EventSystem' local FP_Greater = FP.Greater local FP_LessEquals = FP.LessEquals -- 注意:这个 skillID 必须是belongTo技能id function SkillDecoratorExtraCD:initialize(entity, skillID, maxExtraCD) Base.initialize(self, entity, skillID) self.type = LuaConst.SkillDecoratorType.ExtraCD self.UIType = LuaConst.UISkillBtnResetType.EnterExtraCD if maxExtraCD == nil then logging.error(LTAG.ERROR, "【gws】 : 策划检查下,添加技能功能:记录CD倒计时, 参数没填写!") end self.maxExtraCD = FP.newV1(0):Reset(maxExtraCD) -- 单位:毫秒 self.curCD = FP.newV1(0) -- 单位:毫秒 end -- ui上面渲染的方法 function SkillDecoratorExtraCD:OnUIBtn() EventSystem.Dispatch(EventID.UI_BattleAttack_ResetBtn, self.entity, self.skillID, self.UIType, self.curCD, self.maxExtraCD) end function SkillDecoratorExtraCD:OnAttackEnter() Base.OnAttackEnter(self) self.curCD:Reset(self.maxExtraCD) EventSystem.Dispatch(EventID.UI_BattleAttack_ResetBtn, self.entity, self.skillID, self.UIType, self.curCD, self.maxExtraCD) end function SkillDecoratorExtraCD:OnLogicUpdate() if not self.enable then return end if FP_Greater(self.curCD,0) then self.curCD:Sub(LuaConst.TimeSpanMs) if FP_LessEquals(self.curCD,0) then EventSystem.Dispatch(EventID.UI_BattleAttack_ResetBtn, self.entity, self.skillID, self.UIType, self.curCD, self.maxExtraCD) end end end function SkillDecoratorExtraCD:CanUseSkill() if FP_Greater(self.curCD,0) then return false end return true end function SkillDecoratorExtraCD.StringParamToFormat(str) local strArr = string.split(str,",") local skillID, maxExtraCD = strArr[1], strArr[2] skillID = tonumber(skillID) maxExtraCD = tonumber(maxExtraCD) return skillID, maxExtraCD end return SkillDecoratorExtraCD