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

311 lines
11 KiB
Lua
Raw Normal View History

2020-08-25 15:46:38 +08:00
----- 装备批量出售 -----
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--表内活动数据
2021-05-21 16:39:08 +08:00
local rewardData1--表内活动数据
2020-08-19 10:05:01 +08:00
local curType = 0
local type = {
2021-04-09 12:26:35 +08:00
[1] = {name=Language[11561],id = 106,goodsType = GoodsTypeDef.TreasureOfHeaven},
[2] = {name=Language[11316],id = 5001,goodsType = GoodsTypeDef.FindBaby},
2021-05-22 14:08:34 +08:00
[3] = {name="无尽秘宝",id = 107,goodsType = GoodsTypeDef.WuJinMiBao},
2021-09-17 17:42:18 +08:00
[4] = {name="七界秘宝",id = 108,goodsType = GoodsTypeDef.QiJieMiBao},
2020-08-19 10:05:01 +08:00
}
--初始化组件(用于子类重写)
function this:InitComponent(gameObject)
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2020-08-19 10:05:01 +08:00
this.btnBack = Util.GetGameObject(gameObject, "frame/bg/closeBtn")
this.dealBtn = Util.GetGameObject(gameObject, "frame/bg/dealBtn")
2021-04-07 19:52:25 +08:00
this.dealBtnIma = Util.GetGameObject(this.dealBtn, "Image"):GetComponent("Image")
2021-05-29 20:17:50 +08:00
this.dealBtnText = Util.GetGameObject(this.dealBtn, "Text"):GetComponent("Text")
2021-04-07 19:52:25 +08:00
if MoneyUtil.MT == MoneyType.RMB then
2021-04-21 13:12:04 +08:00
this.dealBtnIma.sprite = this.spLoader:LoadSprite("q_qinlongmibao_jiesuozhenbao198")
2021-04-07 19:52:25 +08:00
else
2021-04-21 13:12:04 +08:00
this.dealBtnIma.sprite = this.spLoader:LoadSprite("q_qinlongmibao_jiesuozhenbao198(2)")
2021-04-07 19:52:25 +08:00
end
2020-08-19 10:05:01 +08:00
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")
2020-08-24 20:37:41 +08:00
this.taskList = {}
2020-08-19 10:05:01 +08:00
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)
2020-08-19 10:05:01 +08:00
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
2020-08-27 22:10:08 +08:00
rewardStateData = TreasureOfHeavenManger.rewardStateData
2020-08-19 10:05:01 +08:00
rewardData = TreasureOfHeavenManger.GetAllRewardData()
this:showRewardTianGong()
2021-04-09 17:13:03 +08:00
this.tip.text = Language[12286]
2021-05-29 20:17:50 +08:00
this.dealBtnIma.gameObject:SetActive(true)
this.dealBtnText.gameObject:SetActive(false)
2020-08-19 10:05:01 +08:00
elseif curType == 2 then
rewardData = QinglongSerectTreasureManager.GetAllRewardData()
this:showRewardQinglong()
2021-04-09 17:13:03 +08:00
this.tip.text = Language[12287]
2021-05-29 20:17:50 +08:00
this.dealBtnIma.gameObject:SetActive(true)
this.dealBtnText.gameObject:SetActive(false)
2021-05-21 16:39:08 +08:00
elseif curType == 3 then
rewardData,rewardData1 = EndLessMapManager.GetAllRewardData()
this:showRewardWuJin(rewardData,rewardData1)
2021-05-31 17:07:49 +08:00
this.tip.text = "<color=#60A22C>解锁秘宝,激活进阶</color><color=#95523B>专属奖励+2000积分<color=#CC4325>可获取1280妖晶</color></color>"
2021-05-29 20:17:50 +08:00
this.dealBtnIma.gameObject:SetActive(false)
this.dealBtnText.gameObject:SetActive(true)
local config = ConfigManager.GetConfigData(ConfigName.RechargeCommodityConfig,type[curType].id)
this.dealBtnText.text = MoneyUtil.GetMoneyUnitNameWithMoney(config.Price)
2021-09-17 17:42:18 +08:00
elseif curType == 4 then --七界秘宝
rewardData,rewardData1 = GeneralTreasureMangaer.GetAllRewardData()
this:SetItem(rewardData,rewardData1)
this.tip.text = "<color=#60A22C>解锁秘宝,激活进阶</color><color=#95523B>专属奖励+1500积分<color=#CC4325>可获取1280妖晶</color></color>"
this.dealBtnIma.gameObject:SetActive(false)
this.dealBtnText.gameObject:SetActive(true)
local config = ConfigManager.GetConfigData(ConfigName.RechargeCommodityConfig,type[curType].id)
this.dealBtnText.text = MoneyUtil.GetMoneyUnitNameWithMoney(config.Price)
2020-08-19 10:05:01 +08:00
end
end
--充值成功
function this:RechargeSuccessFunc()
2021-04-09 12:26:35 +08:00
PopupTipPanel.ShowTip(Language[11564])
2020-08-19 10:05:01 +08:00
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
2021-02-25 12:04:31 +08:00
Game.GlobalEvent:DispatchEvent(GameEvent.TreasureOfHeaven.RechargeQinglongSerectSuccess,false,false)
2021-05-21 16:39:08 +08:00
elseif curType == 3 then
EndLessMapManager.SetTreasureGiftState(1)
EndLessMapManager.SetTreasureState()
Game.GlobalEvent:DispatchEvent(GameEvent.EndLess.RechargeQinglongSerectSuccess,false,false)
2021-09-17 17:42:18 +08:00
elseif curType == 4 then
Game.GlobalEvent:DispatchEvent(GameEvent.SerectTreasure.RechargeSuccess,false,false)
end
2020-08-19 10:05:01 +08:00
parent:ClosePanel()
end
--直接/间接奖励
function this:showRewardTianGong()
local direct = {}
local indirect ={}
local curScore = TreasureOfHeavenManger.curScore
2020-08-19 10:05:01 +08:00
for i = 1, #rewardData do
2020-08-24 20:37:41 +08:00
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
2020-08-19 10:05:01 +08:00
end
2020-08-24 20:37:41 +08:00
else
2020-08-19 10:05:01 +08:00
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
2021-05-21 16:39:08 +08:00
this:SetItem(direct,indirect)
2020-08-19 10:05:01 +08:00
end
--直接/间接奖励
function this:showRewardQinglong()
local direct = {}
local indirect ={}
local config = ConfigManager.GetConfigData(ConfigName.SpecialConfig,16)
local strs = string.split(config.Value,"|")
2021-06-09 18:48:24 +08:00
local configLv = 0
if QinglongSerectTreasureManager.GetLevel() - 1 < 0 then
configLv = 0
else
configLv = QinglongSerectTreasureManager.GetLevel() - 1
end
local curScore = ConfigManager.GetConfigDataByKey(ConfigName.TreasureSunlongConfig,"Level",configLv).Integral[1][2]
local Getlv = function(curScore)
local lv = 0
for k,v in ConfigPairs(ConfigManager.GetConfig(ConfigName.TreasureSunlongConfig)) do
if not v.Integral or #v.Integral < 1 or #v.Integral[1] < 2 then
lv = v.Level
break
elseif curScore < v.Integral[1][2] then
lv = v.Level
break
end
end
return lv
end
for i = 1,#strs do
local strs1 = string.split(strs[i],"#")
if tonumber(strs1[1]) == QinglongSerectTreasureManager.scoreId then
curScore = curScore + tonumber(strs1[2])
end
end
local level = Getlv(curScore)
for i = 1, #rewardData do
2020-08-19 10:05:01 +08:00
-- 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 not indirect[id] then
indirect[id] = 0
end
indirect[id] = indirect[id] + num
if reward.state ~= -1 then
if level >= reward.level then
if not direct[id] then
direct[id] = 0
end
direct[id] = direct[id] + num
2020-08-19 10:05:01 +08:00
end
end
else
if reward.state == 0 or reward.state == -2 then
if level >= reward.level then
if not direct[id] then
direct[id] = 0
end
direct[id] = direct[id] + num
end
end
2020-08-19 10:05:01 +08:00
end
end
2020-08-19 10:05:01 +08:00
end
2021-05-21 16:39:08 +08:00
this:SetItem(direct,indirect)
end
function this:showRewardWuJin(rewardData,rewardData1)
local direct = {}
local indirect ={}
direct = this:SetDataList(rewardData)
indirect = this:SetDataList(rewardData1)
this:SetItem(direct,indirect)
end
function this:SetDataList(rewardData)
local temp = {}
for i = 1, #rewardData do
local id = rewardData[i].id
local num = rewardData[i].num
if not temp[id] then
temp[id] = 0
end
temp[id] = temp[id] + num
end
return temp
end
function this:SetItem(direct,indirect)
2020-08-24 19:45:18 +08:00
for i = 1,#this.taskList do
this.taskList[i].gameObject:SetActive(false)
2020-08-19 10:05:01 +08:00
end
local index = 1
for key, value in pairs(direct) do
--LogGreen("direct key:"..key.." value:"..value)
2020-08-24 20:37:41 +08:00
if not this.taskList[index] then
2020-08-19 10:05:01 +08:00
local item = SubUIManager.Open(SubUIConfig.ItemView, this.box1.transform)
2020-08-24 19:45:18 +08:00
this.taskList[index] = item
2020-08-19 10:05:01 +08:00
end
2020-08-24 19:45:18 +08:00
this.taskList[index].gameObject:SetActive(true)
this.taskList[index].gameObject.transform:SetParent(this.box1.transform)
2020-08-24 20:37:41 +08:00
this.taskList[index].gameObject:GetComponent("RectTransform").localPosition = Vector3.zero
2020-08-24 19:45:18 +08:00
this.taskList[index]:OnOpen(false,{key, value},0.95)
2020-08-19 10:05:01 +08:00
index = index + 1
end
2020-08-22 21:20:12 +08:00
if LengthOfTable(direct) > 0 then
Util.GetGameObject(this.Content, "empty").gameObject:SetActive(false)
else
Util.GetGameObject(this.Content, "empty").gameObject:SetActive(true)
end
2020-08-19 10:05:01 +08:00
for key, value in pairs(indirect) do
--LogGreen("indirect key:"..key.." value:"..value)
2020-08-24 19:45:18 +08:00
if not this.taskList[index] then
2020-08-19 10:05:01 +08:00
local item = SubUIManager.Open(SubUIConfig.ItemView, this.box2.transform)
2020-08-24 19:45:18 +08:00
this.taskList[index] = item
2020-08-19 10:05:01 +08:00
end
2020-08-24 19:45:18 +08:00
this.taskList[index].gameObject:SetActive(true)
this.taskList[index].gameObject.transform:SetParent(this.box2.transform)
2020-08-24 20:37:41 +08:00
this.taskList[index].gameObject:GetComponent("RectTransform").localPosition = Vector3.zero
2020-08-24 19:45:18 +08:00
this.taskList[index]:OnOpen(false,{key, value},0.95)
2020-08-19 10:05:01 +08:00
index = index + 1
end
end
function this:AddListener()
end
function this:RemoveListener()
end
--界面关闭时调用(用于子类重写)
function this:OnClose()
2021-05-21 16:39:08 +08:00
for i = 1,#this.taskList do
SubUIManager.Close(this.taskList[i])
end
this.taskList = {}
2020-08-19 10:05:01 +08:00
end
--界面销毁时调用(用于子类重写)
function this:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2020-08-24 19:45:18 +08:00
this.taskList = {}
2020-08-19 10:05:01 +08:00
end
return this