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

57 lines
1.2 KiB
Lua
Raw Normal View History

2019-03-12 14:05:45 +08:00
Brand = Buff:New()
--初始化Buff通过传入一些自定义参数控制成长相关的数值
function Brand:SetData(...)
2020-04-10 14:52:41 +08:00
2019-04-17 21:04:32 +08:00
self.flag, self.endFunc = ... --标记,结束回调
2019-03-12 14:05:45 +08:00
self.cover = true
self.layer = 1
2019-05-07 20:01:07 +08:00
self.maxLayer = 0
2020-04-10 14:52:41 +08:00
-- 刷新排序等级
self.sort = 4
2019-03-12 14:05:45 +08:00
end
--初始化后调用一次
function Brand:OnStart()
2020-04-10 14:52:41 +08:00
2019-03-12 14:05:45 +08:00
end
--间隔N帧触发返回true时表示继续触发返回false立刻触发OnEnd
function Brand:OnTrigger()
2020-04-10 14:52:41 +08:00
2019-03-12 14:05:45 +08:00
return true
end
--效果结束时调用一次
function Brand:OnEnd()
2020-04-10 14:52:41 +08:00
2019-04-17 21:04:32 +08:00
if self.endFunc then
self.endFunc()
2019-09-01 12:11:18 +08:00
self.endFunc = nil
2019-04-17 21:04:32 +08:00
end
2019-09-01 12:11:18 +08:00
self.coverFunc = nil
2019-03-12 14:05:45 +08:00
end
--只有当cover字段为true时触发返回true则被新效果覆盖
function Brand:OnCover(newBuff)
2020-04-10 14:52:41 +08:00
2019-04-17 21:04:32 +08:00
local b = newBuff.flag == self.flag
if b then
2019-05-07 20:01:07 +08:00
if newBuff.maxLayer == 0 then
2020-01-14 16:16:09 +08:00
newBuff.layer = newBuff.layer + self.layer
2019-05-07 20:01:07 +08:00
else
2020-01-14 16:16:09 +08:00
newBuff.layer = math.min(newBuff.layer + self.layer, newBuff.maxLayer)
2019-05-07 20:01:07 +08:00
end
2019-09-09 10:14:21 +08:00
if newBuff.coverFunc then
newBuff.coverFunc(self)
end
2019-09-01 12:11:18 +08:00
end
2019-04-17 21:04:32 +08:00
return b
2019-03-12 14:05:45 +08:00
end
2020-04-23 20:08:25 +08:00
-- 比较buff
function Brand:OnCompare(buff)
return buff.flag == self.flag
end
2020-04-10 14:52:41 +08:00
return Brand