miduo_client/Assets/ManagedResources/~Lua/Modules/Popup/View/GeneralPopup_HeavenUnlockEx...

210 lines
6.5 KiB
Lua
Raw Normal View History

2020-08-19 10:05:01 +08:00
----- 装备批量出售 -----
local this = {}
--传入父脚本模块
local parent
--传入特效层级
local sortingOrder=0
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
local count = 0
local rewardStateData = {}
local treasureState--礼包状态
local rewardData--表内活动数据
local curType = 0
local type = {
[1] = {name="天宫秘宝",id = 106,goodsType = GoodsTypeDef.TreasureOfHeaven},
[2] = {name="青龙秘宝",id = 5001,goodsType = GoodsTypeDef.FindBaby},
}
--初始化组件(用于子类重写)
function this:InitComponent(gameObject)
this.btnBack = Util.GetGameObject(gameObject, "frame/bg/closeBtn")
this.dealBtn = Util.GetGameObject(gameObject, "frame/bg/dealBtn")
this.Content = Util.GetGameObject(gameObject, "rewardPart/Viewport/Content")
this.box1 = Util.GetGameObject(this.Content, "scroll/box")
this.box2 = Util.GetGameObject(this.Content, "scroll2/box")
this.tip = Util.GetGameObject(this.Content, "Text"):GetComponent("Text")
this.taskList = {}
end
--绑定事件(用于子类重写)
function this:BindEvent()
Util.AddClick(this.btnBack, function()
parent:ClosePanel()
end)
Util.AddOnceClick(this.dealBtn,function()
if AppConst.isSDKLogin then
PayManager.Pay({Id = type[curType].id})
else
NetManager.RequestBuyGiftGoods(type[curType].id,function()
this.RechargeSuccessFunc()
end)
end
end)
end
function this:OnSortingOrderChange()
end
-- 打开,重新打开时回调
function this:OnShow(_parent,...)
parent=_parent
sortingOrder =_parent.sortingOrder
parent.BG:SetActive(false)
local temp = {...}
curType = temp[1]
if curType == 1 then
rewardStateData = TreasureOfHeavenManger.GetState()
rewardData = TreasureOfHeavenManger.GetAllRewardData()
this:showRewardTianGong()
elseif curType == 2 then
rewardData = QinglongSerectTreasureManager.GetAllRewardData()
this:showRewardQinglong()
end
this.tip.text = "<color=#60A22C>解锁高阶战令,激活进阶</color><color=#95523B>专属奖励+直升15级</color><color=#60A22C>解锁立获限定称号+限定气泡</color>"
end
--充值成功
function this:RechargeSuccessFunc()
PopupTipPanel.ShowTip(Language[11987])
FirstRechargeManager.RefreshAccumRechargeValue(type[curType].id)
OperatingManager.RefreshGiftGoodsBuyTimes(type[curType].goodsType,type[curType].id)
if curType == 1 then
TreasureOfHeavenManger.SetTreasureState()
Game.GlobalEvent:DispatchEvent(GameEvent.TreasureOfHeaven.RechargeSuccess)
elseif curType == 2 then
Game.GlobalEvent:DispatchEvent(GameEvent.TreasureOfHeaven.RechargeQinglongSerectSuccess)
end
parent:ClosePanel()
end
--直接/间接奖励
function this:showRewardTianGong()
local direct = {}
local indirect ={}
for i = 1, #rewardData do
if rewardStateData[i].state == 1 then--已达成但不能领取的
-- body
local reward = rewardData[i]
local k1 = reward.TreasureReward[1][1]
local v1 = reward.TreasureReward[1][2]
local k2 = reward.TreasureReward[2][1]
local v2 = reward.TreasureReward[2][2]
if not direct[k1] then
direct[k1] = 0
end
direct[k1] = direct[k1] + v1
if not direct[k2] then
direct[k2] = 0
end
direct[k2] = direct[k2] + v2
elseif rewardStateData[i].state == 0 then--未达成且不能领取的
local reward = rewardData[i]
local k1 = reward.TreasureReward[1][1]
local v1 = reward.TreasureReward[1][2]
local k2 = reward.TreasureReward[2][1]
local v2 = reward.TreasureReward[2][2]
if not indirect[k1] then
indirect[k1] = 0
end
indirect[k1] = indirect[k1] + v1
if not indirect[k2] then
indirect[k2] = 0
end
indirect[k2] = indirect[k2] + v2
end
end
if #this.taskList == 0 then
for key, value in pairs(direct) do
local item = SubUIManager.Open(SubUIConfig.ItemView, this.box1.transform)
item:OnOpen(false,{key, value},0.9)
table.insert(this.taskList,{key, value})
end
for key, value in pairs(indirect) do
local item = SubUIManager.Open(SubUIConfig.ItemView, this.box2.transform)
item:OnOpen(false,{key, value},0.9)
table.insert(this.taskList,{key, value})
end
end
end
--直接/间接奖励
function this:showRewardQinglong()
local direct = {}
local indirect ={}
for i = 1, #rewardData do
-- body
local reward = rewardData[i]
for j=1,#reward.Reward do
local id = reward.Reward[j].item[1]
local num = reward.Reward[j].item[2]
if reward.Reward[j].type == 2 then
if reward.state == 1 or reward.state == 0 then
if not direct[id] then
direct[id] = 0
end
direct[id] = direct[id] + num
elseif reward.state == -2 then
if not indirect[id] then
indirect[id] = 0
end
indirect[id] = indirect[id] + num
end
end
end
end
for i = 1,#this.taskList do
this.taskList[i].gameObject:SetActive(false)
end
local index = 1
for key, value in pairs(direct) do
if not this.taskList[index] then
local item = SubUIManager.Open(SubUIConfig.ItemView, this.box1.transform)
this.taskList[index] = item
end
this.taskList[index].gameObject:SetActive(true)
this.taskList[index]:OnOpen(false,{key, value},0.95)
index = index + 1
end
for key, value in pairs(indirect) do
if not this.taskList[index] then
local item = SubUIManager.Open(SubUIConfig.ItemView, this.box2.transform)
this.taskList[index] = item
end
this.taskList[index].gameObject:SetActive(true)
this.taskList[index]:OnOpen(false,{key, value},0.95)
index = index + 1
end
end
function this:AddListener()
end
function this:RemoveListener()
end
--界面关闭时调用(用于子类重写)
function this:OnClose()
end
--界面销毁时调用(用于子类重写)
function this:OnDestroy()
end
return this