miduo_client/Assets/ManagedResources/~Lua/Modules/GeneralPanel/View/GeneralBigPopup_YiJingBaoKu...

156 lines
5.1 KiB
Lua
Raw Normal View History

----- 易经宝库弹窗 -----
2020-11-05 19:10:20 +08:00
local this = {}
--传入父脚本模块
local parent
--传入特效层级
local sortingOrder=0
local curId = nil--当前已选择的物品的Id
local ActData = {}
local itemList = {}--克隆预制体列表
local goList = {}--勾选按钮列表
local itemIconList={}--ItemView的List
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
local _args
local func
function this:InitComponent(gameObject)
this.titleText=Util.GetGameObject(gameObject,"TitleText"):GetComponent("Text")
this.itemPre = Util.GetGameObject(gameObject, "itemPre")
this.ConfirmBtn = Util.GetGameObject(gameObject, "ConfirmBtn")
this.Scroll = Util.GetGameObject(gameObject, "Scroll")
local rootHight = this.Scroll.transform.rect.height
local width = this.Scroll.transform.rect.width
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, this.Scroll.transform,
2021-03-04 21:22:02 +08:00
this.itemPre, nil, Vector2.New(860, rootHight), 1, 2, Vector2.New(0, 0))
2020-11-05 19:10:20 +08:00
this.ScrollView.moveTween.MomentumAmount = 1
this.ScrollView.moveTween.Strength = 2
end
function this:BindEvent()
Util.AddClick(this.ConfirmBtn,function()
if curId and curId ~= 0 then
2020-11-05 19:10:20 +08:00
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.YiJingBaoKuConfirm,curId,function()
NetManager.SelectFinalRewardRequest(curId,ActData.activityId,function ()
if func then
func()
end
parent:ClosePanel()
end)
end)
else
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[10759])
2020-11-05 19:10:20 +08:00
end
end)
end
function this:AddListener()
end
function this:RemoveListener()
end
function this:OnShow(_parent,...)
itemList={}
parent=_parent
sortingOrder = _parent.sortingOrder
--不定参中包含的不定参 _args[1]为面板类型 _args[2]之后(包括)为打开面板后传入的不定参
_args = {...}
ActData = _args[1]
func = _args[2]
2021-03-02 16:53:12 +08:00
this.titleText.text = Language[10760]
2020-11-05 19:10:20 +08:00
curId = ActData.selectId or nil
local RewardConfig = ConfigManager.GetAllConfigsDataByKey(ConfigName.BlessingRewardPoolNew,"PoolId",ActData.curFinalPool)
this.ScrollView:SetData(RewardConfig, function(index, go)
this:SetSingleData(index,go, RewardConfig[index])
end)
end
function this:SetSingleData(index,item,data)
itemList[index] = item
local icon = Util.GetGameObject(item,"icon")
local name = Util.GetGameObject(item,"name"):GetComponent("Text")
local num = Util.GetGameObject(item,"text"):GetComponent("Text")
local limit1 = Util.GetGameObject(item,"limit1"):GetComponent("Text")
local limit2 = Util.GetGameObject(item,"limit2"):GetComponent("Text")
2020-11-05 19:10:20 +08:00
local select = Util.GetGameObject(item,"select")
local go = Util.GetGameObject(item,"select/Go")
goList[index] = go
item:SetActive(true)
if not itemIconList[item] then
local view = SubUIManager.Open(SubUIConfig.ItemView, icon.transform)
itemIconList[item] = view
end
itemIconList[item]:OnOpen(false,data.Reward,0.9,false)
2021-01-26 17:08:39 +08:00
name.text = SubString2(GetLanguageStrById(itemConfig[data.Reward[1]].Name),10)
2020-11-05 19:10:20 +08:00
--判断是否选了该物品
if curId == data.Id then
go:SetActive(true)
else
go:SetActive(false)
end
--选择一个物品
Util.AddOnceClick(select,function()
if go.gameObject.activeSelf then
go:SetActive(false)
curId = nil
else
for index, value in ipairs(goList) do
goList[index]:SetActive(false)
end
go:SetActive(true)
curId = data.Id
end
end)
local t1 = true
local t2 = true
local t3 = true
--判断是否可以选择
if PlayerManager.level >= data.LevelLimit then
num.gameObject:SetActive(true)
limit1.gameObject:SetActive(false)
select:SetActive(true)
else
limit1.gameObject:SetActive(true)
2021-03-02 16:53:12 +08:00
limit1.text = data.LevelLimit..Language[10761]
t1 = false
end
if ActData.curLevel >= data.FloorLimit then
num.gameObject:SetActive(true)
limit2.gameObject:SetActive(false)
select:SetActive(true)
else
limit2.gameObject:SetActive(true)
2021-03-02 16:53:12 +08:00
limit2.text = Language[10262]..data.FloorLimit..Language[10762]
t2 = false
end
-- LogRed(ActData.allData[index].rewardId..""..tostring(ActData.allData[index].progress))
if ActData.allData[index].progress > data.InitializeNum then
t3 = false
elseif ActData.allData[index].progress == data.InitializeNum and ActData.curLevel > data.InitializeNum then
t3 = false
num.text = "<color=red>"..(data.InitializeNum-ActData.allData[index].progress).."/"..data.InitializeNum.."</color>"
else
t3 = true
num.text = (data.InitializeNum-ActData.allData[index].progress).."/"..data.InitializeNum
end
num.gameObject:SetActive(t1 and t2)
select:SetActive(t1 and t2 and t3)
2020-11-05 19:10:20 +08:00
end
function this:OnClose()
end
function this:OnDestroy()
itemIconList={}
end
return this