----- 装备批量出售 ----- 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) this.spLoader = SpriteLoader.New() 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 PopupTipPanel.ShowTip(Language[11579]) return end NetManager.RequestBuyTreasureLevel(templv, function(msg) -- Timer.New(function() PopupTipPanel.ShowTip(Language[11580]) parent:ClosePanel() Game.GlobalEvent:DispatchEvent(GameEvent.TreasureOfHeaven.BuyQinglongSerectLevelSuccess) -- end,1):Start() end) end) Util.AddClick(this.addBtn,function() if (lv + count) < 50 then this:SetCount(count + 1) else PopupTipPanel.ShowTip(Language[11581]) end end) Util.AddClick(this.reduceBtn,function() if count > 0 then this:SetCount(count - 1) else PopupTipPanel.ShowTip(Language[11582]) end end) end function this:SetCount(value) count = value this.slider.value = value templv = lv + count this.tip.text = string.format(Language[11583],count,templv) this.num.text = a * count ^ 3 + b * count ^ 2 + c * count + d local tempCount = this:Caculate(templv) this.bodyText.text=string.format(Language[11584],templv,tempCount) 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 and id~=0 then if not direct[id] then direct[id] = 0 end direct[id] = direct[id] + num elseif reward.Reward[j].type == 2 and treasureState and id~=0 then 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 this.slider.maxValue = 50 - lv this:SetCount(1) this.icon.sprite = SetIcon(this.spLoader, id) this.slider.onValueChanged:AddListener(function() this:SetCount(this.slider.value) end) end function this:OnClose() end function this:OnDestroy() this.spLoader:Destroy() itemlist = {} end return this