181 lines
6.5 KiB
Lua
181 lines
6.5 KiB
Lua
-- 竞技场:匹配
|
|
local ArenaMatchUI = class("ArenaMatchUI", BaseUI)
|
|
|
|
function ArenaMatchUI:isFullScreen()
|
|
return false
|
|
end
|
|
|
|
function ArenaMatchUI:showCommonBG()
|
|
return false
|
|
end
|
|
|
|
function ArenaMatchUI:getPrefabPath()
|
|
return "assets/prefabs/ui/arena/arena_match_ui.prefab"
|
|
end
|
|
|
|
function ArenaMatchUI:onPressBackspace()
|
|
self:closeUI()
|
|
end
|
|
|
|
function ArenaMatchUI:ctor()
|
|
end
|
|
|
|
function ArenaMatchUI:onCover()
|
|
end
|
|
|
|
function ArenaMatchUI:onReshow()
|
|
end
|
|
|
|
function ArenaMatchUI:onClose()
|
|
if self.waitSid then
|
|
ModuleManager.BattleManager:unscheduleGlobal(self.waitSid)
|
|
end
|
|
if self.countdownSid then
|
|
ModuleManager.BattleManager:unscheduleGlobal(self.countdownSid)
|
|
end
|
|
end
|
|
|
|
function ArenaMatchUI:onLoadRootComplete()
|
|
local uiMap = self.root:genAllChildren()
|
|
|
|
-- 匹配等待页
|
|
self.matchLoading = uiMap["arena_match_ui.match_loading"]
|
|
self.spineLoading = uiMap["arena_match_ui.match_loading.spine_loading"]
|
|
self.txSeason = uiMap["arena_match_ui.match_loading.tx_season"]
|
|
self.txLoading = uiMap["arena_match_ui.match_loading.tx_loading"]
|
|
self.btnCancel = uiMap["arena_match_ui.match_loading.btn_cancel"]
|
|
self.txCancel = uiMap["arena_match_ui.match_loading.btn_cancel.tx_cancel"]
|
|
|
|
-- 匹配结果页
|
|
self.matchResult = uiMap["arena_match_ui.match_result"]
|
|
self.btnClose = uiMap["arena_match_ui.match_result.btn_close"]
|
|
-- 对手信息
|
|
self.matchAvatar = CellManager:addCellComp(uiMap["arena_match_ui.match_result.match_info.player_head_cell"], GConst.TYPEOF_LUA_CLASS.PLAYER_HEAD_CELL)
|
|
self.matchTxName = uiMap["arena_match_ui.match_result.match_info.tx_name"]
|
|
self.matchTxLevel = uiMap["arena_match_ui.match_result.match_info.tx_level"]
|
|
self.matchImgGrading = uiMap["arena_match_ui.match_result.match_info.img_grading"]
|
|
self.matchTxGrading = uiMap["arena_match_ui.match_result.match_info.img_grading.tx_grading"]
|
|
-- 对手编队
|
|
self.txMatchFormation = uiMap["arena_match_ui.match_result.match_formation.tx_match_formation"]
|
|
self.matchHeroFormationComp = uiMap["arena_match_ui.match_result.match_formation.hero_formation_comp"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.HERO_FORMATION_COMP)
|
|
-- 自己编队
|
|
self.txMyFormation = uiMap["arena_match_ui.match_result.my_formation.tx_my_formation"]
|
|
self.selfHeroFormationComp = uiMap["arena_match_ui.match_result.my_formation.hero_formation_comp"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.HERO_FORMATION_COMP)
|
|
-- 功能按钮
|
|
self.btnStart = uiMap["arena_match_ui.match_result.btn_start"]
|
|
self.imgConst = uiMap["arena_match_ui.match_result.btn_start.img_const"]
|
|
self.txStart = uiMap["arena_match_ui.match_result.btn_start.tx_start"]
|
|
self.txConst = uiMap["arena_match_ui.match_result.btn_start.tx_const"]
|
|
self.btnRematch = uiMap["arena_match_ui.match_result.btn_rematch"]
|
|
self.txRematch = uiMap["arena_match_ui.match_result.btn_rematch.tx_rematch"]
|
|
self.txFreeCountdown = uiMap["arena_match_ui.match_result.btn_rematch.tx_free_countdown"]
|
|
self.imgAd = uiMap["arena_match_ui.match_result.btn_rematch.img_ad"]
|
|
self.btnFormation = uiMap["arena_match_ui.match_result.btn_formation"]
|
|
self.txFormation = uiMap["arena_match_ui.match_result.btn_formation.tx_formation"]
|
|
|
|
self.btnCancel:addClickListener(function()
|
|
self:closeUI()
|
|
end)
|
|
self.btnClose:addClickListener(function()
|
|
self:closeUI()
|
|
end)
|
|
self.btnStart:addClickListener(function()
|
|
ModuleManager.ArenaManager:reqChallenge()
|
|
self:closeUI()
|
|
end)
|
|
self.btnRematch:addClickListener(function()
|
|
-- todo 判断重新匹配状态
|
|
self:closeUI()
|
|
end)
|
|
self.btnFormation:addClickListener(function()
|
|
UIManager:showUI("app/ui/arena/arena_formation_ui")
|
|
self:closeUI()
|
|
end)
|
|
self:bind(DataManager.ArenaData, "isDirty", function()
|
|
self:onRefresh()
|
|
end)
|
|
end
|
|
|
|
function ArenaMatchUI:onRefresh()
|
|
self.matchInfo = DataManager.ArenaData:getMatchInfo()
|
|
|
|
if self.matchInfo == nil then
|
|
ModuleManager.ArenaManager:reqMatch()
|
|
self:showMatchLoading()
|
|
else
|
|
self:showMatchResult()
|
|
end
|
|
end
|
|
|
|
-- 展示匹配等待页
|
|
function ArenaMatchUI:showMatchLoading()
|
|
self.matchLoading:setActive(true)
|
|
self.matchResult:setActive(false)
|
|
|
|
self.txSeason:setText()
|
|
self.txLoading:setText(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_5))
|
|
self.txCancel:setText(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_5))
|
|
|
|
self.spineLoading:playAnimComplete("idle1", false, true, function()
|
|
self.spineLoading:playAnim("idle2", true, true)
|
|
end)
|
|
|
|
-- 等待
|
|
if self.waitSid == nil then
|
|
self.waitSid = self.matchLoading:scheduleGlobal(function()
|
|
self.matchInfo = DataManager.ArenaData:getMatchInfo()
|
|
if self.matchInfo ~= nil then
|
|
self:showMatchResult()
|
|
else
|
|
-- 居然还没获取到数据,继续等待,基本不会走到这
|
|
self:showMatchLoading()
|
|
end
|
|
end, 1.5)
|
|
end
|
|
end
|
|
|
|
-- 展示匹配结果页
|
|
function ArenaMatchUI:showMatchResult()
|
|
self.matchLoading:setActive(true)
|
|
self.matchResult:setActive(false)
|
|
|
|
self.txMatchFormation:setText(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_5))
|
|
self.txMyFormation:setText(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_5))
|
|
self.txStart:setText(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_5))
|
|
self.txConst:setText(0)
|
|
self.txRematch:setText(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_5))
|
|
self.txFormation:setText(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_5))
|
|
self.txFreeCountdown:setText(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_5))
|
|
|
|
local matchGradingId = DataManager.ArenaData:getGradingIdFromScore(self.matchInfo.score)
|
|
self.matchAvatar:refresh(self.matchInfo.avatar, self.matchInfo.avatar_frame)
|
|
self.matchTxName:setText(self.matchInfo.name)
|
|
self.matchTxLevel:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_1, self.matchInfo.level))
|
|
self.matchImgGrading:setSprite(GConst.ATLAS_PATH.ARENA, DataManager.ArenaData:getGradingIconName(matchGradingId))
|
|
self.matchTxGrading:setText(DataManager.ArenaData:getGradingName(matchGradingId))
|
|
self.matchHeroFormationComp:refreshWithOtherHero(self.matchInfo.array_heroes)
|
|
self.selfHeroFormationComp:refresh()
|
|
|
|
self.freeRematchCD = DataManager.ArenaData:getFreeRematchCd()
|
|
if self.countdownSid then
|
|
ModuleManager.BattleManager:unscheduleGlobal(self.countdownSid)
|
|
end
|
|
self.countdownSid = self.txFreeCountdown:scheduleGlobal(function()
|
|
self:refreshCountdown()
|
|
end, 1)
|
|
end
|
|
|
|
function ArenaMatchUI:refreshCountdown()
|
|
self.freeRematchCD = self.freeRematchCD - 1
|
|
if self.freeRematchCD <= 0 then
|
|
-- 冷却已好
|
|
self.txFreeCountdown:setText("")
|
|
|
|
ModuleManager.BattleManager:unscheduleGlobal(self.countdownSid)
|
|
else
|
|
-- 冷却未好
|
|
self.txFreeCountdown:setText(GFunc.getTimeStrWithHMS(self.freeRematchCD))
|
|
end
|
|
end
|
|
|
|
return ArenaMatchUI |