require("Base/BasePanel") local WorldArenaMainPanel = Inherit(BasePanel) local this = WorldArenaMainPanel local arenaBattleReward = ConfigManager.GetConfig(ConfigName.ArenaBattleReward) local MServerRankConfig=ConfigManager.GetConfig(ConfigName.MServerRankConfig) local rewardBoxBtn local titleLive local myRank=0 local leftTimes=0 local battleTimes=0 local rewardState=nil local enemyList={} --初始化组件(用于子类重写) function WorldArenaMainPanel:InitComponent() this.spLoader = SpriteLoader.New() this.btnBack = Util.GetGameObject(self.gameObject, "btnBack") this.ArenaName = Util.GetGameObject(self.gameObject, "nameImg/name") this.ArenaTime = Util.GetGameObject(self.gameObject, "timelab") this.Integral = Util.GetGameObject(self.gameObject, "myScore/integral"):GetComponent("Text") this.endTime = Util.GetGameObject(self.gameObject, "myScore/Text"):GetComponent("Text") this.rankPar= Util.GetGameObject(self.gameObject, "center/ranks") this.rankName= Util.GetGameObject(self.gameObject, "center/Text"):GetComponent("Text") this.StarList={} for i = 1, 5 do table.insert(this.StarList, Util.GetGameObject(self.gameObject, "starPar/Image"..i)) end this.Enemys = {} for i = 1, 5 do table.insert(this.Enemys, Util.GetGameObject(self.gameObject, "challengebox/enemy_"..i)) end --右侧按钮 this.RecordBtn = Util.GetGameObject(self.gameObject, "rightUp/record") this.RefreshBtn = Util.GetGameObject(self.gameObject, "refresh") this.RewardBtn = Util.GetGameObject(self.gameObject, "rightUp/reward") this.StoreBtn = Util.GetGameObject(self.gameObject, "rightUp/store") this.sortBtn = Util.GetGameObject(self.gameObject, "rightUp/sortBtn") this.helpBtn = Util.GetGameObject(self.gameObject, "rightUp/helpBtn") this.helpPosition=this.helpBtn:GetComponent("RectTransform").localPosition this.FormationBtn = Util.GetGameObject(self.gameObject, "rightUp/formationBtn") --this.rank=Util.GetGameObject(this.myRank,"Rank"):GetComponent("Text") this.power=Util.GetGameObject(self.gameObject,"powerImg/Power"):GetComponent("Text") --宝箱部分 this.progressImage = Util.GetGameObject(self.gameObject, "finalTarget/progressbar/progress"):GetComponent("Image") this.progressTipText = Util.GetGameObject(self.gameObject, "finalTarget/Text (1)"):GetComponent("Text") rewardBoxBtn = {} this.freeTimes = Util.GetGameObject(self.gameObject, "count/text"):GetComponent("Text") for i = 1, 5 do rewardBoxBtn[i] = Util.GetGameObject(self.gameObject, "finalTarget/rewardProgress/rewardBoxBtn (" .. i .. ")") --rewardBoxBtn[i].transform.localPosition = Vector3.New(arenaBattleReward[i].Position[1], arenaBattleReward[i].Position[2] ,0) end -- 上部货币显示 this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.transform, { showType = UpViewOpenType.ShowLeft}) end --绑定事件(用于子类重写) function WorldArenaMainPanel:BindEvent() Util.AddClick(this.btnBack, function() PlaySoundWithoutClick(SoundConfig.Sound_UICancel) this:ClosePanel() end) -- 防守编队 Util.AddClick(this.FormationBtn, function() -- if not ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.ARENA) then -- PopupTipPanel.ShowTip(Language[10075]) -- return -- end -- UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.ARENA_DEFEND) UIManager.OpenPanel(UIName.WorldArenaMyTeamPanel,1) --UIManager.OpenPanel(UIName.WorldArenaBattleInfoPanel) end) -- 挑战按钮 for i, enemy in ipairs(this.Enemys) do local challengeBtn = Util.GetGameObject(enemy, "challenge") Util.AddClick(challengeBtn, function() if not ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.ARENA) then PopupTipPanel.ShowTip(Language[10075]) return end -- 只在活动时间范围内可点 if ArenaManager.GetLeftTime() > 0 then -- 添加次数限制 --local leftTimes = WorldArenaManager.GetArenaChallengeTimes() if leftTimes <= 0 then local itemId, needNum = WorldArenaManager.GetArenaChallengeCost() local haveNum = BagManager.GetItemCountById(itemId) if haveNum < needNum then UIManager.OpenPanel(UIName.QuickPurchasePanel, { type = UpViewRechargeType.ChallengeTicket }) PopupTipPanel.ShowTip("邀请函不足!") return end end LogError("/////////////////") NetManager.CrossYuXuLunDaoChallengeBeforeRequest(PlayerManager.uid,enemyList[i],function(msg) LogError("open battleinfo ???") UIManager.OpenPanel(UIName.WorldArenaBattleInfoPanel,msg,1) end) else PopupTipPanel.ShowTip(Language[10092]) end end) end --排行 Util.AddClick(this.sortBtn, function() UIManager.OpenPanel(UIName.RankingSingleListPanel,rankKingList[27]) end) -- 刷新按钮 Util.AddClick(this.RefreshBtn, function() PlaySoundWithoutClick("UI_refresh") if not ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.ARENA) then PopupTipPanel.ShowTip(Language[10075]) return end NetManager.CrossYuXuLunDaoChangeEnemyInfoRequest(function(msg) this:RefreshEnemyData(msg.arenaEnemys) end) end) -- 记录按钮 Util.AddClick(this.RecordBtn, function() if not ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.ARENA) then PopupTipPanel.ShowTip(Language[10075]) return end UIManager.OpenPanel(UIName.WorldArenaRecordPopup) ResetServerRedPointStatus(RedPointType.Arena_Record) end) -- 帮助按钮 Util.AddClick(this.helpBtn, function() UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.Arena,this.helpPosition.x,this.helpPosition.y) end) -- 奖励按钮 Util.AddClick(this.RewardBtn, function() UIManager.OpenPanel(UIName.WorldArenaRankRewardPanel,myRank) --UIManager.OpenPanel(UIName.WorldArenaUpRewardPanel,3,2) --UIManager.OpenPanel(UIName.WorldArenaMyTeamPanel, FORMATION_TYPE.ARENA_DEFEND) end) --商店按钮 Util.AddClick(this.StoreBtn, function() if not ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.JumpServer_YuXu) then PopupTipPanel.ShowTip(Language[10075]) return end JumpManager.GoJump(40032) end) end --添加事件监听(用于子类重写) function WorldArenaMainPanel:AddListener() end --移除事件监听(用于子类重写) function WorldArenaMainPanel:RemoveListener() end local grid, rankData --界面打开时调用(用于子类重写) function WorldArenaMainPanel:OnOpen(...) -- 参数保存 local args = {...} NetManager.CrossYuXuLunDaoGetInfoRequest(function(msg) local currRankId=msg.newLevelId grid, rankData=WorldArenaManager.GetRankImgByScore(msg.newMyscore) --rankData=ConfigManager.GetConfigData(ConfigName.MServerRankConfig,currRankId) battleTimes=msg.changedTimes rewardState=msg.dailyRewardState leftTimes=msg.freeTimes WorldArenaManager.SetFreeTime(leftTimes) this.Integral.text="积分:"..msg.newMyscore this.SetStarShow(grid,self.sortingOrder) this.endTime.text="周日23:30赛季结束" LogError("len==="..#msg.arenaEnemys) this:RefreshEnemyData(msg.arenaEnemys) myRank=msg.myRank this.freeTimes.text = string.format("%s次", math.max(leftTimes, 0)) end) end --星级和段位图标显示 function this.SetStarShow(grade,layer) -- 设置星级 WorldArenaManager.SetStarShow(this.StarList, rankData.RankLevel) titleLive = poolManager:LoadAsset("fx_duanwei_0"..grade, PoolManager.AssetType.GameObject) titleLive.transform:SetParent(this.rankPar.transform) titleLive.transform.localPosition=Vector3.New(0,-600,0) titleLive.transform.localScale =Vector3.New(1,1,1) AddParticleSortLayer(titleLive,layer) this.rankName.text=rankData.RankName --this.RefreshEnemyData() this.ShowRewardBoxProgressData() end --显示上边积分奖励 function this.ShowRewardBoxProgressData() -- local baseData = ArenaManager.GetArenaBaseData() local allNums = battleTimes --宝箱领取状态 local allBoxGetState = rewardState local maxNum = 0 local config=ConfigManager.GetConfigDataByKey(ConfigName.MServerRankConfig,1) local rewards=config.DailyReward for i = 1, #rewards do if rewards[i][1]>maxNum then maxNum=rewards[i][1] end end for i = 1, #allBoxGetState do LogError("state=="..allBoxGetState[i]) end for i = 1, #rewardBoxBtn do if rewards[i] then local state = 1--1 未完成 2 未领取 3 已完成allNums >= arenaBattleReward[i].BattleTimes and false if allNums < rewards[i][1] then state = 1 elseif allNums >= rewards[i][1] and not allBoxGetState[i]==1 then state = 2 else state = 3 end Util.GetGameObject(rewardBoxBtn[i], "redPoint"):SetActive(state == 2) Util.GetGameObject(rewardBoxBtn[i], "Text"):GetComponent("Text").text = rewards[i][1]..Language[10048] Util.GetGameObject(rewardBoxBtn[i], "getFinish"):SetActive(state == 3) Util.AddOnceClick(rewardBoxBtn[i], function() if state == 1 then UIManager.OpenPanel(UIName.BoxRewardShowPopup,rewards[i][2].."#"..rewards[i][3],rewardBoxBtn[i].transform.localPosition.x,-400,rewards[i][1] .. Language[10100]) return elseif state == 3 then PopupTipPanel.ShowTip(Language[10101]) return elseif state == 2 then NetManager.TakeArenaBattleRewardRequest(i, function(msg) UIManager.OpenPanel(UIName.RewardItemPopup, msg.drop, 1,function () this.ShowRewardBoxProgressData() CheckRedPointStatus(RedPointType.Arena_Reward) end) end) end end) end end this.progressImage.fillAmount = allNums/maxNum this.progressTipText.text = Language[10102]..allNums..Language[10048] end -- 刷新敌人列表 function this:RefreshEnemyData(team) local prefab = {} --local leftTimes=time table.sort(team, function(a,b) return a.score > b.score end) local EnemyList =team -- ArenaManager.GetEnemyList() enemyList={} for i, node in ipairs(this.Enemys) do node:SetActive(false) if EnemyList[i] then table.insert(prefab,node) local lv_name = Util.GetGameObject(node, "name"):GetComponent("Text") local integral = Util.GetGameObject(node, "integralTip"):GetComponent("Text") -- Util.GetGameObject(node, "power"):SetActive(false) -- Util.GetGameObject(node, "integral"):SetActive(false) local power = Util.GetGameObject(node, "powerTip") local headroot = Util.GetGameObject(node, "headroot") local bg = Util.GetGameObject(node, "bg") local btnText = Util.GetGameObject(node, "challenge/Text"):GetComponent("Text") local btnItem = Util.GetGameObject(node, "challenge/item"):GetComponent("Image") local btnItemNum = Util.GetGameObject(node, "challenge/item/num"):GetComponent("Text") local rankImg= Util.GetGameObject(node, "rankImg"):GetComponent("Image") local rankId=WorldArenaManager.GetRankImgByScore(EnemyList[i].score) rankImg.sprite=this.spLoader:LoadSprite("y_yuxulundao_xiaobiao_0"..rankId) local name=EnemyList[i].servername.." "..EnemyList[i].name lv_name.text = PracticeManager.SetNameColor(JingJiShouWeiToEn(name),EnemyList[i].practiceLevel) integral:GetComponent("Text").text = Language[11693].. EnemyList[i].score power:GetComponent("Text").text = Language[12179]..EnemyList[i].totalForce btnText.gameObject:SetActive(leftTimes > 0) btnText.text = Language[10099] btnItem.gameObject:SetActive(leftTimes <= 0) if leftTimes <= 0 then local itemId, needNum = WorldArenaManager.GetArenaChallengeCost() local haveNum = BagManager.GetItemCountById(itemId) btnItem.sprite = SetIcon(this.spLoader, itemId) btnItemNum.text = "×"..needNum btnItemNum.color = haveNum < needNum and UIColor.NOT_ENOUGH_RED or UIColor.BTN_TEXT end if not this.HeadList then this.HeadList = {} end if not this.HeadList[i] then this.HeadList[i] = SubUIManager.Open(SubUIConfig.PlayerHeadView, headroot.transform) end this.HeadList[i]:Reset() this.HeadList[i]:SetHead(EnemyList[i].head) this.HeadList[i]:SetFrame(EnemyList[i].headFrame) this.HeadList[i]:SetLevel(EnemyList[i].level) this.HeadList[i]:SetScale(Vector3.one*0.8) this.HeadList[i]:SetLayer(this.sortingOrder) this.HeadList[i]:SetEffectScale(0.85) table.insert(enemyList,EnemyList[i].uid) Util.AddOnceClick(bg, function() LogError("uid=="..EnemyList[i].uid) UIManager.OpenPanel(UIName.WorldArenaOtherTeamPanel, EnemyList[i].uid,1) end) end end SecTorPlayAnim(prefab) end -- 打开,重新打开时回调 function WorldArenaMainPanel:OnShow() SoundManager.PlayMusic(SoundConfig.BGM_Arena) end function WorldArenaMainPanel:OnSortingOrderChange() end --界面关闭时调用(用于子类重写) function WorldArenaMainPanel:OnClose() end --界面销毁时调用(用于子类重写) function WorldArenaMainPanel:OnDestroy() SubUIManager.Close(this.UpView) -- 清除红点 -- ClearRedPointObject(RedPointType.Arena_Shop) this.spLoader:Destroy() if this.shopView then this.shopView.gameObject:SetActive(true) -- 重置一下显示状态,避免其他界面打开时状态错误 this.shopView = SubUIManager.Close(this.shopView) this.shopView = nil end if this.HeadList then for i = 1, #this.HeadList do this.HeadList[i]:Recycle() this.HeadList[i]=nil end end end -- function this.OpenView(index) -- 货币界面 this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Arena }) end function this.CloseView(index) if this._CurLogicIndex ~= index then return end -- 商店界面特殊处理 if index == 3 then if this.shopView then this.shopView.gameObject:SetActive(false) end return end local logic = this.ViewLogicList[index] if logic then if logic.RemoveListener then logic:RemoveListener() end if logic.OnClose then logic:OnClose() end logic.gameObject:SetActive(false) end end return WorldArenaMainPanel