miduo_client/Assets/ManagedResources/~Lua/Modules/Popup/View/GeneralPopup_ChooseUpSoul.lua

152 lines
5.4 KiB
Lua

----- 送神弹窗 -----
local this = {}
--传入父脚本模块
local parent
--传入特效层级
local sortingOrder = 0
local args = nil
local equipConfig = ConfigManager.GetConfig(ConfigName.EquipConfig)
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
local artResourcesConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
function this:InitComponent(gameObject)
this.spLoader = SpriteLoader.New()
this.titleText = Util.GetGameObject(gameObject, "TitleText"):GetComponent("Text")
this.titleText.text = Language[12282]
this.cancelBtn = Util.GetGameObject(gameObject, "CancelBtn")
this.confirmBtn = Util.GetGameObject(gameObject, "ConfirmBtn")
this.btn_close = Util.GetGameObject(gameObject, "BGImage/btn_close")
this.FourStarUpTip = Util.GetGameObject(gameObject, "tip"):GetComponent("Text")
this.FourStarUpTip.text = Language[12283]
this.selectObj = Util.GetGameObject(gameObject, "choosed")
this.prefab = Util.GetGameObject(gameObject, "item")
--滚动条根节点
this.root = Util.GetGameObject(gameObject, "Root")
this.scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, this.root.transform, this.prefab, nil,
Vector2.New(this.root.transform.rect.width, this.root.transform.rect.height), 1, 4, Vector2.New(50, 20))
this.scrollView.gameObject:GetComponent("RectTransform").anchoredPosition = Vector2.New(0, 0)
this.scrollView.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(0.5, 0.5)
this.scrollView.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(0.5, 0.5)
this.scrollView.gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5)
this.scrollView.moveTween.MomentumAmount = 1
this.scrollView.moveTween.Strength = 2
this.preList = {}
this.currHeroIds = {}
this.itemList = {}
end
function this:BindEvent()
Util.AddClick(this.confirmBtn, function()
if #this.currHeroIds ~= 3 then
PopupTipPanel.ShowTip(Language[12284])
return
end
NetManager.BeautyBagWishEquipRequest(this.currHeroIds, function()
Game.GlobalEvent:DispatchEvent(GameEvent.Activity.TimeLimitUpHeroChange, this.currHeroIds[1])
parent:ClosePanel()
end)
end)
Util.AddClick(this.cancelBtn, function()
parent:ClosePanel()
end)
Util.AddClick(this.btn_close, function()
parent:ClosePanel()
end)
end
function this:AddListener()
end
function this:RemoveListener()
end
function this:OnShow(_parent, ...)
parent = _parent
sortingOrder = _parent.sortingOrder
args = { ... }
this.currHeroIds = RecruitManager.GetWishEquipData()
local heroDatas = {}
for k, v in ConfigPairs(equipConfig) do
if v.Position == 5 and v.Quality == 6 then
if table.indexof(this.currHeroIds, v.Id) then
table.insert(heroDatas, 1, itemConfig[v.Id])
else
table.insert(heroDatas, itemConfig[v.Id])
end
end
end
-- for i = 1, math.max(#this.preList,#heroDatas) do
-- local item=this.preList[i]
-- if not item then
-- item=newObject(this.prefab)
-- item.transform:SetParent(this.root.transform)
-- item.transform.localScale=Vector3.one
-- item.transform.localPosition=Vector3.zero
-- this.preList[i]=item
-- end
-- item.gameObject:SetActive(false)
-- end
this.scrollView:ForeachItemGO(function(index, go)
go.gameObject:SetActive(false)
end)
this.scrollView:SetData(heroDatas, function(index, root)
this.SingleHeroDataShow(root, heroDatas[index])
end)
this.scrollView:SetIndex(1)
end
--英雄单个数据展示
function this.SingleHeroDataShow(go, _heroData)
local heroData = _heroData
local _go = go
_go.gameObject:SetActive(true)
local pos = Util.GetGameObject(_go.transform, "pos")
local btn = Util.GetGameObject(_go.transform, "btn")
if not this.itemList[go] then
this.itemList[go] = SubUIManager.Open(SubUIConfig.ItemView, pos.transform)
end
this.itemList[go].gameObject:SetActive(true)
this.itemList[go]:OnOpen(false, { heroData.Id, 0 }, 1, true, false, false, sortingOrder + 1)
local selectObj = Util.GetGameObject(_go.transform, "choosed"):GetComponent("Image")
selectObj.sprite = this.spLoader:LoadSprite("r_chouka_yixuanding")
local isHave = table.indexof(this.currHeroIds, heroData.Id)
selectObj.gameObject:SetActive(not not isHave)
Util.AddOnceClick(btn, function()
if #this.currHeroIds == 3 and not isHave then
PopupTipPanel.ShowTip(Language[12285])
return
end
if isHave then
table.removebyvalue(this.currHeroIds, heroData.Id)
isHave = false
else
table.insert(this.currHeroIds, heroData.Id)
isHave = true
end
local aa = RecruitManager.GetWishEquipData()
selectObj.gameObject:SetActive(isHave)
end)
Util.AddLongPressClick(btn, function()
UIManager.OpenPanel(UIName.SoulPrintPopUp, nil, nil, heroData.Id, nil, nil)
end, 0.5)
end
function this:OnClose()
this.currHeroIds = nil
args = nil
end
function this:OnDestroy()
this.spLoader:Destroy()
this.scrollView = nil
for k, v in pairs(this.itemList) do
SubUIManager.Close(v)
end
this.itemList = {}
end
return this