miduo_client/Assets/ManagedResources/~Lua/Modules/Practice/PracticeImprintPanel.lua

140 lines
5.0 KiB
Lua

local PracticeImprint = quick_class("PracticeImprint", BasePanel)
local orginLayer
local curImprintData={}
function PracticeImprint:InitComponent()
self.backBtn = Util.GetGameObject(self.gameObject, "backBtn")
self.Scroll = Util.GetGameObject(self.gameObject, "Scroll")
self.ImprintPre = Util.GetGameObject(self.gameObject, "ImprintPre")
self.ImprintInfo = Util.GetGameObject(self.gameObject, "ImprintInfo")
self.ImprintInfoBack = Util.GetGameObject(self.ImprintInfo, "close")
self.leftInfo = Util.GetGameObject(self.ImprintInfo, "Content/Layout/Left")
self.leftTitle = Util.GetGameObject(self.leftInfo, "Title/Text"):GetComponent("Text")
self.leftDetail = Util.GetGameObject(self.leftInfo, "TextArena/Text"):GetComponent("Text")
self.rightInfo = Util.GetGameObject(self.ImprintInfo, "Content/Layout/Right")
self.tightTitle = Util.GetGameObject(self.rightInfo, "Title/Text"):GetComponent("Text")
self.doBtn = Util.GetGameObject(self.ImprintInfo, "Content/Btn")
self.doBtnText = Util.GetGameObject(self.doBtn, "Text"):GetComponent("Text")
local rootHight = self.Scroll.transform.rect.height
local width = self.Scroll.transform.rect.width
self.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.Scroll.transform,
self.ImprintPre, nil,Vector2.New(width, rootHight), 1, 1,Vector2.New(15, 0))
self.ScrollView.moveTween.MomentumAmount = 1
self.ScrollView.moveTween.Strength = 2
end
function PracticeImprint:BindEvent()
Util.AddClick(self.backBtn, function()
self:ClosePanel()
end)
Util.AddClick(self.ImprintInfoBack, function()
self.ImprintInfo:SetActive(false)
end)
Util.AddClick(self.doBtn, function()
LogGreen("按钮")
end)
end
function PracticeImprint:AddListener()
end
function PracticeImprint:RemoveListener()
end
--待功能扩展(试图打开某个状态)
function PracticeImprint:OnOpen()
end
function PracticeImprint:OnSortingOrderChange()
end
function PracticeImprint:OnShow()
self.allImprintData = PracticeManager.GetAllImprintData()
self.ImprintInfo:SetActive(false)
self.ScrollView:SetData(self.allImprintData, function(index, go)
self:SetPre(index,go,self.allImprintData[index])
end)
end
--设置每一期的三个神印
function PracticeImprint:SetPre(index,_go,_data)
local title = Util.GetGameObject(_go, "title/Text"):GetComponent("Text")
title.text = string.format("%s期",_data.RealmName)
for i = 1, 3 do
local Imprint = Util.GetGameObject(_go, "Content/Imprint"..i)
self:SetSingleImprint(Imprint,_data.TeamSkill[i])
end
end
--设置单个神印信息
function PracticeImprint:SetSingleImprint(_go,_imprintId)
local serverData,configData = PracticeManager.GetSingleImprintData(_imprintId)--获取神印信息
local maskBtn = Util.GetGameObject(_go, "mask")
local stateImg = Util.GetGameObject(_go, "state"):GetComponent("Image")
local heroImg = Util.GetGameObject(_go, "hero"):GetComponent("Image")
local icon = Util.GetGameObject(_go, "icon"):GetComponent("Image")
if not serverData then--未解锁
stateImg.gameObject:SetActive(true)
stateImg.sprite = Util.LoadSprite("r_Dungeon_lockon")
heroImg.gameObject:SetActive(false)
else--已解锁
if serverData.state == 0 then--未使用
stateImg.gameObject:SetActive(false)
heroImg.gameObject:SetActive(false)
elseif serverData.state == 1 then--已使用
stateImg.gameObject:SetActive(true)
stateImg.sprite = Util.LoadSprite("t_tianshumijuan_yijihuo_zh")
heroImg.gameObject:SetActive(serverData.subId ~= "")
end
end
icon.sprite = Util.LoadSprite(GetResourcePath(configData.Icon))
Util.AddOnceClick(maskBtn,function ()
self.ImprintInfo:SetActive(true)
self:ShowSingleImprintInfoLayout(serverData,configData)
end)
end
--设置下方神印信息界面
function PracticeImprint:ShowSingleImprintInfoLayout(_serverData,_configData)
local curHero = ""
if not _serverData then
self.rightInfo:SetActive(false)
self.doBtnText.text = string.format("%s期解锁",_configData.Name)
else
if _configData.Type == 0 then
self.rightInfo:SetActive(false)
self.doBtnText.text = "选择神印"
elseif _configData.Type == 1 then
self.rightInfo:SetActive(true)
self.doBtnText.text = "取消神印"
end
end
self.leftTitle.text = string.format("通用神印·%s",_configData.Name)
self.leftDetail.text = _configData.Desc
if _serverData then
Util.AddOnceClick(self.doBtn,function ()
local old,new,sub = 0,0,""
old = PracticeManager.BigLevelImprintList[_configData.UnlockId]
new = _configData.Id
sub = tostring(curHero)
NetManager.PracticeImprintRequest(old,new,sub,function ()
self:OnShow()
end)
end)
end
end
function PracticeImprint:OnClose()
end
function PracticeImprint:OnDestroy()
end
return PracticeImprint