local MainCompBaseCell = require "app/ui/main_city/component/main_comp_base_cell" local ArenaComp = class("ArenaComp", MainCompBaseCell) local GIFT_CELL = "app/ui/main_city/cell/side_bar_arena_gift_cell" function ArenaComp:getIsOpen() return DataManager.ArenaData:isOpen(true) 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() local params = { type = GConst.TipsConst.HELP_TIPS_TYPE.ARENA, title = I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_4), desc = I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_HELP), } ModuleManager.TipsManager:showHelpTips(params) end) self.btnRecord:addClickListener(function() -- 赛季结算 if DataManager.ArenaData:isInSeasonSettlement() then GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_29)) return end 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() self:initRightBtns() 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() if not DataManager.ArenaData:isOpen(true) then return end local totalScore = DataManager.ArenaData:getScore() local maxScore = DataManager.ArenaData:getGradingScoreTotal(totalScore) local curScore = DataManager.ArenaData:getGradingScore(totalScore) 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:refreshBounty() -- 刷新战令 self:updateTimer() end function ArenaComp:updateTimer() if not DataManager.ArenaData:isOpen(true) then return end if self.seasonSettlementSid then self:getBaseObject():unscheduleGlobal(self.seasonSettlementSid) self.seasonSettlementSid = nil end if self.seasonEndSid then self:getBaseObject():unscheduleGlobal(self.seasonEndSid) self.seasonEndSid = nil end if DataManager.ArenaData:isInSeasonSettlement() then -- 结算计时器 self.seasonSettlementSid = self:getBaseObject():performWithDelayGlobal(function() ModuleManager.ArenaManager:onSeasonSettlement() end, DataManager.ArenaData:getRemainSeasonTime()) else -- 结束计时器 self.seasonEndSid = self:getBaseObject():performWithDelayGlobal(function() ModuleManager.ArenaManager:onSeasonChanged() end, DataManager.ArenaData:getRemainSeasonSettlementTime()) end -- 显示倒计时 if self.seasonChangeSid then self:getBaseObject():unscheduleGlobal(self.seasonChangeSid) end self.seasonChangeSid = self:getBaseObject():scheduleGlobal(function() self.txCountdown:setText(Time:formatNumTimeStr(DataManager.ArenaData:getRemainSeasonTime())) end, 1) end function ArenaComp:refreshTime() self:refreshRightBtns() end function ArenaComp:initRightBtns() if self.rightBtnCells then return end local uiMap = self:getUIMap() self.rightArrow = uiMap["arena_comp.right_node.arrow_node"] self.rightNode = uiMap["arena_comp.right_node"] self.rightBtnCells = {} self.rightBtnCells.giftCell = CellManager:addCellComp(uiMap["arena_comp.right_node.side_bar.side_bar_cell"], GIFT_CELL) self:refreshRightBtns() end function ArenaComp:refreshRightBtns() local y = 0 if self.rightBtnCells.giftCell:checkIsOpen() then y = y - 60 self.rightBtnCells.giftCell:setActive(true) self.rightBtnCells.giftCell:setVisible(true) self.rightBtnCells.giftCell:getBaseObject():setAnchoredPositionY(y) self.rightBtnCells.giftCell:refresh() else self.rightBtnCells.giftCell:setVisible(false) end -- 暂不处理箭头的问题 self.rightNode:setVisible(y < 0) end return ArenaComp