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

60 lines
2.0 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.

require("Modules/Battle/Logic/Base/Buff")
PropertyChange = Buff:New()
--初始化Buff通过传入一些自定义参数控制成长相关的数值
function PropertyChange:SetData(...)
--log("PropertyChange:SetData")
local args = {...}
self.propertyName = args[1]
self.Value = args[2]
self.changeType = args[3]
end
--初始化后调用一次
function PropertyChange:OnStart()
--log("PropertyChange:OnStart")
if self.changeType == 1 then --加算
self.delta = self.target.data:AddValue(self.propertyName, self.Value)
self.isBuff = true
elseif self.changeType == 2 then --乘加算(百分比属性加算)
self.delta = self.target.data:AddPencentValue(self.propertyName, self.Value)
self.isBuff = true
elseif self.changeType == 3 then --减算
self.delta = self.target.data:SubValue(self.propertyName, self.Value)
self.isDeBuff = true
elseif self.changeType == 4 then --乘减算(百分比属性减算)
self.delta = self.target.data:SubPencentValue(self.propertyName, self.Value)
self.isDeBuff = true
end
end
--间隔N帧触发返回true时表示继续触发返回false立刻触发OnEnd
function PropertyChange:OnTrigger()
--log("PropertyChange:OnTrigger")
return true
end
--效果结束时调用一次
function PropertyChange:OnEnd()
--log("PropertyChange:OnEnd")
if self.changeType == 3 or self.changeType == 4 then
self.target.data:AddValue(self.propertyName, self.delta)
else
self.target.data:SubDeltaValue(self.propertyName, self.delta)
end
end
--只有当Cover字段为true时触发返回true则被新效果覆盖
function PropertyChange:OnCover(newBuff)
--log("PropertyChange:OnCover")
if self.layer then
if self.maxCount == 0 then
newBuff.layer = self.layer + 1
else
newBuff.layer = math.min(self.layer + 1, self.maxCount)
end
end
return true
end
return PropertyChange