Merge branch 'battle' into dev
This commit is contained in:
commit
fb0ebff007
@ -1,5 +1,7 @@
|
||||
local LocalizationGlobalConst =
|
||||
{
|
||||
COUNTER_ATTACK_DESC = "COUNTER_ATTACK_DESC",
|
||||
BLOCK_DESC = "BLOCK_DESC",
|
||||
MAIN_BTN_1 = "MAIN_BTN_1",
|
||||
QLT_DESC_1 = "QLT_DESC_1",
|
||||
QLT_DESC_2 = "QLT_DESC_2",
|
||||
|
||||
@ -118,6 +118,9 @@ local localization_global =
|
||||
["BTN_READ"] = "读取",
|
||||
["BATTLE_DESC_9"] = "{0}攻击力:<color=#ffffff>{1}</color>",
|
||||
["BATTLE_DESC_10"] = "已激活效果",
|
||||
|
||||
["BLOCK_DESC"] = "格挡",
|
||||
["COUNTER_ATTACK_DESC"] = "反击",
|
||||
}
|
||||
|
||||
return localization_global
|
||||
@ -30,6 +30,8 @@ BattleConst.HURT_STATE_CRIT = 1 -- 暴击
|
||||
BattleConst.EFFECT_COLOR_RED = 1
|
||||
BattleConst.EFFECT_COLOR_GREEN = 2
|
||||
BattleConst.EFFECT_COLOR_BLUE = 3
|
||||
BattleConst.EFFECT_COLOR_WHILTE = 4
|
||||
BattleConst.EFFECT_COLOR_SPECIAL = 5
|
||||
BattleConst.EFFECT_TYPE_MOVE_L = 1
|
||||
BattleConst.EFFECT_TYPE_MOVE_R = 2
|
||||
BattleConst.EFFECT_TYPE_CRIT = 3
|
||||
@ -178,6 +180,7 @@ BattleConst.SPINE_ANIMATION_NAME = {
|
||||
DEAD = "death",
|
||||
BORN = "born",
|
||||
OUT = "out",
|
||||
BLOCK = "block",
|
||||
}
|
||||
|
||||
BattleConst.EFFECT_TYPE = {
|
||||
@ -193,6 +196,7 @@ BattleConst.EFFECT_TYPE = {
|
||||
BattleConst.SPECIAL_DAMAGE_OR_CURE_TYPE = {
|
||||
ROUND_BEGIN_HEAL = "round_begin_heal",
|
||||
KILL_MAX_ELEMENT_AND_HEAL = "kill_max_element_and_heal",
|
||||
BE_SUCKED = "be_sucked",
|
||||
}
|
||||
|
||||
BattleConst.SKILL_RECORD_DATA_NAME = {
|
||||
|
||||
@ -5,6 +5,9 @@ function BattleNumberComp:init()
|
||||
local uiMap = self.baseObject:genAllChildren()
|
||||
self.animator = self.baseObject:getComponent(GConst.TYPEOF_UNITY_CLASS.ANIMATOR)
|
||||
self.effectText = uiMap["battle_number.text_number"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT)
|
||||
if not self.effectText then
|
||||
self.effectText = uiMap["battle_number.text_number"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO)
|
||||
end
|
||||
self.time = 0
|
||||
end
|
||||
|
||||
|
||||
@ -86,7 +86,7 @@ function BattleUnitComp:_initBase()
|
||||
self.currAttackBlockIndex = 0 -- 多段伤害索引
|
||||
self.validEffectIdx = {}
|
||||
self.switchTime = 0
|
||||
self.isPlayHurt = 0
|
||||
self.playIdleSubAniDuration = {}
|
||||
self.attackDurationMap = {}
|
||||
self.attackKeyFrameTimeMap = {}
|
||||
self.shieldBuffList = {}
|
||||
@ -227,11 +227,6 @@ function BattleUnitComp:stopRunAction()
|
||||
end
|
||||
|
||||
function BattleUnitComp:playAnimation(name, loop, forceRefresh)
|
||||
if name == SPINE_ANIMATION_NAME.HIT then
|
||||
self.isPlayHurt = 1
|
||||
else
|
||||
self.isPlayHurt = 0
|
||||
end
|
||||
self.currAnimationName = name
|
||||
self.baseObject:playAnimation(name, loop, forceRefresh)
|
||||
end
|
||||
@ -651,29 +646,59 @@ function BattleUnitComp:enterIdleState()
|
||||
end
|
||||
|
||||
function BattleUnitComp:updateIdle(dt)
|
||||
self:updateHurt(dt)
|
||||
self:updateIdleSubAni(dt)
|
||||
end
|
||||
|
||||
function BattleUnitComp:updateIdleSubAni(...)
|
||||
if not self.currAnimationName then
|
||||
return
|
||||
end
|
||||
if self.currAnimationName == SPINE_ANIMATION_NAME.HIT then
|
||||
self:updateHurt(...)
|
||||
elseif self.currAnimationName == SPINE_ANIMATION_NAME.BLOCK then
|
||||
self:updateBlock(...)
|
||||
end
|
||||
end
|
||||
|
||||
function BattleUnitComp:playHurt()
|
||||
self.hurtTime = 0
|
||||
if self.currHitDuration == nil then
|
||||
self.currHitDuration = self:getAnimationDuration(SPINE_ANIMATION_NAME.HIT)
|
||||
local name = SPINE_ANIMATION_NAME.HIT
|
||||
self.playIdleSubAniTime = 0
|
||||
if self.playIdleSubAniDuration[name] == nil then
|
||||
self.playIdleSubAniDuration[name] = self:getAnimationDuration(name)
|
||||
end
|
||||
self:playAnimation(SPINE_ANIMATION_NAME.HIT, false, false)
|
||||
|
||||
self:playAnimation(name, false, false)
|
||||
end
|
||||
|
||||
function BattleUnitComp:updateHurt(dt)
|
||||
if self.isPlayHurt == 0 then
|
||||
return
|
||||
end
|
||||
if self.isPlayHurt == 1 then
|
||||
self.hurtTime = self.hurtTime + dt
|
||||
if self.hurtTime >= self.currHitDuration then
|
||||
self.playIdleSubAniTime = self.playIdleSubAniTime + dt
|
||||
if self.playIdleSubAniTime >= self.playIdleSubAniDuration[SPINE_ANIMATION_NAME.HIT] then
|
||||
self:playAnimation(SPINE_ANIMATION_NAME.IDLE, true, false)
|
||||
self.isPlayHurt = 0
|
||||
end
|
||||
end
|
||||
|
||||
function BattleUnitComp:playBlock()
|
||||
local name = SPINE_ANIMATION_NAME.BLOCK
|
||||
self.playIdleSubAniTime = 0
|
||||
if self.playIdleSubAniDuration[name] == nil then
|
||||
self.playIdleSubAniDuration[name] = self:getAnimationDuration(name)
|
||||
end
|
||||
self:playAnimation(name, false, false)
|
||||
|
||||
local direction = BattleConst.EFFECT_TYPE_MOVE_R
|
||||
local x, y = self.baseObject:fastGetLocalPosition()
|
||||
if self.side == BattleConst.SIDE_ATK then
|
||||
direction = BattleConst.EFFECT_TYPE_MOVE_L
|
||||
end
|
||||
|
||||
self:showEffectNumber(BattleConst.EFFECT_COLOR_SPECIAL, direction, I18N:getGlobalText(I18N.GlobalConst.BLOCK_DESC), x, y, 0)
|
||||
end
|
||||
|
||||
|
||||
function BattleUnitComp:updateBlock(dt)
|
||||
self.playIdleSubAniTime = self.playIdleSubAniTime + dt
|
||||
if self.playIdleSubAniTime >= self.playIdleSubAniDuration[SPINE_ANIMATION_NAME.BLOCK] then
|
||||
self:playAnimation(SPINE_ANIMATION_NAME.IDLE, true, false)
|
||||
end
|
||||
end
|
||||
|
||||
function BattleUnitComp:enterRecoverHpWaveState()
|
||||
@ -1210,6 +1235,7 @@ function BattleUnitComp:onSkillTakeEffect(skill, isFinalBlock, validEffectIdx)
|
||||
local block = target.unitEntity:getBlock()
|
||||
if block > 0 then
|
||||
if BattleHelper:random(1, DEFAULT_FACTOR) <= block then -- 格挡成功
|
||||
target:playBlock()
|
||||
return
|
||||
end
|
||||
end
|
||||
@ -1407,19 +1433,34 @@ function BattleUnitComp:takeDamageOrCure(atker, num, effectType, effectStatus, d
|
||||
if effectStatus == HURT_STATE_CRIT then
|
||||
self:showEffectNumber(BattleConst.EFFECT_COLOR_RED, BattleConst.EFFECT_TYPE_CRIT, "c" .. damage, x, y, delayTime)
|
||||
else
|
||||
if self.side == BattleConst.SIDE_ATK then
|
||||
self:showEffectNumber(BattleConst.EFFECT_COLOR_RED, BattleConst.EFFECT_TYPE_MOVE_L, damage, x, y, delayTime)
|
||||
local effectColor = BattleConst.EFFECT_COLOR_RED
|
||||
local damageStr = damage
|
||||
local direction = BattleConst.EFFECT_TYPE_MOVE_R
|
||||
local elementType = BattleHelper:getDamageOrCureType2MatchType(damageOrCureType)
|
||||
local weekNessValue = self.unitEntity:getWeakness(elementType)
|
||||
if weekNessValue > 0 then
|
||||
damageStr = "a" .. damage
|
||||
else
|
||||
self:showEffectNumber(BattleConst.EFFECT_COLOR_RED, BattleConst.EFFECT_TYPE_MOVE_R, damage, x, y, delayTime)
|
||||
local decGmgValue = self.unitEntity:getDecDmg(elementType)
|
||||
if decGmgValue > 0 then
|
||||
effectColor = BattleConst.EFFECT_COLOR_WHILTE
|
||||
damageStr = "d" .. damage
|
||||
end
|
||||
end
|
||||
|
||||
if self.side == BattleConst.SIDE_ATK then
|
||||
direction = BattleConst.EFFECT_TYPE_MOVE_L
|
||||
end
|
||||
|
||||
self:showEffectNumber(effectColor, direction, damageStr, x, y, delayTime)
|
||||
end
|
||||
end
|
||||
if effectType == EFFECT_TYPE.DIRECT then
|
||||
if hp > 0 and self.unitEntity:getShieldRebound() then -- 伤害反弹
|
||||
atker:takeDamageOrCure(self, num*self.unitEntity:getShieldRebound() // DEFAULT_FACTOR, EFFECT_TYPE.REBOUND, 0, BattleConst.BUFF_NAME.SHIELD_REBOUND_200)
|
||||
end
|
||||
if self.unitEntity:getBeSucked() > 0 then -- 吸血
|
||||
atker:takeDamageOrCure(self, -num*self.unitEntity:getBeSucked() // DEFAULT_FACTOR, EFFECT_TYPE.HEAL, 0, BattleConst.ATTR_NAME.BE_SUCKED)
|
||||
atker:takeDamageOrCure(self, -num*self.unitEntity:getBeSucked() // DEFAULT_FACTOR, EFFECT_TYPE.HEAL, 0, BattleConst.SPECIAL_DAMAGE_OR_CURE_TYPE.BE_SUCKED)
|
||||
end
|
||||
if self.unitEntity:getIsLethargy() then -- 移除昏睡
|
||||
self:removeBuffByName(BattleConst.BUFF_NAME.LETHARGY)
|
||||
@ -1431,6 +1472,7 @@ function BattleUnitComp:takeDamageOrCure(atker, num, effectType, effectStatus, d
|
||||
local counterattack = self.unitEntity:getCounterAttack()
|
||||
if counterattack > DEFAULT_FACTOR or BattleHelper:random(1, DEFAULT_FACTOR) <= counterattack then -- 通过命中概率
|
||||
self.unitEntity:addCounterAttackCount(1)
|
||||
self.battleController:showCounterAttack(self.unitEntity:getCounterAttackCount(), self.side)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -282,6 +282,14 @@ function BattleController:hideCombo()
|
||||
self.battleUI:hideCombo()
|
||||
end
|
||||
|
||||
function BattleController:showCounterAttack(count, side)
|
||||
self.battleUI:showCounterAttack(count, side)
|
||||
end
|
||||
|
||||
function BattleController:hideCounterAttack()
|
||||
self.battleUI:hideCounterAttack()
|
||||
end
|
||||
|
||||
function BattleController:prepareFight()
|
||||
local count = 0
|
||||
local totalCount = 3
|
||||
@ -297,7 +305,9 @@ function BattleController:prepareFight()
|
||||
self.battleUI:addLoadUICompleteListener(function()
|
||||
BattleHelper:setEffectTextCache(self.battleUI:getBattleNumberRed(),
|
||||
self.battleUI:getBattleNumberGreen(),
|
||||
self.battleUI:getBattleNumberBlue())
|
||||
self.battleUI:getBattleNumberBlue(),
|
||||
self.battleUI:getBattleNumberWhite(),
|
||||
self.battleUI:getBattleNumberSpecial())
|
||||
self:initAtkUnits(onPreloadFinished)
|
||||
self:initDefUnits(onPreloadFinished)
|
||||
self.battleUI:refreshChessBoard(self:getChessBoardBgName())
|
||||
@ -577,6 +587,7 @@ function BattleController:enterNextTeamAction()
|
||||
|
||||
self.roundStep = BattleConst.BATTLE_ROUND_STEP.ON_TEAM_ACTION_OVER
|
||||
self:hideCombo()
|
||||
self:hideCounterAttack()
|
||||
|
||||
if self:checkTeamIsDead(function() self:enterRoundEnd() end) then
|
||||
return
|
||||
|
||||
@ -20,6 +20,7 @@ function BattleHelper:init()
|
||||
self.seed = tonumber(tostring(os.time()):reverse():sub(1,6))
|
||||
self.baseOrder = 0
|
||||
self.skillSoundPath = {}
|
||||
self.damageOrCureType2MatchType = {}
|
||||
end
|
||||
|
||||
function BattleHelper:setBaseOrder(baseOrder)
|
||||
@ -175,13 +176,15 @@ function BattleHelper:addSpineBoneFollowerGraphic(effectObj)
|
||||
return boneFollower
|
||||
end
|
||||
|
||||
function BattleHelper:setEffectTextCache(cache1, cache2, cache3)
|
||||
function BattleHelper:setEffectTextCache(cache1, cache2, cache3, cache4, cache5)
|
||||
if self.effectTextCacheList == nil then
|
||||
self.effectTextCacheList = {}
|
||||
end
|
||||
self.effectTextCacheList[1] = cache1
|
||||
self.effectTextCacheList[2] = cache2
|
||||
self.effectTextCacheList[3] = cache3
|
||||
self.effectTextCacheList[4] = cache4
|
||||
self.effectTextCacheList[5] = cache5
|
||||
end
|
||||
|
||||
function BattleHelper:getEffectText(parent, colorType)
|
||||
@ -256,6 +259,30 @@ function BattleHelper:playSkillSound(name, delay)
|
||||
end
|
||||
end
|
||||
|
||||
function BattleHelper:getDamageOrCureType2MatchType(damageOrCureType)
|
||||
if not damageOrCureType then
|
||||
return GConst.BattleConst.ELEMENT_TYPE.NONE
|
||||
end
|
||||
|
||||
if not self.damageOrCureType2MatchType[damageOrCureType] then
|
||||
local elementType = GConst.BattleConst.ELEMENT_TYPE.NONE
|
||||
if string.match(damageOrCureType, "red") then
|
||||
elementType = GConst.BattleConst.ELEMENT_TYPE.RED
|
||||
elseif string.match(damageOrCureType, "yellow") then
|
||||
elementType = GConst.BattleConst.ELEMENT_TYPE.YELLOW
|
||||
elseif string.match(damageOrCureType, "green") then
|
||||
elementType = GConst.BattleConst.ELEMENT_TYPE.GREEN
|
||||
elseif string.match(damageOrCureType, "blue") then
|
||||
elementType = GConst.BattleConst.ELEMENT_TYPE.BLUE
|
||||
elseif string.match(damageOrCureType, "purple") then
|
||||
elementType = GConst.BattleConst.ELEMENT_TYPE.PURPLE
|
||||
end
|
||||
self.damageOrCureType2MatchType[damageOrCureType] = elementType
|
||||
end
|
||||
|
||||
return self.damageOrCureType2MatchType[damageOrCureType]
|
||||
end
|
||||
|
||||
function BattleHelper:performDurationDelay(delay, func)
|
||||
return BattleScheduler:performWithDelayGlobal(func, delay)
|
||||
end
|
||||
|
||||
@ -67,6 +67,7 @@ function BattleUI:_display()
|
||||
self:initSelectSkillNode()
|
||||
self:initCommonSkillDescTips()
|
||||
self:initBossEnterAni()
|
||||
self:initCounterAttack()
|
||||
end
|
||||
|
||||
function BattleUI:_addListeners()
|
||||
@ -384,6 +385,8 @@ function BattleUI:initNumberNode()
|
||||
self.battleNumberRed = self.uiMap["battle_ui.cache_node.battle_number_red"]
|
||||
self.battleNumberGreen = self.uiMap["battle_ui.cache_node.battle_number_green"]
|
||||
self.battleNumberBlue = self.uiMap["battle_ui.cache_node.battle_number_blue"]
|
||||
self.battleNumberWhite = self.uiMap["battle_ui.cache_node.battle_number_white"]
|
||||
self.battleNumberSpecial = self.uiMap["battle_ui.cache_node.battle_number_special"]
|
||||
end
|
||||
|
||||
function BattleUI:getNumberNode()
|
||||
@ -402,6 +405,14 @@ function BattleUI:getBattleNumberBlue()
|
||||
return self.battleNumberBlue
|
||||
end
|
||||
|
||||
function BattleUI:getBattleNumberWhite()
|
||||
return self.battleNumberWhite
|
||||
end
|
||||
|
||||
function BattleUI:getBattleNumberSpecial()
|
||||
return self.battleNumberSpecial
|
||||
end
|
||||
|
||||
function BattleUI:initComboNode()
|
||||
self.comboNode = self.uiMap["battle_ui.top_node.combo"]
|
||||
self.comboAnimator = self.comboNode:getComponent(GConst.TYPEOF_UNITY_CLASS.ANIMATOR)
|
||||
@ -516,6 +527,26 @@ function BattleUI:showCombo(count)
|
||||
end
|
||||
end
|
||||
|
||||
function BattleUI:initCounterAttack()
|
||||
self.counterAttackNode = self.uiMap["battle_ui.battle_root.battle_number_node.counter_attack"]
|
||||
self.counterTx = self.uiMap["battle_ui.battle_root.battle_number_node.counter_attack.text_number"]
|
||||
self.counterAttackNode:setVisible(false)
|
||||
end
|
||||
|
||||
function BattleUI:showCounterAttack(count, side)
|
||||
local x = 280
|
||||
if side == GConst.BattleConst.SIDE_ATK then
|
||||
x = -280
|
||||
end
|
||||
self.counterAttackNode:setAnchoredPositionX(x)
|
||||
self.counterTx:setText(I18N:getGlobalText(I18N.GlobalConst.COUNTER_ATTACK_DESC) .. "+" .. count)
|
||||
self.counterAttackNode:setVisible(true)
|
||||
end
|
||||
|
||||
function BattleUI:hideCounterAttack()
|
||||
self.counterAttackNode:setVisible(false)
|
||||
end
|
||||
|
||||
function BattleUI:initFxNode()
|
||||
self.fxNode = self.uiMap["battle_ui.battle_root.batttle_fx_node"]
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user