miduo_client/Assets/ManagedResources/~Lua/Modules/SoulPrint/SoulPrintHandBook.lua

200 lines
6.9 KiB
Lua
Raw Normal View History

2021-04-21 13:12:04 +08:00
---- 魂印图鉴 ----
2020-05-09 13:31:21 +08:00
require("Base/BasePanel")
SoulPrintHandBook = Inherit(BasePanel)
local this = SoulPrintHandBook
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
local ConfigData = ConfigManager.GetConfig(ConfigName.SpecialConfig)
2020-05-09 13:31:21 +08:00
local orginLayer=0--层级
local allSoulPrintData={}--所有魂印数据
local curIndex = 0--当前选择索引
local chooseNum = 0
local tabs = {}
local itemData = {}
local currentDataList = {}
local chooseIdList = {}
2020-07-01 10:54:39 +08:00
local list={}
2020-05-09 13:31:21 +08:00
function SoulPrintHandBook:InitComponent()
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2020-05-09 13:31:21 +08:00
this.backBtn = Util.GetGameObject(this.gameObject, "BackBtn")
2021-11-02 15:14:19 +08:00
this.mask = Util.GetGameObject(this.gameObject, "mask")
2023-09-01 18:04:52 +08:00
for i = 1, 5 do
2020-05-09 13:31:21 +08:00
tabs[i] = Util.GetGameObject(this.gameObject, "Tabs/Btn" .. i)
2024-01-11 10:37:43 +08:00
if i<3 then
tabs[i]:SetActive(false)
end
2020-05-09 13:31:21 +08:00
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,--
2020-05-25 19:16:23 +08:00
Vector2.New(this.scrollRoot.transform.rect.width,this.scrollRoot.transform.rect.height),1,4,Vector2.New(50,15))
2020-05-09 13:31:21 +08:00
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 SoulPrintHandBook:BindEvent()
--tab按钮点击
2023-09-01 18:04:52 +08:00
for i = 1, 5 do
2020-05-09 13:31:21 +08:00
Util.AddClick(tabs[i], function()
if (curIndex == i) then
2022-02-18 15:08:45 +08:00
-- this.selectBtn:SetActive(false)
-- curIndex = 0
return
2020-05-09 13:31:21 +08:00
end
2022-02-18 15:08:45 +08:00
curIndex = i
2020-05-09 13:31:21 +08:00
this.OnRefresh(curIndex)
2022-02-18 15:08:45 +08:00
this:SetSelect()
2020-05-09 13:31:21 +08:00
end)
end
--关闭页面
Util.AddClick(this.backBtn, function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
2021-11-02 15:14:19 +08:00
--关闭页面
Util.AddClick(this.mask, function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
2020-05-09 13:31:21 +08:00
end
function SoulPrintHandBook:AddListener()
end
function SoulPrintHandBook:RemoveListener()
end
function SoulPrintHandBook:OnSortingOrderChange()
2020-07-01 10:54:39 +08:00
--特效层级重设
for _, v in pairs(list) do
Util.SetParticleSortLayer(v, this.sortingOrder+1)
2020-07-01 10:54:39 +08:00
end
orginLayer = self.sortingOrder
2020-05-09 13:31:21 +08:00
end
function SoulPrintHandBook:OnOpen()
end
function SoulPrintHandBook:OnShow()
2021-05-17 18:24:47 +08:00
this.GetAllData()
2022-02-18 15:17:28 +08:00
curIndex=4
2020-05-09 13:31:21 +08:00
this.OnRefresh(curIndex)
this.SetBottomBarIsActive()
2022-02-18 15:08:45 +08:00
this:SetSelect()
end
function SoulPrintHandBook: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
2021-05-17 18:24:47 +08:00
function this.GetAllData()
allSoulPrintData = {}
local allCurSoulPrintData= ConfigManager.GetAllConfigsDataByKey(ConfigName.EquipConfig,"Position",5)
for i = 1, #allCurSoulPrintData do
local curSpiritAnimalBook
2023-02-14 18:05:59 +08:00
-- for _, configInfo in ConfigPairs(ConfigManager.GetConfig(ConfigName.SpiritAnimalBook)) do
-- if configInfo.FetterType == 2 and configInfo.Teamers and configInfo.Teamers[1] and configInfo.Teamers[1][1] == allCurSoulPrintData[i].Id then
-- curSpiritAnimalBook = configInfo
-- break
-- end
-- end
-- if curSpiritAnimalBook then--表里只有高品质 所以低品质直接添加
-- if PlayerManager.level >= curSpiritAnimalBook.OpenLevel then
-- table.insert(allSoulPrintData,allCurSoulPrintData[i])
-- end
-- else
2021-05-17 18:24:47 +08:00
table.insert(allSoulPrintData,allCurSoulPrintData[i])
2023-02-14 18:05:59 +08:00
--end
2021-05-17 18:24:47 +08:00
end
end
--特殊的开启条件
function this.SetBottomBarIsActive()
for i = 1, #tabs do
--为白金魂印定开启规则
2021-05-17 18:24:47 +08:00
-- if i == 4 then
-- local num = ConfigData[89].Value
-- tabs[i]:SetActive(PlayerManager.level >= tonumber(num))
-- end
end
2020-05-09 13:31:21 +08:00
end
function SoulPrintHandBook:OnClose()
this.selectBtn:SetActive(false)
end
function SoulPrintHandBook:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
list = {}
2020-05-09 13:31:21 +08:00
this.scrollView=nil
end
2020-07-01 10:54:39 +08:00
local orginLayer2=0
2020-05-09 13:31:21 +08:00
--打开页面时,页面数据刷新
function this.OnRefresh(index)
local tempData={}
2021-05-17 18:24:47 +08:00
-- local num = ConfigData[89].Value
2020-05-09 13:31:21 +08:00
if index==0 then
2021-05-17 18:24:47 +08:00
-- if PlayerManager.level >= tonumber(num) then--达到80级才显示白色魂印
tempData=allSoulPrintData
2021-05-17 18:24:47 +08:00
-- else
-- for i,v in ipairs(allSoulPrintData) do
-- if v.Quality ~= 7 then
-- table.insert(tempData, v)
-- end
-- end
-- end
2020-05-09 13:31:21 +08:00
else
for i,v in ipairs(allSoulPrintData) do
if v.Quality==(index+3) then
table.insert( tempData, v)
end
end
end
2020-05-09 13:31:21 +08:00
--预设容器
this.scrollView:SetData(tempData,function(index,root)
this.SetScrollPre(root,tempData[index])
list[root] = root
2020-05-09 13:31:21 +08:00
end)
this.scrollView:SetIndex(1)
2020-07-01 10:54:39 +08:00
orginLayer2 = this.sortingOrder
2020-05-09 13:31:21 +08:00
orginLayer = this.sortingOrder
end
--设置预设
function this.SetScrollPre(root,data)
Util.SetParticleSortLayer(root, this.sortingOrder+1)
SetSoulEffect(itemConfig[data.Id].Quantity1,root)
2020-05-09 13:31:21 +08:00
local frame=Util.GetGameObject(root,"Frame"):GetComponent("Image")
2020-06-23 18:36:24 +08:00
local icon=Util.GetGameObject(root,"circleFrameBg/Icon"):GetComponent("Image")
2020-05-09 13:31:21 +08:00
local name=Util.GetGameObject(root,"Name"):GetComponent("Text")
Util.AddOnceClick(root,function()
UIManager.OpenPanel(UIName.SoulPrintPopUp,3,nil,data.Id,nil)
end)
2021-04-21 13:12:04 +08:00
frame.sprite=this.spLoader:LoadSprite(GetQuantityImageByquality(data.Quality))
icon.sprite=this.spLoader:LoadSprite(GetResourcePath(itemConfig[data.Id].ResourceID))
Util.GetGameObject(root,"circleFrameBg"):GetComponent("Image").sprite=this.spLoader:LoadSprite(SoulPrintSpriteByQuantity[itemConfig[data.Id].Quantity].circleBg2)
Util.GetGameObject(root,"circleFrameBg/circleFrame"):GetComponent("Image").sprite=this.spLoader:LoadSprite(SoulPrintSpriteByQuantity[itemConfig[data.Id].Quantity].circle)
2021-11-02 15:14:19 +08:00
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)
2020-05-09 13:31:21 +08:00
end
return SoulPrintHandBook