miduo_client/Assets/ManagedResources/~Lua/Modules/Fight/FastExploreInfoPopup.lua

371 lines
13 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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]
-- 时光沙漏ID
local sandItemId = StoreConfig[10008].Cost[1][1]
-- 妖晶ID
local crystalItemId = StoreConfig[10015].Cost[1][1]
-- 当前妖晶的所需消耗
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.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")
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
UIManager.OpenPanel(UIName.MainRechargePanel, 3)
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()
this.privilege:SetActive(false) --24暂时关闭删除这里就行
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 = Language[10557]
this.itemTitle.text = Language[10558]
this.item1:GetComponent("Image").sprite = SetFrame(crystalItemId)
this.iconCrystal.sprite = SetIcon(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[10055] .. fastBuyNum .. "/".. fastMaxNum.. Language[10056]
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("<color=%s>%s</color>", fastExploreColor, PrintWanNum2(costNeed))
local freeTimes = AdventureManager.GetSandFastBattleCount()
if freeTimes ~= 0 then
this.item1Left:GetComponent("Text").text = Language[10559]..freeTimes..Language[10054]
this.crystalNum.text = string.format("<color=%s>%s</color>", "#FFFFFFFF", 0)
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 = "<color="..colorStr..Language[10560]
if isActive then
local leftTime = PrivilegeManager.GetPrivilegeLeftTimeById(33)
this.privilegeTime.text = Language[10561]..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[10562]..BagManager.GetItemCountById(FindTreasureManager.materialItemId).."/"..mazeTreasureMax..
Language[10563]..ConfigManager.GetConfigData(ConfigName.ItemConfig,FindTreasureManager.materialItemId).Name..
Language[10564]
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()
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(Language[10060])
end
else
PopupTipPanel.ShowTip(Language[10565])
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[10060])
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.itemList = {}
end
return FastExploreInfoPopup