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

79 lines
2.3 KiB
Lua
Raw Normal View History

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