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

152 lines
4.8 KiB
Lua
Raw Normal View History

2021-04-21 13:12:04 +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 id = 0
local a = 0
local b = 0
local c = 0
local d = 0
local lv = 0
local itemlist = {}
local templv = 0
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.bodyText=Util.GetGameObject(gameObject,"BodyText"):GetComponent("Text")
this.rewardGroup=Util.GetGameObject(gameObject,"scroll/grid")
this.confirmBtn=Util.GetGameObject(gameObject,"ConfirmBtn")
this.addBtn=Util.GetGameObject(gameObject,"GameObject/add")
this.reduceBtn=Util.GetGameObject(gameObject,"GameObject/reduce")
this.slider=Util.GetGameObject(gameObject,"GameObject/Slider"):GetComponent("Slider")
this.tip=Util.GetGameObject(gameObject,"GameObject/tip"):GetComponent("Text")
this.num=Util.GetGameObject(gameObject,"GameObject/total/num"):GetComponent("Text")
this.icon=Util.GetGameObject(gameObject,"GameObject/total/icon"):GetComponent("Image")
this.cancelBtn = Util.GetGameObject(gameObject,"BG/BackBtn")
end
function this:BindEvent()
Util.AddClick(this.cancelBtn,function()
parent:ClosePanel()
end)
Util.AddClick(this.confirmBtn,function()
if templv == 0 or count == 0 then
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[11579])
return
end
2020-08-19 10:05:01 +08:00
NetManager.RequestBuyTreasureLevel(templv, function(msg)
-- Timer.New(function()
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[11580])
parent:ClosePanel()
Game.GlobalEvent:DispatchEvent(GameEvent.TreasureOfHeaven.BuyQinglongSerectLevelSuccess)
-- end,1):Start()
2020-08-19 10:05:01 +08:00
end)
end)
Util.AddClick(this.addBtn,function()
if (lv + count) < 50 then
this:SetCount(count + 1)
else
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[11581])
end
2020-08-19 10:05:01 +08:00
end)
Util.AddClick(this.reduceBtn,function()
if count > 0 then
this:SetCount(count - 1)
else
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[11582])
end
2020-08-19 10:05:01 +08:00
end)
end
function this:SetCount(value)
count = value
this.slider.value = value
templv = lv + count
2021-03-02 16:53:12 +08:00
this.tip.text = string.format(Language[11583],count,templv)
2020-08-19 10:05:01 +08:00
this.num.text = a * count ^ 3 + b * count ^ 2 + c * count + d
local tempCount = this:Caculate(templv)
2021-03-02 16:53:12 +08:00
this.bodyText.text=string.format(Language[11584],templv,tempCount)
2020-08-19 10:05:01 +08:00
end
function this:Caculate(templv)
local rewardData = QinglongSerectTreasureManager.GetAllRewardData()
local direct = {}
local treasureState = QinglongSerectTreasureManager.GetTreasureState()
for i = 1, #rewardData do
local reward = rewardData[i]
if reward.level > lv and reward.level <= templv then
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 == 1 then
if not direct[id] then
direct[id] = 0
end
direct[id] = direct[id] + num
2020-10-15 16:38:32 +08:00
elseif reward.Reward[j].type == 2 and treasureState then
2020-08-19 10:05:01 +08:00
if not direct[id] then
direct[id] = 0
end
direct[id] = direct[id] + num
end
end
end
end
for i=1,#itemlist do
itemlist[i].gameObject:SetActive(false)
end
local index = 1
for k,v in pairs(direct) do
if not itemlist[index] then
itemlist[index] = SubUIManager.Open(SubUIConfig.ItemView,this.rewardGroup.transform)
end
itemlist[index].gameObject:SetActive(true)
itemlist[index]:OnOpen(false, {k,v}, 1,false)
index = index + 1
end
return LengthOfTable(direct)
end
function this:AddListener()
end
function this:RemoveListener()
end
function this:OnShow(_parent,...)
parent=_parent
sortingOrder =_parent.sortingOrder
parent.BG:SetActive(false)
local config = ConfigManager.GetConfigData(ConfigName.SpecialConfig,18)
local strs = string.split(config.Value,"|")
local id =tonumber(strs[1])
strs = string.split(strs[2],"#")
count = 1
a = tonumber(strs[1])
b = tonumber(strs[2])
c = tonumber(strs[3])
d = tonumber(strs[4])
lv = QinglongSerectTreasureManager.GetLevel()
this.slider.minValue = 1
2020-08-19 10:05:01 +08:00
this.slider.maxValue = 50 - lv
this:SetCount(1)
2021-04-21 13:12:04 +08:00
this.icon.sprite = SetIcon(this.spLoader, id)
2020-08-19 10:05:01 +08:00
this.slider.onValueChanged:AddListener(function()
this:SetCount(this.slider.value)
end)
end
function this:OnClose()
end
function this:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2020-08-19 10:05:01 +08:00
itemlist = {}
end
2021-04-21 13:12:04 +08:00
return this