护盾
This commit is contained in:
parent
d8bf6274d8
commit
8575d48b37
@ -193,6 +193,7 @@ local BUFF_NAME = {
|
||||
CURED_ADD = "cured_add",
|
||||
ADD_SKILL = "add_skill",
|
||||
SKILL_FIRE_TIMES = "skill_fire_times",
|
||||
SHIELD_REBOUND_200 = "shield_rebound_200",
|
||||
}
|
||||
BattleConst.BUFF_NAME = BUFF_NAME
|
||||
|
||||
@ -227,6 +228,7 @@ local ATTR_NAME = {
|
||||
CRIT_TIME = "crit_time",
|
||||
EXP_TIME = "exp_time",
|
||||
CURE_ADDITION = "cure_addition",
|
||||
SHIELD_REBOUND = "shield_rebound",
|
||||
}
|
||||
BattleConst.ATTR_NAME = ATTR_NAME
|
||||
|
||||
|
||||
@ -366,6 +366,17 @@ function BattleUnitComp:addShield(num, buffEffect)
|
||||
self.team:addShield(buffEffect)
|
||||
end
|
||||
|
||||
function BattleUnitComp:removeShield(buffEffect)
|
||||
if buffEffect == nil then
|
||||
return
|
||||
end
|
||||
if buffEffect.result > 0 then
|
||||
self.unitEntity:addShield(-buffEffect.result)
|
||||
buffEffect.result = 0
|
||||
end
|
||||
self.team:removeShield(buffEffect)
|
||||
end
|
||||
|
||||
function BattleUnitComp:changeState(state)
|
||||
if self.currState == state and not self:repeatCurrState() then
|
||||
return false
|
||||
|
||||
@ -116,10 +116,32 @@ local function _takeEffectControl(unitComp, buff, target, buffEffect)
|
||||
return true
|
||||
end
|
||||
|
||||
local function _takeEffectShield(unitComp, buff, target, buffEffect)
|
||||
BattleBuffHandle.addShield = {
|
||||
-- 反弹目标伤害的200%,直接写死
|
||||
[BUFF_NAME.SHIELD_REBOUND_200] = function(unitComp, buff, target, buffEffect)
|
||||
local shieldNum = target.unitEntity:getMaxHp() * buff:getEffectNum() // DEFAULT_FACTOR
|
||||
target:addShield(shieldNum, buffEffect)
|
||||
return true
|
||||
target.unitEntity:addAttr(ATTR_NAME.SHIELD_REBOUND, 20000, false)
|
||||
return shieldNum
|
||||
end,
|
||||
}
|
||||
|
||||
BattleBuffHandle.removeShield = {
|
||||
[BUFF_NAME.SHIELD_REBOUND_200] = function(buffSender, target, buff, buffEffect)
|
||||
target.unitEntity:addAttr(ATTR_NAME.SHIELD_REBOUND, -20000, false)
|
||||
target:removeShield(buffEffect)
|
||||
end,
|
||||
}
|
||||
|
||||
local function _takeEffectShield(unitComp, buff, target, buffEffect)
|
||||
local func = BattleBuffHandle.addShield[buff:getName()]
|
||||
if func then
|
||||
return func(unitComp, buff, target, buffEffect)
|
||||
else
|
||||
local shieldNum = target.unitEntity:getMaxHp() * buff:getEffectNum() // DEFAULT_FACTOR
|
||||
target:addShield(shieldNum, buffEffect)
|
||||
return shieldNum
|
||||
end
|
||||
end
|
||||
|
||||
-- buff添加时的效果
|
||||
@ -152,6 +174,15 @@ local function _removeEffectAttr(buffSender, target, buff, buffEffect)
|
||||
end
|
||||
end
|
||||
|
||||
local function _removeEffectShield(buffSender, target, buff, buffEffect)
|
||||
local func = BattleBuffHandle.removeShield[buff:getName()]
|
||||
if func then
|
||||
func(buffSender, target, buff, buffEffect)
|
||||
else
|
||||
target:removeShield(buffEffect)
|
||||
end
|
||||
end
|
||||
|
||||
local function _removeEffectControl(buffSender, target, buff, buffEffect)
|
||||
target.unitEntity:removeLimit(buff:getName())
|
||||
end
|
||||
@ -159,6 +190,7 @@ end
|
||||
-- buff移除时的效果
|
||||
BattleBuffHandle.removeEffect = {
|
||||
[1] = _removeEffectAttr,
|
||||
[2] = _removeEffectShield,
|
||||
[7] = BattleBuffSpecial.specialBuffOff,
|
||||
[8] = _removeEffectControl,
|
||||
}
|
||||
|
||||
@ -157,6 +157,15 @@ function BattleTeam:addShield(buffEffect)
|
||||
end
|
||||
end
|
||||
|
||||
function BattleTeam:removeShield(buffEffect)
|
||||
for k, v in ipairs(self.shieldBuffList) do
|
||||
if v == buffEffect then
|
||||
table.remove(self.shieldBuffList, k)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function BattleTeam:handleShield(reduceShield, unit)
|
||||
if #self.shieldBuffList <= 0 then
|
||||
return
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user