c1_lua/lua/app/ui/battle/battle_ui_pvp.lua
2023-06-26 15:28:40 +08:00

224 lines
10 KiB
Lua

local BattleBaseUI = require "app/ui/battle/battle_base_ui"
local BattleUIPVP = class("BattleUIPVP", BattleBaseUI)
local DEFAULT_X = 10000
local BOARD_POS_UP = BF.Vector2(0, 47)
local BOARD_POS_DOWN = BF.Vector2(0, -740)
---------------------------------必须重写的方法----------------------------------
function BattleBaseUI:initBaseInfo()
local uiMap = self.root:genAllChildren()
self.uiMap = uiMap
self.gridNode = uiMap["battle_ui_pvp.board_root_node.board_node_atk.grid_node"]
self.boardNode = uiMap["battle_ui_pvp.board_root_node.board_node_atk"]
self.boardNode:setAnchoredPositionX(DEFAULT_X)
self.boardMask2D = self.gridNode:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_RECT_MASK_2D)
self.boardMask = uiMap["battle_ui_pvp.board_root_node.board_node_atk.grid_node.board_mask"]
self.boardMask:setVisible(false)
self.boardCacheNode = uiMap["battle_ui.bg_2.board_cache_node"]
self.boardCacheNode:setVisible(false)
self.boardCacheBox = uiMap["battle_ui.bg_2.board_cache_node.skill_box"]
self.boardCacheBox:setAnchoredPositionX(DEFAULT_X)
self.battleRoot = uiMap["battle_ui.battle_root"]
self.maxLayerNode = uiMap["battle_ui.battle_root.battle_node.max_layer_show_node"]
end
function BattleUIPVP:initBg()
self.bg = self.uiMap["battle_ui.battle_root.bg"]
self.bg:setLocalScale(0, 0, 0)
local width = self.bg:fastGetSizeDelta()
self.bg:setAnchoredPositionX(width/4)
end
function BattleUIPVP:initSkill()
local uiMap = self.root:genAllChildren()
local atkNode = uiMap["battle_ui_pvp.bottom_node.skill_node"]
local defNode = uiMap["battle_ui_pvp.top_node.skill_node"]
local atkCellPrefix = "battle_ui_pvp.bottom_node.skill_node.skill_node_cell_"
local defCellPrefix = "battle_ui_pvp.top_node.skill_node.skill_node_cell_"
self:_initSkill(atkNode, atkCellPrefix, defNode, defCellPrefix)
end
function BattleUIPVP:initBuff()
local atkBuffPrefix = "battle_ui_pvp.bottom_node.buff.tiny_buff_cell_"
local defBuffPrefix = "battle_ui_pvp.top_node.buff.tiny_buff_cell_"
local battleBuffTipsRoot = self.uiMap["battle_ui_pvp.battle_buff_tips"]
local battleBuffTipsMask = self.uiMap["battle_ui_pvp.battle_buff_tips.mask"]
local battleBuffTipsBg = self.uiMap["battle_ui_pvp.battle_buff_tips.bg"]
local battleBuffTipsBuff = self.uiMap["battle_ui_pvp.battle_buff_tips.bg.buff"]
self:_initBuff(atkBuffPrefix, defBuffPrefix, battleBuffTipsRoot, battleBuffTipsMask, battleBuffTipsBg, battleBuffTipsBuff)
end
function BattleUIPVP:initBattlefield()
self.battleNode = self.uiMap["battle_ui.battle_root.battle_node"]
end
function BattleUIPVP:initNumberNode()
self.battleNumberNode = self.uiMap["battle_ui_pvp.battle_root.battle_number_node"]
self.battleNumberRed = self.uiMap["battle_ui_pvp.cache_node.battle_number_red"]
self.battleNumberGreen = self.uiMap["battle_ui_pvp.cache_node.battle_number_green"]
self.battleNumberBlue = self.uiMap["battle_ui_pvp.cache_node.battle_number_blue"]
self.battleNumberWhite = self.uiMap["battle_ui_pvp.cache_node.battle_number_white"]
self.battleNumberSpecial = self.uiMap["battle_ui_pvp.cache_node.battle_number_special"]
end
function BattleBaseUI:initComboNode()
self.comboNode = self.uiMap["battle_ui_pvp.battle_root.combo"]
self.comboBg1 = self.uiMap["battle_ui_pvp.battle_root.combo.bg.bg_1"]
self.comboTx1 = self.uiMap["battle_ui_pvp.battle_root.combo.number.text.text_1"]
self.comboTx2 = self.uiMap["battle_ui_pvp.battle_root.combo.number.text.text_2"]
self.comboFx1 = self.uiMap["battle_ui_pvp.battle_root.combo.bg.vfx_ui_hit_b01"]
self.comboFx2 = self.uiMap["battle_ui_pvp.battle_root.combo.bg.vfx_ui_hit_b02"]
self.comboFx3 = self.uiMap["battle_ui_pvp.battle_root.combo.bg.vfx_ui_hit_b03"]
self:_initComboNode()
end
function BattleBaseUI:initHpNode()
self.hpProgressLeft = self.uiMap["battle_ui_pvp.bottom_node.hp_node.hp_progress"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
self.hpProgressRight = self.uiMap["battle_ui_pvp.top_node.hp_node.hp_progress"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
self.hpTextLeft = self.uiMap["battle_ui_pvp.bottom_node.hp_node.hp"]
self.hpTextRight = self.uiMap["battle_ui_pvp.top_node.hp_node.hp"]
self.hpProgressYellowLeft = self.uiMap["battle_ui_pvp.bottom_node.hp_node.hp_progress_yellow"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
self.hpProgressYellowRight = self.uiMap["battle_ui_pvp.top_node.hp_node.hp_progress_yellow"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
self:_initHpNode()
end
function BattleUIPVP:initFxNode()
self.fxNode = self.uiMap["battle_ui.battle_root.batttle_fx_node"]
end
function BattleUIPVP:hideGenerateSkillGridCells()
local generateSkillCellPrefix = "battle_ui_pvp.board_root_node.ani_node.grid_cell_"
self:_hideGenerateSkillGridCells(generateSkillCellPrefix)
end
function BattleBaseUI:initSkillLineSfx()
if not self.skillLineSfxs then
self.skillLineSfxs = {}
self.skillLineSfxs[13] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b01_2_1h"]
self.skillLineSfxs[11] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b01_2_1v"]
self.skillLineSfxs[15] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b01_2_1l"]
self.skillLineSfxs[17] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b01_2_1r"]
self.skillLineSfxs[23] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b01_1_2h"]
self.skillLineSfxs[21] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b01_1_2v"]
self.skillLineSfxs[25] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b01_1_2l"]
self.skillLineSfxs[27] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b01_1_2r"]
self.skillLineSfxs[33] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b01_3h"]
self.skillLineSfxs[31] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b01_3v"]
self.skillLineSfxs[35] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b01_3l"]
self.skillLineSfxs[37] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b01_3r"]
end
if not self.skillLightSfxs then
self.skillLightSfxs = {}
self.skillLightSfxs.point = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b03"]
self.skillLightSfxs[11] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b04_1"]
self.skillLightSfxs[12] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b04_2"]
self.skillLightSfxs[13] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b04_3"]
self.skillLightSfxs[14] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b04_4"]
self.skillLightSfxs[15] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b04_5"]
self.skillLightSfxs[21] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b05_1"]
self.skillLightSfxs[22] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b05_2"]
self.skillLightSfxs[23] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b05_3"]
self.skillLightSfxs[24] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b05_4"]
self.skillLightSfxs[25] = self.uiMap["battle_ui_pvp.board_root_node.ani_node.sfx_skill_b05_5"]
end
end
function BattleUIPVP:initGenerateSkillEffect()
local generateSkillEffecPrefix = "battle_ui_pvp.board_root_node.ani_node.grid_cell_"
self:_initGenerateSkillEffect(generateSkillEffecPrefix)
end
function BattleUIPVP:initCounterAttack()
self.counterAttackNode = self.uiMap["battle_ui_pvp.battle_root.counter_attack"]
self.counterTx = self.uiMap["battle_ui_pvp.battle_root.counter_attack.text_number"]
self.counterTxbgComp = self.uiMap["battle_ui_pvp.battle_root.counter_attack.bg"]
self.counterTxTmp = self.counterTx:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO)
self.counterAttackNode:setVisible(false)
end
--------------------------------end必须重写的方法--------------------------------
function BattleUIPVP:getPrefabPath()
return "assets/prefabs/ui/battle/battle_ui_pvp.prefab"
end
function BattleUIPVP:getBGMId()
return AudioManager.BGM_ID.BATTLE
end
function BattleUIPVP:_display()
BattleBaseUI._display(self)
self:refreshAvatar()
end
function BattleUIPVP:_addListeners()
local uiMap = self.root:genAllChildren()
uiMap["battle_ui.top_node.close_btn"]:addClickListener(function()
ModuleManager.BattleManager:showPauseUI(self.battleController.battleType)
end)
end
function BattleUIPVP:refreshAvatar()
-- 等数据
end
function BattleUIPVP:showLeftBuffTips(buffList, autoClose)
local addY = self:showBuffTips(buffList, autoClose)
self.battleBuffTipsBg:setAnchoredPosition(-175, -1018 + addY)
end
function BattleUIPVP:showRightBuffTips(buffList, autoClose)
self:showBuffTips(buffList, autoClose)
self.battleBuffTipsBg:setAnchoredPosition(175, -188)
end
function BattleUIPVP:switchBoard(downCallback, callback, isFirst)
if self.switchBoardSeq then
self.switchBoardSeq:Kill()
self.switchBoardSeq = nil
end
if isFirst then
if downCallback then
downCallback()
end
if callback then
callback()
end
self.boardNode:setAnchoredPositionY(BOARD_POS_UP.y)
return
end
self.switchBoardSeq = self.root:createBindTweenSequence()
self.switchBoardSeq:Append(self.boardNode:getTransform():DOAnchorPos(BOARD_POS_DOWN, 0.5))
self.switchBoardSeq:AppendCallback(function()
if downCallback then
downCallback()
end
end)
self.switchBoardSeq:Append(self.boardNode:getTransform():DOAnchorPos(BOARD_POS_UP, 0.5))
self.switchBoardSeq:AppendCallback(function()
if callback then
callback()
end
end)
end
function BattleUIPVP:refreshWave(wave, iconAtlas, iconName)
local uiMap = self.root:genAllChildren()
local icon = uiMap["battle_ui_pvp.bottom_node.round_icon"]
local desc = uiMap["battle_ui_pvp.bottom_node.round_text"]
desc:setText(wave)
GFunc.centerImgAndTx(icon, desc, 10)
iconAtlas = iconAtlas or GConst.ATLAS_PATH.COMMON
iconName = iconName or "common_dec_3"
icon:setSprite(iconAtlas, iconName)
end
return BattleUIPVP