Blood = Buff:New() --初始化Buff,通过传入一些自定义参数控制成长相关的数值 function Blood:SetData(...) -- 刷新排序等级 --self.bloodValue=... self.bloodValue=0 self.sort = 4 end function Blood:AddValue(value) local passiveChange=function(addValue) value=value+addValue end if self.target==nil then return end BattleLogic.Event:DispatchEvent(BattleEventName.BloodValuePassiveChange,passiveChange,self.target,self.caster,value) self.bloodValue=self.bloodValue+value self.target.Event:DispatchEvent(BattleEventName.BloodValueChange,self.bloodValue/self.target:GetRoleData(RoleDataName.MaxHp),1,value) end --初始化后调用一次 function Blood:OnStart() --self.target.bloodShield = self -- local passiveChange=function(addValue) -- self.bloodValue=self.bloodValue+addValue -- end -- BattleLogic.Event:DispatchEvent(BattleEventName.BloodValuePassiveChange,passiveChange,self.target,self.caster,self.bloodValue) -- self.target.Event:DispatchEvent(BattleEventName.BloodValueChange,self.bloodValue/self.target:GetRoleData(RoleDataName.MaxHp),1,self.bloodValue) end function Blood:GetCurValue() return self.bloodValue end --间隔N帧触发,返回true时表示继续触发,返回false立刻触发OnEnd function Blood:OnTrigger() return true end --效果结束时调用一次 function Blood:OnEnd() self.target.Event:DispatchEvent(BattleEventName.BloodValueChange,0) self.target.bloodShield = nil self.bloodValue=0 end --计算血甲 function Blood:CountBloodValue(damage,atkRole) local finalDamage=0 if self.target==nil then return damage end self.bloodValue=self.bloodValue-damage if self.bloodValue<=0 then self.disperse=true finalDamage=self.bloodValue end local value=0 if self.bloodValue<=0 then value=0 self.bloodValue=0 self.target.Event:DispatchEvent(BattleEventName.BloodValueGetZero,self.bloodValue/self.target:GetRoleData(RoleDataName.MaxHp),atkRole) end self.target.Event:DispatchEvent(BattleEventName.BloodValueChange,self.bloodValue/self.target:GetRoleData(RoleDataName.MaxHp)) return finalDamage end --只有当cover字段为true时触发,返回true则被新效果覆盖 function Blood:OnCover(newBuff) return true end return Blood