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

131 lines
4.7 KiB
Lua

----- 修行境界预览弹窗 -----
PracticeStatePreview = {}
--传入父脚本模块
local parent
--传入特效层级
local sortingOrder=0
local data
local XiuXianConfig = ConfigManager.GetConfig(ConfigName.XiuXianConfig)
function PracticeStatePreview:InitComponent(gameObject)
self.titleText = Util.GetGameObject(gameObject,"TitleText"):GetComponent("Text")
self.itemPre = Util.GetGameObject(gameObject,"Pre")
self.GameObject = Util.GetGameObject(gameObject,"Scroll")
local rootHight = self.GameObject.transform.rect.height
local width = self.GameObject.transform.rect.width
self.ScrollView = SubUIManager.Open(SubUIConfig.ScrollFitterView, self.GameObject.transform,
self.itemPre, Vector2.New(width, rootHight), 1, 0)
self.ScrollView.moveTween.MomentumAmount = 1
self.ScrollView.moveTween.Strength = 2
self.preList = {}
self.textList = {}
end
function PracticeStatePreview:BindEvent()
end
function PracticeStatePreview:AddListener()
end
function PracticeStatePreview:RemoveListener()
end
function PracticeStatePreview:OnShow(_parent,_args)
parent=_parent
data = _args
sortingOrder = _parent.sortingOrder
--不定参中包含的不定参 _args[1]为面板类型 _args[2]之后(包括)为打开面板后传入的不定参
self.titleText.text = "境界预览"
self.previewData = PracticeManager.GetPreViewData()
self.ScrollView:SetData(self.previewData, function(index, go)
self:SetSingleData(index,go,self.previewData[index])
end)
ForceRebuildLayout(self.GameObject.transform)
self.ScrollView:SetIndex(PracticeManager.PracticeBigLevel)
end
function PracticeStatePreview:SetSingleData(index,_go,_data)
local title = Util.GetGameObject(_go,"title/Text"):GetComponent("Text")
local specialText = Util.GetGameObject(_go,"SpecialText"):GetComponent("Text")
local textPre = Util.GetGameObject(_go,"Content/Text")
local content = Util.GetGameObject(_go,"Content")
local star = Util.GetGameObject(_go,"title/Star"):GetComponent("Text")
local starImg = Util.GetGameObject(_go,"title/Image")
if not self.textList[_go] then
self.textList[_go] = {}
end
local singleTextList = self.textList[_go]
for k,v in ipairs(singleTextList) do
v.gameObject:SetActive(false)
end
--进行排序
local templist = {}
for key, value in pairs(_data.AddList) do
local sData = {}
sData.id = key
sData.value = value
table.insert(templist,sData)
end
table.sort(templist,function (a,b)
return a.id < b.id
end)
--显示文字
for i = 1, #templist do
if not singleTextList[i] then
singleTextList[i] = newObject(textPre)
singleTextList[i].transform:SetParent(content.transform)
singleTextList[i].transform.localScale = Vector3.one
singleTextList[i].transform.localPosition = Vector3.zero
end
local Text = singleTextList[i]:GetComponent("Text")
local num = Util.GetGameObject(singleTextList[i],"num"):GetComponent("Text")
local string,string2 = PracticeManager.GetPreviewSingleText(templist[i].id,templist[i].value)
singleTextList[i]:SetActive(true)
Text.text = string
num.text = string2
if _data.IsActive == 2 then
Text.text = string.format("<color=#00ff00>%s</color>",string)
num.text = string.format("<color=#00ff00>%s</color>",string2)
elseif _data.IsActive == 1 and not XiuXianConfig[PracticeManager.PracticeLevel].LevelUpCost then
Text.text = string.format("<color=#00ff00>%s</color>",string)
num.text = string.format("<color=#00ff00>%s</color>",string2)
end
end
if _data.RealmDesc then
specialText.gameObject:SetActive(true)
specialText.text = _data.RealmDesc
if _data.IsActive == 1 or _data.IsActive == 2 then
specialText.text = string.format("<color=#00ff00>%s</color>",_data.RealmDesc)
end
else
specialText.gameObject:SetActive(false)
end
title.text = string.format("%s期",_data.RealmName)
if _data.NeedStarNum ~= 0 then
star.gameObject:SetActive(true)
starImg.gameObject:SetActive(true)
if _data.NeedStarNum > PracticeManager.StarNum then
star.text = string.format("<color=red>需要%s</color>",_data.NeedStarNum)
else
star.text = string.format("<color=#00ff00>需要%s</color>",_data.NeedStarNum)
end
else
star.gameObject:SetActive(false)
starImg.gameObject:SetActive(false)
end
ForceRebuildLayout(_go.transform)
_go:SetActive(true)
end
function PracticeStatePreview:OnClose()
end
function PracticeStatePreview:OnDestroy()
self.textList = {}
end
return PracticeStatePreview