require("Base/BasePanel") EndLessCarbonPanel = Inherit(BasePanel) local this = EndLessCarbonPanel local endLessConfig = ConfigManager.GetConfig(ConfigName.EndlessMapConfig) local mapConfig = ConfigManager.GetConfig(ConfigName.ChallengeConfig) local hadClikcBuy = false --初始化组件(用于子类重写) function EndLessCarbonPanel:InitComponent() this.btnBack = Util.GetGameObject(self.gameObject, "btnBack") -- 显示行动力 this.energy = Util.GetGameObject(self.gameObject, "Bg/bg1/miniMap/tBottom/energy") this.curValue = Util.GetGameObject(self.energy, "energyInfo"):GetComponent("Text") this.btnBuy = Util.GetGameObject(self.energy, "add") -- 小地图 this.miniMap = Util.GetGameObject(self.gameObject, "Bg/bg1/miniMap"):GetComponent("Image") this.miniMapName = Util.GetGameObject(this.miniMap.gameObject, "tBottom/main/mapName"):GetComponent("Text") this.worldLevel = Util.GetGameObject(this.miniMap.gameObject, "tBottom/left/worldLevel"):GetComponent("Text") this.worldMode = Util.GetGameObject(this.miniMap.gameObject, "tBottom/right/worldMode"):GetComponent("Text") this.text1 = Util.GetGameObject(this.miniMap.gameObject, "tBottom/left/text"):GetComponent("Text") this.text2 = Util.GetGameObject(this.miniMap.gameObject, "tBottom/right/text"):GetComponent("Text") -- 怪物组 this.bossGrid = Util.GetGameObject(self.gameObject, "Bg/bg1/InfoRoot/bossList/grid") this.bossItemPre = Util.GetGameObject(self.gameObject, "Bg/bg1/InfoRoot/bossList/itemPre") -- 奖励预览 this.rewwardGrid = Util.GetGameObject(self.gameObject, "Bg/bg1/InfoRoot/rewardList/grid") this.btnFight = Util.GetGameObject(self.gameObject, "Bg/bg1/InfoRoot/btnFight") this.btnMapInfo = Util.GetGameObject(self.gameObject, "Bg/bg1/miniMap/mapInfo") this.btnMapInfo:SetActive(false) --幫助 this.helpBtn = Util.GetGameObject(self.gameObject, "helpBtn ") this.helpPosition = this.helpBtn:GetComponent("RectTransform").localPosition -- 行动力刷新倒计时显示 this.bgTime = Util.GetGameObject(self.energy, "Bgtime") this.actCountTime = Util.GetGameObject(this.bgTime, "time"):GetComponent("Text") --红点 this.redPoint = Util.GetGameObject(self.gameObject, "Bg/bg1/InfoRoot/btnFight/redPoint") this.rewardList = {} this.bossList = {} end --绑定事件(用于子类重写) function EndLessCarbonPanel:BindEvent() Util.AddClick(this.btnBack, function () -- !!!! PS: 这里必须是主动打开副本选择界面,从地图中返回时,这个界面的上一级是地图界面, -- 如果只是关闭自己,则会打开地图界面,不会打开副本选择界面,导致报错 PlayerManager.carbonType = 1 UIManager.OpenPanel(UIName.MainPanel) --检测到上一个面板打开之后,关闭自己 CallBackOnPanelOpen(UIName.CarbonTypePanelV2, function() UIManager.ClosePanel(UIName.EndLessCarbonPanel) end) CarbonManager.difficulty = 0 end) Util.AddClick(this.btnFight, function () this.EnterMap() end) Util.AddClick(this.btnBuy, function () ---- 先同步位置再弹出购买界面 --if not hadClikcBuy then -- hadClikcBuy = true UIManager.OpenPanel(UIName.QuickPurchasePanel, { type = 1 }) --end end) Util.AddClick(this.btnMapInfo, function () --UIManager.OpenPanel(UIName.MinMapPopup) end) --帮助按钮 Util.AddClick(this.helpBtn, function() UIManager.OpenPanel(UIName.HelpPopup, HELP_TYPE.EndLessMap, this.helpPosition.x, this.helpPosition.y) end) BindRedPointObject(RedPointType.EndlessPanel,this.redPoint) end --添加事件监听(用于子类重写) function EndLessCarbonPanel:AddListener() Game.GlobalEvent:AddEvent(GameEvent.Bag.BagGold, this.InitActPowerShow) end --移除事件监听(用于子类重写) function EndLessCarbonPanel:RemoveListener() Game.GlobalEvent:RemoveEvent(GameEvent.Bag.BagGold, this.InitActPowerShow) end --界面打开时调用(用于子类重写) function EndLessCarbonPanel:OnOpen(...) -- 初始化组件 this.InitCompShow() -- 请求获取队伍血量 -- 设置静态表数据 this.SetStaticData() this.RequestBlood(function () this.InitActPowerShow() end) end function EndLessCarbonPanel:OnSortingOrderChange() end function EndLessCarbonPanel:OnShow() this.InitActPowerShow() this.ShowCountTime() -- 界面打开时刷新队伍血量数据 -- 刷新无尽副本编队数据 EndLessMapManager.RrefreshFormation() hadClikcBuy = false end function this.InitActPowerShow() local total = EndLessMapManager.GetTotalEnergy() local curEnergy = 0 curEnergy = BagManager.GetItemCountById(1) local color = curEnergy <= 5 and "FF0014FF" or "A0B2B2FF" local str = string.format("%s", color, tostring(curEnergy)) this.curValue.text = str .. " / " .. total end function this.RequestBlood(func) NetManager.RequestAllHeroHp(function () if func then func() end end) end function this.EnterMap() -- 进入地图编队,重新赋值一遍 CarbonManager.difficulty = CARBON_TYPE.ENDLESS UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.CARBON, MapManager.curMapId) end function this.InitCompShow() --生成6个boss预设 for i = 1, 6 do if not this.bossList[i] then this.bossList[i] = newObjToParent(this.bossItemPre, this.bossGrid) this.bossList[i]:SetActive(false) end end -- 8个奖励预览 for j = 1, 8 do if not this.rewardList[j] then this.rewardList[j] = SubUIManager.Open(SubUIConfig.ItemView, this.rewwardGrid.transform) this.rewardList[j].gameObject:SetActive(false) end end end function this.SetStaticData() local mapData = endLessConfig[EndLessMapManager.openMapId] if not mapData then Log(Language[12148]) end for i = 1, #mapData.RewardShow do local item = {} local itemId = mapData.RewardShow[i][1] item[#item + 1] = itemId item[#item + 1] = 0 this.rewardList[i]:OnOpen(false, item, 1.05) -- this.rewardList[i].gameObject:SetActive(true) Timer.New(function() this.rewardList[i].gameObject:SetActive(true) PlayUIAnim(this.rewardList[i].gameObject) end, 0.001 * (i - 1)):Start() end -- 显示怪物 for j = 1, #mapData.MonsterShow do local monsterId = mapData.MonsterShow[j] local mIcon, level = MonsterCampManager.GetIconByMonsterId(monsterId) local icon = Util.GetGameObject(this.bossList[j], "icon"):GetComponent("Image") local monsterLevel = Util.GetGameObject(this.bossList[j], "imgLv/lv"):GetComponent("Text") icon.sprite = mIcon monsterLevel.text = level -- this.bossList[j]:SetActive(true) Timer.New(function() this.bossList[j]:SetActive(true) PlayUIAnim(this.bossList[j]) end, 0.001 * (j - 1)):Start() end this.worldLevel.text = PlayerManager.worldLeve --EndLessMapManager.worldLevel this.worldMode.text = MAP_MODE[mapConfig[EndLessMapManager.openMapId].DifficultType] this.text1.horizontalOverflow = GetCurLanguage() ~= 2 and 1 or 0 this.text1.alignment = GetCurLanguage() ~= 2 and "MiddleRight" or "MiddleCenter" this.text2.horizontalOverflow = GetCurLanguage() ~= 2 and 1 or 0 this.text2.alignment = GetCurLanguage() ~= 2 and "MiddleRight" or "MiddleCenter" this.miniMapName.text = GetLanguageStrById(mapData.Info) end -- 行动力是否显示倒计时 function this.ShowCountTime() if this.timer then this.timer:Stop() end this.timer = nil this.actCountTime.text = "" this.bgTime:SetActive(not EndLessMapManager.EnergyEnough()) -- 初始化是判断一次 if not EndLessMapManager.EnergyEnough() then -- 启动倒计时 this.timer = Timer.New(function () local leftTime = AutoRecoverManager.GetRecoverTime(1) if EndLessMapManager.EnergyEnough()then -- 回复满了,在地图外面可以停止计时器 this.timer:Stop() this.bgTime:SetActive(false) else this.actCountTime.text = GetTimeMaoHaoStrBySeconds(math.floor(leftTime)) end end, 1, -1, true) this.timer:Start() end end --界面关闭时调用(用于子类重写) function EndLessCarbonPanel:OnClose() if this.timer then this.timer:Stop() this.timer = nil end end --界面销毁时调用(用于子类重写) function EndLessCarbonPanel:OnDestroy() ClearRedPointObject(RedPointType.EndlessPanel,this.redPoint) this.rewardList = {} this.bossList = {} end return EndLessCarbonPanel