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

243 lines
8.2 KiB
Lua

----- 装备批量出售 -----
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=Language[11561],id = 106,goodsType = GoodsTypeDef.TreasureOfHeaven},
[2] = {name=Language[11316],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.dealBtnIma = Util.GetGameObject(this.dealBtn, "Image"):GetComponent("Image")
if MoneyUtil.MT == MoneyType.RMB then
this.dealBtnIma.sprite = Util.LoadSprite("q_qinlongmibao_jiesuozhenbao198")
else
this.dealBtnIma.sprite = Util.LoadSprite("q_qinlongmibao_jiesuozhenbao198(2)")
end
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()
PayManager.Pay(type[curType].id, function(id)
this.RechargeSuccessFunc()
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.rewardStateData
rewardData = TreasureOfHeavenManger.GetAllRewardData()
this:showRewardTianGong()
this.tip.text = Language[12286]
elseif curType == 2 then
rewardData = QinglongSerectTreasureManager.GetAllRewardData()
this:showRewardQinglong()
this.tip.text = Language[12287]
end
end
--充值成功
function this:RechargeSuccessFunc()
PopupTipPanel.ShowTip(Language[11564])
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,false,false)
end
parent:ClosePanel()
end
--直接/间接奖励
function this:showRewardTianGong()
local direct = {}
local indirect ={}
local curScore = TreasureOfHeavenManger.curScore--当前分数
for i = 1, #rewardData do
if curScore >= rewardData[i].Integral then
if rewardStateData[i].state == 1 or rewardStateData[i].state == 0 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
end
else
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
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].gameObject.transform:SetParent(this.box1.transform)
this.taskList[index].gameObject:GetComponent("RectTransform").localPosition = Vector3.zero
this.taskList[index]:OnOpen(false,{key, value},0.95)
index = index + 1
end
if LengthOfTable(direct) > 0 then
Util.GetGameObject(this.Content, "empty").gameObject:SetActive(false)
else
Util.GetGameObject(this.Content, "empty").gameObject:SetActive(true)
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].gameObject.transform:SetParent(this.box2.transform)
this.taskList[index].gameObject:GetComponent("RectTransform").localPosition = Vector3.zero
this.taskList[index]:OnOpen(false,{key, value},0.95)
index = index + 1
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].gameObject.transform:SetParent(this.box1.transform)
this.taskList[index].gameObject:GetComponent("RectTransform").localPosition = Vector3.zero
this.taskList[index]:OnOpen(false,{key, value},0.95)
index = index + 1
end
if LengthOfTable(direct) > 0 then
Util.GetGameObject(this.Content, "empty").gameObject:SetActive(false)
else
Util.GetGameObject(this.Content, "empty").gameObject:SetActive(true)
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].gameObject.transform:SetParent(this.box2.transform)
this.taskList[index].gameObject:GetComponent("RectTransform").localPosition = Vector3.zero
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()
this.taskList = {}
end
return this