226 lines
7.7 KiB
Lua
226 lines
7.7 KiB
Lua
require("Base/BasePanel")
|
|
local FightAreaRewardFullPopup = Inherit(BasePanel)
|
|
local this = FightAreaRewardFullPopup
|
|
|
|
local _RewardList = {}
|
|
--初始化组件(用于子类重写)
|
|
function FightAreaRewardFullPopup:InitComponent()
|
|
this.spLoader = SpriteLoader.New()
|
|
this.btnBack = Util.GetGameObject(self.transform, "mask")
|
|
this.time = Util.GetGameObject(self.transform, "showMopUp/Bg/bg/info/time"):GetComponent("Text")
|
|
this.map = Util.GetGameObject(self.transform, "showMopUp/Bg/bg/info/map"):GetComponent("Text")
|
|
|
|
this.rewardBox = Util.GetGameObject(self.transform, "showMopUp/Bg/bg/bottom/Scroll/Viewport/Content")
|
|
this.getBtn = Util.GetGameObject(self.transform, "showMopUp/Bg/bg/bottom/btn")
|
|
|
|
-- 附加成分
|
|
this.info = Util.GetGameObject(self.gameObject, "showMopUp/Bg/bg/info")
|
|
this.fastInfo = Util.GetGameObject(self.gameObject, "showMopUp/Bg/bg/fastInfo")
|
|
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.itemTitle = Util.GetGameObject(self.gameObject, "showMopUp/Bg/bg/bottom/itemTitle"):GetComponent("Text")
|
|
|
|
end
|
|
|
|
--绑定事件(用于子类重写)
|
|
function FightAreaRewardFullPopup:BindEvent()
|
|
Util.AddClick(this.btnBack, function()
|
|
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
|
|
this:ClosePanel()
|
|
end)
|
|
Util.AddClick(this.getBtn, function()
|
|
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[10601]
|
|
local isPopUp = RedPointManager.PlayerPrefsGetStr(PlayerManager.uid .. "mazeTreasureMax")
|
|
local currentTime = os.date("%Y%m%d", PlayerManager.serverTime)
|
|
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
|
|
this.GetBtnClickEvent()
|
|
end,nil,nil,nil,true)
|
|
else
|
|
this.GetBtnClickEvent()
|
|
end
|
|
end)
|
|
end
|
|
|
|
function this.GetBtnClickEvent()
|
|
-- 保存一下当前等级,用于判断是否升级
|
|
FightPointPassManager.oldLevel = PlayerManager.level
|
|
NetManager.GetAventureRewardRequest(function(msg)
|
|
if AdventureManager.stateTime >= AdventureManager.adventureRefresh then
|
|
if AdventureManager.stateTime >= AdventureManager.adventureBoxShow[2] then
|
|
AdventureManager.stateTime = AdventureManager.adventureBoxShow[2]
|
|
end
|
|
AdventureManager.stateTime = AdventureManager.stateTime % AdventureManager.adventureRefresh
|
|
CheckRedPointStatus(RedPointType.SecretTer_MaxBoxReward)
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Adventure.OnRefeshBoxRewardShow)
|
|
end
|
|
|
|
this:ClosePanel()
|
|
local drop = {}
|
|
drop = this.AddDrop(drop, msg.Drop)
|
|
drop = this.AddDrop(drop, msg.randomDrop)
|
|
|
|
UIManager.OpenPanel(UIName.RewardItemPopup, drop, 1, function() this:ClosePanel() end, 1, false)
|
|
end, 2)
|
|
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 FightAreaRewardFullPopup:AddListener()
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function FightAreaRewardFullPopup:RemoveListener()
|
|
end
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
function FightAreaRewardFullPopup:OnOpen(...)
|
|
local curFightId = FightPointPassManager.GetCurFightId()
|
|
local config = ConfigManager.GetConfigData(ConfigName.MainLevelConfig, curFightId)
|
|
if not config then return end
|
|
|
|
-- 初始化组件显示
|
|
this.InitCompShow()
|
|
local curTime = AdventureManager.stateTime
|
|
local maxTime = AdventureManager.adventureOffline * 3600
|
|
if curTime > maxTime then
|
|
curTime = maxTime
|
|
end
|
|
this.time.text = TimeToHMS(curTime)
|
|
this.map.text = GetLanguageStrById(config.Name)
|
|
--
|
|
Util.SetGray(this.getBtn, false)
|
|
|
|
local index = 0
|
|
for _, reward in ipairs(AdventureManager.HangOnReward) do --(config.RewardShowMin) do
|
|
index = index + 1
|
|
if not _RewardList[index] then
|
|
_RewardList[index] = SubUIManager.Open(SubUIConfig.ItemView, this.rewardBox.transform)
|
|
end
|
|
_RewardList[index]:OnOpen(false, reward, 1, true)
|
|
end
|
|
|
|
local randReward = {}
|
|
if config.RewardShow then
|
|
for j = 1, #config.RewardShow do
|
|
randReward[#randReward + 1] = config.RewardShow[j]
|
|
end
|
|
end
|
|
|
|
local open, extral = FightPointPassManager.GetExtralReward()
|
|
if open > 0 then
|
|
for k = 1, #extral do
|
|
randReward[#randReward + 1] = extral[k]
|
|
end
|
|
end
|
|
|
|
for _, reward in ipairs(randReward) do
|
|
index = index + 1
|
|
if not _RewardList[index] then
|
|
_RewardList[index] = SubUIManager.Open(SubUIConfig.ItemView, this.rewardBox.transform)
|
|
end
|
|
local rdata = {reward[1], 0}
|
|
_RewardList[index]:OnOpen(false, rdata, 1, true)
|
|
end
|
|
end
|
|
|
|
function this.InitCompShow()
|
|
this.info:SetActive(true)
|
|
this.fastInfo:SetActive(false)
|
|
this.imgFast:SetActive(false)
|
|
this.imgStatic:SetActive(true)
|
|
this.itemTitle.text = Language[10602]
|
|
end
|
|
|
|
function this.GetPlayerLevelInfo(addExp)
|
|
local curLevel = PlayerManager.level
|
|
local curExp = PlayerManager.exp
|
|
local maxExp = 0
|
|
local isUp = false
|
|
|
|
local function Add()
|
|
local curLevelConfig = ConfigManager.GetConfigData(ConfigName.PlayerLevelConfig, curLevel)
|
|
if not curLevelConfig then return end
|
|
maxExp = curLevelConfig.Exp
|
|
curExp = curExp + addExp
|
|
if curExp >= maxExp then
|
|
addExp = curExp - maxExp
|
|
curExp = 0
|
|
curLevel = curLevel + 1
|
|
isUp = true
|
|
Add()
|
|
end
|
|
end
|
|
Add()
|
|
return curLevel, curExp, maxExp, isUp
|
|
end
|
|
|
|
|
|
|
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
|
function FightAreaRewardFullPopup:OnShow()
|
|
end
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
function FightAreaRewardFullPopup:OnClose()
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function FightAreaRewardFullPopup:OnDestroy()
|
|
this.spLoader:Destroy()
|
|
for _, node in ipairs(_RewardList) do
|
|
SubUIManager.Close(node)
|
|
end
|
|
_RewardList = {}
|
|
end
|
|
|
|
return FightAreaRewardFullPopup |