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

311 lines
11 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.

----- 装备批量出售 -----
local this = {}
--传入父脚本模块
local parent
--传入特效层级
local sortingOrder=0
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
local count = 0
local rewardStateData = {}
local treasureState--礼包状态
local rewardData--表内活动数据
local rewardData1--表内活动数据
local curType = 0
local type = {
[1] = {name=Language[11561],id = 106,goodsType = GoodsTypeDef.TreasureOfHeaven},
[2] = {name=Language[11316],id = 5001,goodsType = GoodsTypeDef.FindBaby},
[3] = {name="无尽秘宝",id = 107,goodsType = GoodsTypeDef.WuJinMiBao},
[4] = {name="七界秘宝",id = 108,goodsType = GoodsTypeDef.QiJieMiBao},
}
--初始化组件(用于子类重写)
function this:InitComponent(gameObject)
this.spLoader = SpriteLoader.New()
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")
this.dealBtnText = Util.GetGameObject(this.dealBtn, "Text"):GetComponent("Text")
if MoneyUtil.MT == MoneyType.RMB then
this.dealBtnIma.sprite = this.spLoader:LoadSprite("q_qinlongmibao_jiesuozhenbao198")
else
this.dealBtnIma.sprite = this.spLoader: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]
this.dealBtnIma.gameObject:SetActive(true)
this.dealBtnText.gameObject:SetActive(false)
elseif curType == 2 then
rewardData = QinglongSerectTreasureManager.GetAllRewardData()
this:showRewardQinglong()
this.tip.text = Language[12287]
this.dealBtnIma.gameObject:SetActive(true)
this.dealBtnText.gameObject:SetActive(false)
elseif curType == 3 then
rewardData,rewardData1 = EndLessMapManager.GetAllRewardData()
this:showRewardWuJin(rewardData,rewardData1)
this.tip.text = "<color=#60A22C>解锁秘宝,激活进阶</color><color=#95523B>专属奖励+2000积分<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)
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)
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)
elseif curType == 3 then
EndLessMapManager.SetTreasureGiftState(1)
EndLessMapManager.SetTreasureState()
Game.GlobalEvent:DispatchEvent(GameEvent.EndLess.RechargeQinglongSerectSuccess,false,false)
elseif curType == 4 then
Game.GlobalEvent:DispatchEvent(GameEvent.SerectTreasure.RechargeSuccess,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
this:SetItem(direct,indirect)
end
--直接/间接奖励
function this:showRewardQinglong()
local direct = {}
local indirect ={}
local config = ConfigManager.GetConfigData(ConfigName.SpecialConfig,16)
local strs = string.split(config.Value,"|")
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
-- 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
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
end
end
end
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)
for i = 1,#this.taskList do
this.taskList[i].gameObject:SetActive(false)
end
local index = 1
for key, value in pairs(direct) do
--LogGreen("direct key:"..key.." value:"..value)
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
--LogGreen("indirect key:"..key.." value:"..value)
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()
for i = 1,#this.taskList do
SubUIManager.Close(this.taskList[i])
end
this.taskList = {}
end
--界面销毁时调用(用于子类重写)
function this:OnDestroy()
this.spLoader:Destroy()
this.taskList = {}
end
return this