355 lines
14 KiB
Lua
355 lines
14 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 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},
|
|
[5] = {name="招募秘宝",id = 109,goodsType = GoodsTypeDef.RecruiteTreasure},
|
|
[6] = {name="招募秘宝",id = 110,goodsType = GoodsTypeDef.RecruiteTreasure},
|
|
[7] = {name="招募秘宝",id = 111,goodsType = GoodsTypeDef.RecruiteTreasure},
|
|
}
|
|
|
|
--初始化组件(用于子类重写)
|
|
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.tip3 = Util.GetGameObject(this.Content, "tip3"):GetComponent("Text")
|
|
this.taskList = {}
|
|
end
|
|
|
|
--绑定事件(用于子类重写)
|
|
function this:BindEvent()
|
|
Util.AddClick(this.btnBack, function()
|
|
parent:ClosePanel()
|
|
end)
|
|
Util.AddOnceClick(this.dealBtn,function()
|
|
local isBuy = true
|
|
if type[curType].goodsType == GoodsTypeDef.RecruiteTreasure and curType > 5 then
|
|
for i = 5,curType - 1 do
|
|
if not RecruitTreasureManager.CheckIsBuyTreasureByGoodsId(type[i].id) then
|
|
isBuy = false
|
|
end
|
|
end
|
|
end
|
|
if isBuy then
|
|
PayManager.Pay(type[curType].id, function(id)
|
|
this.RechargeSuccessFunc()
|
|
end)
|
|
elseif type[curType].goodsType == GoodsTypeDef.RecruiteTreasure then
|
|
PopupTipPanel.ShowTip("需购买上一档秘宝!")
|
|
return
|
|
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]
|
|
local extraType = temp[2]
|
|
this.tip3.text = "解锁秘宝"
|
|
if curType == 1 then
|
|
rewardStateData = TreasureOfHeavenManger.rewardStateData
|
|
rewardData = TreasureOfHeavenManger.GetAllRewardData()
|
|
this:showRewardTianGong()
|
|
this.tip.text = Language[12286]
|
|
this.tip.text = "·获得<color=#45953B>200积分</color>\n·获取<color=#45953B>980000妖晶</color>,激活<color=#45953B>进阶专属奖励</color>\n<size=25> <color=#45953B>妖晶</color>奖励通过<color=#45953B>邮件</color>发送</size>"
|
|
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 == 2 then
|
|
rewardData = QinglongSerectTreasureManager.GetAllRewardData()
|
|
this:showRewardQinglong()
|
|
this.tip.text = "·直升<color=#45953B>15级</color>\n·获取<color=#45953B>980000妖晶</color>,激活<color=#45953B>进阶专属奖励</color>\n<size=25> <color=#45953B>妖晶</color>奖励通过<color=#45953B>邮件</color>发送</size>"
|
|
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 == 3 then
|
|
rewardData,rewardData1 = EndLessMapManager.GetAllRewardData()
|
|
this:showRewardWuJin(rewardData,rewardData1)
|
|
this.tip.text = "·获得<color=#45953B>2000积分</color>\n·获取<color=#45953B>1280妖晶</color>,激活<color=#45953B>进阶专属奖励</color>\n<size=25> <color=#45953B>妖晶</color>奖励通过<color=#45953B>邮件</color>发送</size>"
|
|
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=#45953B>1500积分</color>\n·获取<color=#45953B>6480妖晶</color>,激活<color=#45953B>进阶专属奖励</color>\n<size=25> <color=#45953B>妖晶</color>奖励通过<color=#45953B>邮件</color>发送</size>"
|
|
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 == 5 or curType == 6 or curType == 7 then --
|
|
this.tip3.text = "解锁基金"
|
|
rewardData,rewardData1 = RecruitTreasureManager.GetAllRewardData(extraType,type[curType].id)
|
|
this:showRewardWuJin(rewardData,rewardData1)
|
|
this.tip.text = "·激活<color=#45953B>进阶专属奖励</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)
|
|
elseif curType == 5 or curType == 6 or curType == 7 then
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.TreasureOfHeaven.RechargeSuccess,false,false)
|
|
MonthCardManager.CheckMonthCardPatFace()
|
|
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 id~=0 then
|
|
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
|
|
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] and id~=0 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()
|
|
Game.GlobalEvent:AddEvent(GameEvent.QiJieShiLian.CloseBuyTreasure, self.CheckClose,self)
|
|
end
|
|
|
|
function this:RemoveListener()
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.QiJieShiLian.CloseBuyTreasure, self.CheckClose,self)
|
|
end
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
function this:CheckClose()
|
|
if curType == 4 then
|
|
parent:ClosePanel()
|
|
end
|
|
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 |