miduo_server/luafight/Modules/Battle/Logic/Buff/Brand.lua

53 lines
1.1 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

Brand = Buff:New()
--初始化Buff通过传入一些自定义参数控制成长相关的数值
function Brand:SetData(...)
self.flag, self.endFunc = ... --标记,结束回调
self.cover = true
self.layer = 1
self.maxLayer = 0
-- 刷新排序等级
self.sort = 4
end
--初始化后调用一次
function Brand:OnStart()
end
--间隔N帧触发返回true时表示继续触发返回false立刻触发OnEnd
function Brand:OnTrigger()
return true
end
--效果结束时调用一次
function Brand:OnEnd()
if self.endFunc then
self.endFunc()
self.endFunc = nil
end
self.coverFunc = nil
end
--只有当cover字段为true时触发返回true则被新效果覆盖
function Brand:OnCover(newBuff)
local b = newBuff.flag == self.flag
if b then
if newBuff.maxLayer == 0 then
newBuff.layer = newBuff.layer + self.layer
else
newBuff.layer = math.min(newBuff.layer + self.layer, newBuff.maxLayer)
end
if newBuff.coverFunc then
newBuff.coverFunc(self)
end
end
return b
end
return Brand