require("Base/BasePanel") FastExploreInfoPopup = Inherit(BasePanel) local StoreConfig = ConfigManager.GetConfig(ConfigName.StoreConfig) local fightLevelConfig = ConfigManager.GetConfig(ConfigName.MainLevelConfig) local ItemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig) local this = FastExploreInfoPopup local MazeTreasureSetting = ConfigManager.GetConfig(ConfigName.MazeTreasureSetting) -- 时光沙漏数量 local costHourGlass = StoreConfig[10008].Cost[2][4] -- 时光沙漏ID local sandItemId = StoreConfig[10008].Cost[1][1] -- 妖晶ID local crystalItemId = StoreConfig[10015].Cost[1][1] -- 当前妖晶的所需消耗 local crystalNeed = 0 -- local orginLayer = 0 --初始化组件(用于子类重写) function FastExploreInfoPopup:InitComponent() this.spLoader = SpriteLoader.New() orginLayer = 0 this.imgFast = Util.GetGameObject(self.gameObject, "showMopUp/Bg/bg/title/title_fast") this.imgStatic = Util.GetGameObject(self.gameObject, "showMopUp/Bg/bg/title/title_static") this.info = Util.GetGameObject(self.gameObject, "showMopUp/Bg/bg/info") this.myInfo = Util.GetGameObject(self.gameObject, "showMopUp/Bg/bg/fastInfo") this.btnHelp = Util.GetGameObject(this.myInfo, "btnHelp") -- 妖精 this.item1 = Util.GetGameObject(this.myInfo, "item1") this.crystalNum = Util.GetGameObject(this.item1, "num"):GetComponent("Text") this.item1Left = Util.GetGameObject(this.item1, "leftTime"):GetComponent("Text") this.item1Choose = Util.GetGameObject(this.item1, "choose") -- 点击极速探索 this.btnFastExplore = Util.GetGameObject(self.gameObject, "showMopUp/Bg/bg/bottom/btn") this.btnText = Util.GetGameObject(this.btnFastExplore, "Text"):GetComponent("Text") this.itemGrid = Util.GetGameObject(self.gameObject, "showMopUp/Bg/bg/bottom/Scroll/Viewport/Content") this.itemTitle = Util.GetGameObject(self.gameObject, "showMopUp/Bg/bg/bottom/itemTitle"):GetComponent("Text") -- 两个图标的点击事件 this.btnCrystal = Util.GetGameObject(this.item1, "btnCrystal") this.iconCrystal = this.btnCrystal:GetComponent("Image") this.addCrystal = Util.GetGameObject(this.item1, "add") this.btnBack = Util.GetGameObject(self.gameObject, "mask") this.btnHelp= Util.GetGameObject(self.transform, "showMopUp/Bg/bg/fastInfo/btnHelp") this.helpPosition=this.btnHelp:GetComponent("RectTransform").localPosition this.itemList = {} this.privilege = Util.GetGameObject(self.transform, "showMopUp/Bg/bg/fastInfo/privilege") this.privilegeIcon = Util.GetGameObject(this.privilege, "Icon") this.privilegeEffect = Util.GetGameObject(this.privilege, "Icon/effect") this.privilegeContent = Util.GetGameObject(this.privilege, "Content"):GetComponent("Text") this.privilegeTimeBg = Util.GetGameObject(this.privilege, "bg") this.privilegeTime = Util.GetGameObject(this.privilege, "bg/Time"):GetComponent("Text") this.privilegeGo = Util.GetGameObject(this.privilege, "go") this.privilegeGoTxt = Util.GetGameObject(this.privilege, "go/Time"):GetComponent("Text") --this.effect = Util.GetGameObject(this.privilege, "UI_Effect_MianBan_GuaJi_Ani") end --绑定事件(用于子类重写) function FastExploreInfoPopup:BindEvent() Util.AddClick(this.btnFastExplore, function () this.HandExplore() end) Util.AddClick(this.btnBack, function () self:ClosePanel() end) --帮助按钮 Util.AddClick(this.btnHelp, function() UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.SpeedExploration,this.helpPosition.x,this.helpPosition.y) end) -- 激活特权 Util.AddClick(this.privilegeGo, function() --local isActive = PrivilegeManager.GetPrivilegeOpenStatusById(33) --if not isActive then --DynamicActivityManager.SetSelectIndex(DataType.Direct,{4002}) --JumpManager.GoJump(36006) UIManager.OpenPanel(UIName.GMShuaChongTeQuan) --end end) end --添加事件监听(用于子类重写) function FastExploreInfoPopup:AddListener() Game.GlobalEvent:AddEvent(GameEvent.Adventure.OnRefreshNextDayData, this.RefreshItemNum) Game.GlobalEvent:AddEvent(GameEvent.Shop.OnShopInfoChange, this.RefreshItemNum) Game.GlobalEvent:AddEvent(GameEvent.Bag.BagGold, this.RefreshItemNum) end --移除事件监听(用于子类重写) function FastExploreInfoPopup:RemoveListener() Game.GlobalEvent:RemoveEvent(GameEvent.Adventure.OnRefreshNextDayData, this.RefreshItemNum) Game.GlobalEvent:RemoveEvent(GameEvent.Shop.OnShopInfoChange, this.RefreshItemNum) Game.GlobalEvent:RemoveEvent(GameEvent.Bag.BagGold, this.RefreshItemNum) end --界面打开时调用(用于子类重写) function FastExploreInfoPopup:OnOpen(...) this.InitShow() this.InitRewardShow() end function this:OnShow() this.RefreshItemNum() if not RECHARGEABLE then--(是否开启充值) this.privilege:SetActive(false) end end function FastExploreInfoPopup:OnSortingOrderChange() Util.AddParticleSortLayer(this.privilegeEffect, self.sortingOrder - orginLayer) --Util.AddParticleSortLayer(this.effect, self.sortingOrder - orginLayer) orginLayer = self.sortingOrder end function this.InitShow() this.myInfo:SetActive(true) this.info:SetActive(false) this.imgStatic:SetActive(false) this.imgFast:SetActive(true) this.btnText.text = Language[10594] this.itemTitle.text = Language[10595] this.item1:GetComponent("Image").sprite = SetFrame(this.spLoader, crystalItemId) this.iconCrystal.sprite = SetIcon(this.spLoader, crystalItemId) this.item1Choose:SetActive(false) end -- 刷新道具数量 function this.RefreshItemNum() --已经花费妖晶次数+1 local count = AdventureManager.GetStoneFastBattleCount() local hasCostNumber = count + 1 local costDemonCrystalMax = StoreConfig[10015].Cost[2] -- 消耗妖晶时可探索的最大次数 local crystalMax = table.nums(costDemonCrystalMax) -- 此时需要消耗的妖精数量 local costNeed = 0 costNeed = hasCostNumber < crystalMax and costDemonCrystalMax[hasCostNumber] or costDemonCrystalMax[crystalMax] local fastMaxNum = PrivilegeManager.GetPrivilegeNumber(33) local fastBuyNum = PrivilegeManager.GetPrivilegeRemainValue(33) this.item1Left.text = Language[10049] .. fastBuyNum .. "/".. fastMaxNum.. Language[10050] crystalNeed = costNeed -- 背包中的道具数量 local fastExploreNum = BagManager.GetItemCountById(crystalItemId) local fastExploreColor = fastExploreNum >= costNeed and "#FFFFFFFF" or "#C66366FF" this.addCrystal:SetActive(false)--fastExploreNum < costNeed) this.crystalNum.text = string.format("%s", fastExploreColor, PrintWanNum2(costNeed)) local freeTimes = AdventureManager.GetSandFastBattleCount() if freeTimes ~= 0 then this.item1Left:GetComponent("Text").text = Language[10484]..freeTimes..Language[10048] this.crystalNum.text = string.format("%s", "#FFFFFFFF", 0) end Util.SetGray(this.btnFastExplore, fastBuyNum == 0 and freeTimes == 0) --local isActive = PrivilegeManager.GetPrivilegeOpenStatusById(12) local isActive =OperatingManager.IsBuyGift(2202) or ActivityGiftManager.GetActivityInfo(ActivityTypeDef.shuaChongTeQuan,2202).state>0 --Util.SetGray(this.privilegeIcon, not isActive) this.privilegeTimeBg:SetActive(false) --this.privilegeGo:SetActive(not isActive) if isActive then this.privilegeGoTxt.text="已激活" else this.privilegeGoTxt.text="去激活" end --this.effect:SetActive(not isActive) this.privilegeEffect:SetActive(isActive) -- if isActive then -- this.privilegeContent.text = Language[12241] -- else -- this.privilegeContent.text = Language[12242] -- end this.privilegeContent.text = "开通永久特权可增加极速探索每日免费及购买次数" if isActive then local leftTime = PrivilegeManager.GetPrivilegeLeftTimeById(33) this.privilegeTime.text = Language[10469]..GetLeftTimeStrByDeltaTime(leftTime) end end -- 开始探索 function this.HandExplore() FightPointPassManager.oldLevel = PlayerManager.level --Log("当前玩家等级 --- " .. PlayerManager.level) --选择了消耗妖晶 local mazeTreasureMax = ConfigManager.GetConfigData(ConfigName.PlayerLevelConfig,PlayerManager.level).MazeTreasureMax local str = Language[10597]..BagManager.GetItemCountById(FindTreasureManager.materialItemId).."/"..mazeTreasureMax.. Language[10598]..GetLanguageStrById(ConfigManager.GetConfigData(ConfigName.ItemConfig,FindTreasureManager.materialItemId).Name).. Language[10599] local isPopUp = RedPointManager.PlayerPrefsGetStr(PlayerManager.uid .. "mazeTreasureMax") local currentTime = os.date("%Y%m%d", PlayerManager.serverTime) local freeTimes = AdventureManager.GetSandFastBattleCount() if freeTimes <= 0 then local fastBuyNum = PrivilegeManager.GetPrivilegeRemainValue(33) if fastBuyNum >= 1 then if (BagManager.GetItemCountById(crystalItemId) >= crystalNeed) then if BagManager.GetItemCountById(FindTreasureManager.materialItemId) >= mazeTreasureMax and isPopUp ~= currentTime then MsgPanel.ShowTwo(str, nil, function(isShow) if (isShow) then local currentTime = os.date("%Y%m%d", PlayerManager.serverTime) RedPointManager.PlayerPrefsSetStr(PlayerManager.uid .."mazeTreasureMax", currentTime) end AdventureManager.GetAventureRewardRequest(1, 1, true, true, function(msg) this.ShowReward(msg) this.RefreshItemNum() CheckRedPointStatus(RedPointType.Expert_FastExplore) end) end,nil,nil,nil,true) else AdventureManager.GetAventureRewardRequest(1, 1, true, true, function(msg) this.ShowReward(msg) this.RefreshItemNum() CheckRedPointStatus(RedPointType.Expert_FastExplore) end) end else PopupTipPanel.ShowTip(Language[10054]) end else PopupTipPanel.ShowTip(Language[10600]) end --选择消耗时光沙漏 else if (BagManager.GetItemCountById(sandItemId) >= costHourGlass or AdventureManager.GetSandFastBattleCount() ~= 0) then if BagManager.GetItemCountById(FindTreasureManager.materialItemId) >= mazeTreasureMax and isPopUp ~= currentTime then MsgPanel.ShowTwo(str, nil, function(isShow) if (isShow) then local currentTime = os.date("%Y%m%d", PlayerManager.serverTime) RedPointManager.PlayerPrefsSetStr(PlayerManager.uid .."mazeTreasureMax", currentTime) end AdventureManager.GetAventureRewardRequest(1, 0, false, true, function(msg) this.ShowReward(msg) this:RefreshItemNum() -- 刷新红点 --this:OnRefreshRedPoint() end) end,nil,nil,nil,true) else AdventureManager.GetAventureRewardRequest(1, 0, false, true, function(msg) this.ShowReward(msg) this:RefreshItemNum() -- 刷新红点 --this:OnRefreshRedPoint() end) end else PopupTipPanel.ShowTip(Language[10054]) end end end function this.InitRewardShow() local reward = {} local r1 = fightLevelConfig[FightPointPassManager.curOpenFight].RewardShowMin local r2 = fightLevelConfig[FightPointPassManager.curOpenFight].RewardShow local open, extral = FightPointPassManager.GetExtralReward() for i = 1, #r1 do reward[#reward + 1] = r1[i] end if r2 then for j = 1, #r2 do reward[#reward + 1] = r2[j] end end if open > 0 then for m = 1, #extral do reward[#reward + 1] = extral[m] end end if #reward > 1 then table.sort(reward, function (a, b) if ItemConfig[a[1]].Quantity == ItemConfig[b[1]].Quantity then return a[1] < b[1] else return ItemConfig[a[1]].Quantity > ItemConfig[b[1]].Quantity end end) end for k = 1, #reward do if not this.itemList[k] then this.itemList[k] = SubUIManager.Open(SubUIConfig.ItemView, this.itemGrid.transform) end local item = {} local itemId = reward[k][1] item[#item + 1] = itemId item[#item + 1] = 0 if this.itemList[k] then this.itemList[k]:OnOpen(false, item, 1, true) end end end function this.ShowReward(msg) local drop = {} local normalDrop = msg.Drop local randDrop = msg.randomDrop this.AddDrop(drop, normalDrop) this.AddDrop(drop, randDrop) UIManager.OpenPanel(UIName.RewardItemPopup, drop, 1, function() end, 1) end function this.AddDrop(drop, addDrop) if not drop then drop = {} end if not drop.itemlist then drop.itemlist = {} end for _, data in ipairs(addDrop.itemlist) do table.insert(drop.itemlist, data) end if not drop.equipId then drop.equipId = {} end for _, data in ipairs(addDrop.equipId) do table.insert(drop.equipId, data) end if not drop.Hero then drop.Hero = {} end for _, data in ipairs(addDrop.Hero) do table.insert(drop.Hero, data) end -- if not drop.especialEquipId then -- drop.especialEquipId = {} -- end -- for _, data in ipairs(addDrop.especialEquipId) do -- table.insert(drop.soulEquip, data) -- end if not drop.soulEquip then drop.soulEquip = {} end for _, data in ipairs(addDrop.soulEquip) do table.insert(drop.soulEquip, data) end return drop end --界面关闭时调用(用于子类重写) function FastExploreInfoPopup:OnClose() FightPointPassManager.isBeginFight = false end --界面销毁时调用(用于子类重写) function FastExploreInfoPopup:OnDestroy() this.spLoader:Destroy() this.itemList = {} end return FastExploreInfoPopup