miduo_client/Assets/ManagedResources/~Lua/Modules/RoleInfo/FaXiangHandBook.lua

175 lines
5.7 KiB
Lua

---- 魂印图鉴 ----
require("Base/BasePanel")
FaXiangHandBook = Inherit(BasePanel)
local this = FaXiangHandBook
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
local orginLayer=0--层级
local allSoulPrintData={}--所有魂印数据
local curIndex = 0--当前选择索引
local tabs = {}
local list={}
function this:InitComponent()
this.spLoader = SpriteLoader.New()
this.backBtn = Util.GetGameObject(this.gameObject, "BackBtn")
this.Title = Util.GetGameObject(this.gameObject, "Title"):GetComponent("Text")
this.Title.text="法相图鉴"
this.mask = Util.GetGameObject(this.gameObject, "mask")
for i = 1, 5 do
tabs[i] = Util.GetGameObject(this.gameObject, "Tabs/Btn" .. i)
end
this.selectBtn = Util.GetGameObject(this.gameObject, "Tabs/selectBtn")
this.selectBtnText = Util.GetGameObject(this.selectBtn.transform, "Text"):GetComponent("Text")
this.scrollRoot=Util.GetGameObject(this.gameObject,"ScrollRoot")
this.pre=Util.GetGameObject(this.scrollRoot,"Pre")
this.scrollView=SubUIManager.Open(SubUIConfig.ScrollCycleView,this.scrollRoot.transform,this.pre, nil,--
Vector2.New(this.scrollRoot.transform.rect.width,this.scrollRoot.transform.rect.height),1,4,Vector2.New(50,15))
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
end
function this:BindEvent()
--tab按钮点击
for i = 1, 3 do
Util.AddClick(tabs[i], function()
if (curIndex == i) then
return
end
curIndex = i
this.OnRefresh(curIndex)
this:SetSelect()
end)
end
--关闭页面
Util.AddClick(this.backBtn, function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
--关闭页面
Util.AddClick(this.mask, function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
end
function this:AddListener()
end
function this:RemoveListener()
end
function this:OnSortingOrderChange()
--特效层级重设
for _, v in pairs(list) do
Util.SetParticleSortLayer(v, this.sortingOrder+1)
end
orginLayer = self.sortingOrder
end
function this:OnOpen()
end
function this:OnShow()
this.GetAllData()
curIndex=1
this.OnRefresh(curIndex)
this.SetBottomBarIsActive()
this:SetSelect()
end
function this:SetSelect()
this.selectBtn:SetActive(true)
this.selectBtn.transform.localPosition = tabs[curIndex].transform.localPosition
this.selectBtnText.text = Util.GetGameObject(tabs[curIndex].transform, "Text"):GetComponent("Text").text
end
function this.GetAllData()
allSoulPrintData = {}
local faXiangConfigData= ConfigManager.GetConfig(ConfigName.FaxiangConfig)
for i, configInfo in ConfigPairs(faXiangConfigData) do
table.insert(allSoulPrintData,itemConfig[i])
end
end
--特殊的开启条件
function this.SetBottomBarIsActive()
for i = 1, #tabs do
end
end
function this:OnClose()
this.selectBtn:SetActive(false)
end
function this:OnDestroy()
this.spLoader:Destroy()
list = {}
this.scrollView=nil
end
local orginLayer2=0
--打开页面时,页面数据刷新
function this.OnRefresh(index)
local tempData={}
if index==0 then
tempData=allSoulPrintData
else
for i,v in ipairs(allSoulPrintData) do
if v.Quantity==(index+4) then
table.insert( tempData, v)
end
end
end
--预设容器
this.scrollView:SetData(tempData,function(index,root)
this.SetScrollPre(root,tempData[index])
list[root] = root
end)
this.scrollView:SetIndex(1)
orginLayer2 = this.sortingOrder
orginLayer = this.sortingOrder
end
--设置预设
function this.SetScrollPre(root,data)
Util.SetParticleSortLayer(root, this.sortingOrder+1)
SetSoulEffect(data.Quantity,root)
local frame=Util.GetGameObject(root,"Frame"):GetComponent("Image")
local icon=Util.GetGameObject(root,"circleFrameBg/Icon"):GetComponent("Image")
local name=Util.GetGameObject(root,"Name"):GetComponent("Text")
Util.AddOnceClick(root,function()
-- UIManager.OpenPanel(UIName.GodPrintPopUp,0,nil,data.Id,nil)
local equipData={}
equipData.id=data.Id
local faxiangConfig=ConfigManager.GetConfigData(ConfigName.FaxiangConfig,data.Id)
equipData.levelPool=faxiangConfig.LevelUpPool
equipData.lv=faxiangConfig.LevelMax
equipData.maxLv=faxiangConfig.LevelMax
equipData.refinePool=faxiangConfig.Star
equipData.refineLv=faxiangConfig.StarMax
UIManager.OpenPanel(UIName.RewardTalismanSingleShowPopup2,this,equipData,0,false,nil,nil,7)
end)
frame.sprite=this.spLoader:LoadSprite(GetQuantityImageByquality(data.Quantity))
icon.sprite=this.spLoader:LoadSprite(GetResourcePath(data.ResourceID))
Util.GetGameObject(root,"circleFrameBg"):GetComponent("Image").sprite=this.spLoader:LoadSprite(SoulPrintSpriteByQuantity[data.Quantity].circleBg2)
Util.GetGameObject(root,"circleFrameBg/circleFrame"):GetComponent("Image").sprite=this.spLoader:LoadSprite(SoulPrintSpriteByQuantity[data.Quantity].circle)
local str = data.Name
if GetCurLanguage() == 0 and LengthString(data.Name)>=5 then
str = SubString(data.Name,4).."..."
end
name.text = str--SubString2(GetLanguageStrById(data.Name),10)
end
return this