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

165 lines
5.5 KiB
Lua
Raw Normal View History

2020-08-25 15:46:38 +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()
this.backBtn = Util.GetGameObject(this.gameObject, "BackBtn")
for i = 1, 4 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,--
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
allSoulPrintData= ConfigManager.GetAllConfigsDataByKey(ConfigName.EquipConfig,"Position",5)
end
function SoulPrintHandBook:BindEvent()
--tab按钮点击
for i = 1, 4 do
Util.AddClick(tabs[i], function()
if (curIndex == i) then
this.selectBtn:SetActive(false)
else
this.selectBtn:SetActive(true)
end
curIndex = i
this.selectBtn.transform.localPosition = tabs[i].transform.localPosition
if (not this.selectBtn.activeSelf) then
curIndex = 0--没有选定筛选按钮显示全部魂印
end
this.OnRefresh(curIndex)
this.selectBtnText.text = Util.GetGameObject(tabs[i].transform, "Text"):GetComponent("Text").text
end)
end
--关闭页面
Util.AddClick(this.backBtn, function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
end
function SoulPrintHandBook:AddListener()
end
function SoulPrintHandBook:RemoveListener()
end
function SoulPrintHandBook:OnSortingOrderChange()
2020-07-01 10:54:39 +08:00
--特效层级重设
for i=1,#list do
2020-08-02 09:16:45 +08:00
Util.SetParticleSortLayer(list[i], 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()
curIndex=0
this.OnRefresh(curIndex)
this.SetBottomBarIsActive()
end
--特殊的开启条件
function this.SetBottomBarIsActive()
for i = 1, #tabs do
--为白金魂印定开启规则
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()
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={}
local num = ConfigData[89].Value
2020-05-09 13:31:21 +08:00
if index==0 then
if PlayerManager.level >= tonumber(num) then--达到80级才显示白色魂印
tempData=allSoulPrintData
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
--预设容器
2020-07-01 10:54:39 +08:00
list={}
2020-05-09 13:31:21 +08:00
this.scrollView:SetData(tempData,function(index,root)
this.SetScrollPre(root,tempData[index])
2020-07-01 10:54:39 +08:00
table.insert(list,root)
2020-05-09 13:31:21 +08:00
end)
this.scrollView:SetIndex(1)
--特效层级重设
for i=1,#list do
2020-08-02 09:16:45 +08:00
Util.SetParticleSortLayer(list[i], this.sortingOrder+1)
2020-05-09 13:31:21 +08:00
end
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)
2020-08-02 09:16:45 +08:00
SetSoulEffect(data.Quality,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)
frame.sprite=Util.LoadSprite(GetQuantityImageByquality(data.Quality))
icon.sprite=Util.LoadSprite(GetResourcePath(itemConfig[data.Id].ResourceID))
2020-06-23 18:36:24 +08:00
Util.GetGameObject(root,"circleFrameBg"):GetComponent("Image").sprite=Util.LoadSprite(SoulPrintSpriteByQuantity[itemConfig[data.Id].Quantity].circleBg2)
Util.GetGameObject(root,"circleFrameBg/circleFrame"):GetComponent("Image").sprite=Util.LoadSprite(SoulPrintSpriteByQuantity[itemConfig[data.Id].Quantity].circle)
2021-01-26 17:08:39 +08:00
name.text=SubString2(GetLanguageStrById(data.Name),10)
2020-05-09 13:31:21 +08:00
end
return SoulPrintHandBook