miduo_client/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Buff/Blood.lua

71 lines
2.0 KiB
Lua
Raw Normal View History

Blood = Buff:New()
--初始化Buff通过传入一些自定义参数控制成长相关的数值
function Blood:SetData(...)
-- 刷新排序等级
self.bloodValue=...
self.sort = 4
end
function Blood:AddValue(value)
2021-10-28 09:48:01 +08:00
local passiveChange=function(addValue)
value=value+addValue
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)
local finalDamage=0
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
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