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

51 lines
1.2 KiB
Lua
Raw Normal View History

2019-03-12 14:05:45 +08:00
require("Modules/Battle/Logic/Base/Buff")
Brand = Buff:New()
--初始化Buff通过传入一些自定义参数控制成长相关的数值
function Brand:SetData(...)
--log("Brand:SetData")
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
2019-03-12 14:05:45 +08:00
end
--初始化后调用一次
function Brand:OnStart()
--log("Brand:OnStart")
end
--间隔N帧触发返回true时表示继续触发返回false立刻触发OnEnd
function Brand:OnTrigger()
--log("Brand:OnTrigger")
return true
end
--效果结束时调用一次
function Brand:OnEnd()
--log("Brand:OnEnd")
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)
--log("Brand:OnCover")
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
newBuff.layer = self.layer + 1
else
newBuff.layer = math.min(self.layer + 1, newBuff.maxLayer)
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
return Brand