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 costHourGlass = StoreConfig[10008].Cost[2][4] local CHOOSE_STATE = { CRYSTAL = 1, SAND = 2, } -- 时光沙漏ID local sandItemId = StoreConfig[10008].Cost[1][1] -- 妖晶ID local crystalItemId = StoreConfig[10015].Cost[1][1] -- 当前的选中状态 local m_index = CHOOSE_STATE.CRYSTAL -- 当前妖晶的所需消耗 local crystalNeed = 0 --初始化组件(用于子类重写) function FastExploreInfoPopup:InitComponent() 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.sandyCan = Util.GetGameObject(self.gameObject, "item2") this.canNum = Util.GetGameObject(this.sandyCan, "num"):GetComponent("Text") this.sanTip = Util.GetGameObject(this.sandyCan, "tip") this.sanChoose = Util.GetGameObject(this.sandyCan, "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.exploreRedPoint = Util.GetGameObject(this.sandyCan, "redpoint") this.itemTitle = Util.GetGameObject(self.gameObject, "showMopUp/Bg/bg/bottom/itemTitle"):GetComponent("Text") -- 两个图标的点击事件 this.btnCrystal = Util.GetGameObject(this.item1, "btnCrystal") this.btnSand = Util.GetGameObject(this.sandyCan, "btnSand") this.iconCrystal = this.btnCrystal:GetComponent("Image") this.iconSand = this.btnSand:GetComponent("Image") this.addCrystal = Util.GetGameObject(this.item1, "add") this.addSand = Util.GetGameObject(this.sandyCan, "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") end --绑定事件(用于子类重写) function FastExploreInfoPopup:BindEvent() Util.AddClick(this.btnCrystal, function () this.SetChooseIndex(CHOOSE_STATE.CRYSTAL, false) end) Util.AddClick(this.btnSand, function () this.SetChooseIndex(CHOOSE_STATE.SAND, false) end) 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 UIManager.OpenPanel(UIName.OperatingPanel, {tabIndex = 1, extraParam = 4}) 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() if AdventureManager.GetSandFastBattleCount() ~= 0 or BagManager.GetItemCountById(sandItemId) >= costHourGlass then this.SetChooseIndex(CHOOSE_STATE.SAND, false) m_index = CHOOSE_STATE.SAND else this.SetChooseIndex(CHOOSE_STATE.CRYSTAL, true) m_index = CHOOSE_STATE.CRYSTAL end end function this:OnShow() this.RefreshItemNum() end -- local orginLayer = -1 function this:OnSortingOrderChange() Util.AddParticleSortLayer(this.privilegeEffect, 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 = "极速探索" this.itemTitle.text = "概率掉落" this.item1:GetComponent("Image").sprite = SetFrame(crystalItemId) this.sandyCan:GetComponent("Image").sprite = SetFrame(sandItemId) this.iconCrystal.sprite = SetIcon(crystalItemId) this.iconSand.sprite = SetIcon(sandItemId) this.item1Choose:SetActive(true) this.sanChoose:SetActive(false) this.exploreRedPoint:SetActive(AdventureManager.GetSandFastBattleCount() ~= 0) 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 fastBuyNum = PrivilegeManager.GetPrivilegeRemainValue(33) this.item1Left.text = "(剩余" .. fastBuyNum .. "次)" crystalNeed = costNeed -- 背包中的道具数量 local timeCanNum = BagManager.GetItemCountById(sandItemId) local fastExploreNum = BagManager.GetItemCountById(crystalItemId) local fastExploreColor = fastExploreNum >= costNeed and "#FFFFFFFF" or "#C66366FF" local timeSandColor = timeCanNum >= costHourGlass and "#FFFFFFFF" or "#C66366FF" this.addCrystal:SetActive(fastExploreNum < costNeed) this.addSand:SetActive(timeCanNum < costHourGlass and AdventureManager.GetSandFastBattleCount() == 0) this.crystalNum.text = string.format("%s/%d ", fastExploreColor, tostring(PrintWanNum2(fastExploreNum)), PrintWanNum2(costNeed)) local item2Text = "" local freeTimes = AdventureManager.GetSandFastBattleCount() if freeTimes ~= 0 then this.sanTip:SetActive(true) this.sanTip:GetComponent("Text").text = "免费"..freeTimes.."次" this.canNum.gameObject:SetActive(false) else item2Text = string.format("%s/%d ", timeSandColor, tostring(PrintWanNum2(timeCanNum)), PrintWanNum2(costHourGlass)) this.canNum.text = item2Text this.sanTip:SetActive(false) this.canNum.gameObject:SetActive(true) end local isActive = PrivilegeManager.GetPrivilegeOpenStatusById(33) Util.SetGray(this.privilegeIcon, not isActive) this.privilegeTimeBg:SetActive(isActive) this.privilegeGo:SetActive(not isActive) this.privilegeEffect:SetActive(isActive) local colorStr = isActive and "#FFA278" or "#B7B7B7" this.privilegeContent.text = "极速探索特权:每天增加免费3次,增加购买3次" if isActive then local leftTime = PrivilegeManager.GetPrivilegeLeftTimeById(33) this.privilegeTime.text = "剩余:"..GetLeftTimeStrByDeltaTime(leftTime) end end -- 设置选中状态 function this.SetChooseIndex(index, isInit) if not isInit then this.item1Choose:SetActive(index == CHOOSE_STATE.CRYSTAL) this.sanChoose:SetActive(index == CHOOSE_STATE.SAND) m_index = index -- 看看道具是否充足 local itemId = index == CHOOSE_STATE.SAND and sandItemId or crystalItemId local I_Have_In_Bag = BagManager.GetItemCountById(itemId) local numNeed = index == CHOOSE_STATE.SAND and costHourGlass or crystalNeed local func = function() if index == CHOOSE_STATE.SAND then --if ShopManager.IsActive(SHOP_TYPE.NOVICE_GIFT_SHOP) and ShopManager.CheckNoviceGiftData() then JumpManager.GoJump(36007) --else -- Log("新手礼包已卖完") --end elseif index == CHOOSE_STATE.CRYSTAL then UIManager.OpenPanel(UIName.QuickPurchasePanel, { type = UpViewRechargeType.DemonCrystal }) end end -- 时光沙漏首次免费 if index == CHOOSE_STATE.SAND then if AdventureManager.GetSandFastBattleCount() == 0 then if I_Have_In_Bag < numNeed then func() else --this.item1Choose:SetActive(index == CHOOSE_STATE.CRYSTAL) --this.sanChoose:SetActive(index == CHOOSE_STATE.SAND) --m_index = index end else --this.item1Choose:SetActive(index == CHOOSE_STATE.CRYSTAL) --this.sanChoose:SetActive(index == CHOOSE_STATE.SAND) --m_index = index end else if I_Have_In_Bag < numNeed then func() else --this.item1Choose:SetActive(index == CHOOSE_STATE.CRYSTAL) --this.sanChoose:SetActive(index == CHOOSE_STATE.SAND) --m_index = index end end end end -- 开始探索 function this.HandExplore() FightPointPassManager.oldLevel = PlayerManager.level --Log("当前玩家等级 --- " .. PlayerManager.level) --选择了消耗妖晶 local mazeTreasureMax = ConfigManager.GetConfigData(ConfigName.PlayerLevelConfig,PlayerManager.level).MazeTreasureMax local str = "当前拥有"..BagManager.GetItemCountById(FindTreasureManager.materialItemId).."/"..mazeTreasureMax.. "的"..ConfigManager.GetConfigData(ConfigName.ItemConfig,FindTreasureManager.materialItemId).Name.. ",极速探索后数量溢出的部分将会丢失,是否继续?" local isPopUp = RedPointManager.PlayerPrefsGetStr(PlayerManager.uid .. "mazeTreasureMax") local currentTime = os.date("%Y%m%d", PlayerManager.serverTime) if (m_index == CHOOSE_STATE.CRYSTAL) 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() end) end,nil,nil,nil,true) else AdventureManager.GetAventureRewardRequest(1, 1, true, true, function(msg) this.ShowReward(msg) this.RefreshItemNum() end) end else PopupTipPanel.ShowTip("道具不足") end else PopupTipPanel.ShowTip("极速探索次数不足") 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() this.exploreRedPoint:SetActive(AdventureManager.GetSandFastBattleCount() ~= 0) end) end,nil,nil,nil,true) else AdventureManager.GetAventureRewardRequest(1, 0, false, true, function(msg) this.ShowReward(msg) this:RefreshItemNum() -- 刷新红点 --this:OnRefreshRedPoint() this.exploreRedPoint:SetActive(AdventureManager.GetSandFastBattleCount() ~= 0) end) end else PopupTipPanel.ShowTip("道具不足") 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 for j = 1, #r2 do reward[#reward + 1] = r2[j] 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.itemList = {} end return FastExploreInfoPopup