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

79 lines
2.3 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.

Blood = Buff:New()
--初始化Buff通过传入一些自定义参数控制成长相关的数值
function Blood:SetData(...)
-- 刷新排序等级
--self.bloodValue=...
self.bloodValue=0
self.sort = 4
end
function Blood:AddValue(value)
local passiveChange=function(addValue)
value=value+addValue
end
if self.target==nil then
return
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,atkRole)
local finalDamage=0
if self.target==nil then
return damage
end
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
self.bloodValue=0
self.target.Event:DispatchEvent(BattleEventName.BloodValueGetZero,self.bloodValue/self.target:GetRoleData(RoleDataName.MaxHp),atkRole)
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