146 lines
6.1 KiB
Lua
146 lines
6.1 KiB
Lua
local MainCompBaseCell = require "app/ui/main_city/component/main_comp_base_cell"
|
|
local ArenaComp = class("ArenaComp", MainCompBaseCell)
|
|
|
|
function ArenaComp:getIsOpen()
|
|
return DataManager.ArenaData:isOpen()
|
|
end
|
|
|
|
function ArenaComp:getEntranceName()
|
|
return I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_1)
|
|
end
|
|
|
|
function ArenaComp:getFightDesc()
|
|
return I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_2)
|
|
end
|
|
|
|
function ArenaComp:onClickFight()
|
|
UIManager:showUI("app/ui/arena/arena_match_ui")
|
|
end
|
|
|
|
function ArenaComp:getShowEntranceRedPoint()
|
|
return DataManager.ArenaData:hasEntranceRedDot()
|
|
end
|
|
|
|
function ArenaComp:ctor()
|
|
end
|
|
|
|
function ArenaComp:init()
|
|
local uiMap = self:getBaseObject():genAllChildren()
|
|
|
|
self.txSeason = uiMap["arena_comp.tx_season"]
|
|
self.txTitle = uiMap["arena_comp.tx_title"]
|
|
self.txCountdown = uiMap["arena_comp.countdown.tx_time"]
|
|
self.txGarding = uiMap["arena_comp.tx_garding"]
|
|
self.imgGarding = uiMap["arena_comp.img_garding"]
|
|
self.imgProg = uiMap["arena_comp.prog.img_prog"]
|
|
self.txProg = uiMap["arena_comp.prog.tx_prog"]
|
|
self.btnHelp = uiMap["arena_comp.tx_season.btn_help"]
|
|
self.btnRecord = uiMap["arena_comp.btn_record"]
|
|
self.txRecord = uiMap["arena_comp.btn_record.tx_record"]
|
|
self.btnFormation = uiMap["arena_comp.btn_formation"]
|
|
self.txFormation = uiMap["arena_comp.btn_formation.tx_formation"]
|
|
self.btnReward = uiMap["arena_comp.btn_reward"]
|
|
self.txReward = uiMap["arena_comp.btn_reward.tx_reward"]
|
|
self.btnRank = uiMap["arena_comp.btn_rank"]
|
|
self.txRank = uiMap["arena_comp.btn_rank.tx_rank"]
|
|
|
|
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_4))
|
|
self.txRecord:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_7))
|
|
self.txFormation:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_9))
|
|
self.txReward:setText(I18N:getGlobalText(I18N.GlobalConst.REWARD_DESC))
|
|
self.txRank:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_5))
|
|
|
|
self.btnHelp:addClickListener(function()
|
|
ModuleManager.TipsManager:showDescTips(DataManager.DungeonData:getRule(self.moduleKey), self.btnHelp)
|
|
end)
|
|
self.btnRecord:addClickListener(function()
|
|
UIManager:showUI("app/ui/arena/arena_recent_battle_ui")
|
|
end)
|
|
self.btnFormation:addClickListener(function()
|
|
UIManager:showUI("app/ui/arena/arena_formation_ui", GConst.BattleConst.FORMATION_TYPE.ARENA_DEFEND)
|
|
end)
|
|
self.btnReward:addClickListener(function()
|
|
UIManager:showUI("app/ui/arena/arena_season_reward_ui")
|
|
end)
|
|
self.btnRank:addClickListener(function()
|
|
UIManager:showUI("app/ui/arena/arena_rank_ui")
|
|
end)
|
|
self:initBounty()
|
|
self:refreshShow()
|
|
end
|
|
|
|
function ArenaComp:initBounty()
|
|
local uiMap = self:getBaseObject():genAllChildren()
|
|
|
|
self.bountyNode = uiMap["arena_comp.bounty_node"]
|
|
self.bountyBanner = uiMap["arena_comp.bounty_node.banner"]
|
|
self.bountyBanner:addClickListener(function()
|
|
ModuleManager.ArenaBountyManager:showBountyMainUI()
|
|
end)
|
|
self.bountyRewardSpine = uiMap["arena_comp.bounty_node.banner.spine"]
|
|
self.bountyBannerInfo = uiMap["arena_comp.bounty_node.banner.info"]
|
|
self.bountyBannerDescTx = uiMap["arena_comp.bounty_node.banner.desc"]
|
|
self.bountyBannerSlider = uiMap["arena_comp.bounty_node.banner.info.progress_bg.slider"]
|
|
self.bountyBannerSliderTx = uiMap["arena_comp.bounty_node.banner.info.progress_bg.slider_tx"]
|
|
self.bountyBannerLvTx = uiMap["arena_comp.bounty_node.banner.info.progress_bg.lv_tx"]
|
|
uiMap["arena_comp.bounty_node.banner.info.name"]:setText(I18N:getGlobalText(I18N.GlobalConst.BOUNTY_TITLE))
|
|
end
|
|
|
|
function ArenaComp:refreshBounty()
|
|
if DataManager.ArenaBountyData:getIfCanClaimReward() then
|
|
self.bountyRewardSpine:setVisible(true)
|
|
self.bountyRewardSpine:playAnim("idle", true)
|
|
self.bountyRewardSpine:getSkeletonGraphic().enabled = true
|
|
self.bountyBannerInfo:setVisible(false)
|
|
self.bountyBannerDescTx:setText(I18N:getGlobalText(I18N.GlobalConst.COLLET_REWARDS))
|
|
else
|
|
self.bountyRewardSpine:setVisible(false)
|
|
self.bountyRewardSpine:getSkeletonGraphic().enabled = false
|
|
local bannerName = DataManager.ArenaBountyData:getBannerName()
|
|
self.bountyBanner:setSprite(GConst.ATLAS_PATH.BOUNTY, bannerName)
|
|
self.bountyBannerInfo:setVisible(true)
|
|
self.bountyBannerDescTx:setText(GConst.EMPTY_STRING)
|
|
local exp = DataManager.ArenaBountyData:getExp()
|
|
local lvUpExp = DataManager.ArenaBountyData:getLvUpExp()
|
|
local level = DataManager.ArenaBountyData:getLevel()
|
|
local maxLevel = DataManager.ArenaBountyData:getMaxLevel()
|
|
self.bountyBannerSliderTx:setText(exp .. "/" .. lvUpExp)
|
|
self.bountyBannerSlider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = exp / lvUpExp
|
|
if level >= maxLevel then
|
|
self.bountyBannerLvTx:setText(I18N:getGlobalText(I18N.GlobalConst.STR_MAX))
|
|
else
|
|
self.bountyBannerLvTx:setText(tostring(level))
|
|
end
|
|
end
|
|
end
|
|
|
|
function ArenaComp:refreshShow()
|
|
local maxScore = DataManager.ArenaData:getGradingScoreTotal()
|
|
local curScore = DataManager.ArenaData:getGradingScore()
|
|
self.txSeason:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_3, DataManager.ArenaData:getSeason()))
|
|
self.txGarding:setText(DataManager.ArenaData:getGradingName(DataManager.ArenaData:getGradingId()))
|
|
self.txProg:setText(curScore.."/"..maxScore)
|
|
self.imgProg:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = curScore/maxScore
|
|
|
|
self.seasonChangeCD = DataManager.ArenaData:getRemainSeasonTime()
|
|
if self.seasonChangeSid then
|
|
ModuleManager.BattleManager:unscheduleGlobal(self.seasonChangeSid)
|
|
end
|
|
self.seasonChangeSid = self.txCountdown:scheduleGlobal(function()
|
|
self:refreshCountdown()
|
|
end, 1)
|
|
|
|
self:refreshBounty() -- 刷新战令
|
|
end
|
|
|
|
function ArenaComp:refreshCountdown()
|
|
self.seasonChangeCD = self.seasonChangeCD - 1
|
|
if self.seasonChangeCD < 0 then
|
|
ModuleManager.ArenaManager:onSeasonChanged()
|
|
return
|
|
end
|
|
|
|
self.txCountdown:setText(Time:formatNumTimeStr(self.seasonChangeCD))
|
|
end
|
|
|
|
return ArenaComp |