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

230 lines
9.6 KiB
Lua
Raw Normal View History

2021-05-12 18:24:50 +08:00
local PracticeImprint = quick_class("PracticeImprint", BasePanel)
local orginLayer
2021-05-13 17:37:47 +08:00
local curImprintData={}
2021-05-12 18:24:50 +08:00
function PracticeImprint:InitComponent()
self.spLoader = SpriteLoader.New()
self.UpView = SubUIManager.Open(SubUIConfig.UpView, self.transform)
2021-05-12 18:24:50 +08:00
self.backBtn = Util.GetGameObject(self.gameObject, "backBtn")
2021-05-13 17:37:47 +08:00
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.Name = Util.GetGameObject(self.ImprintInfo, "Content/Name"):GetComponent("Text")
2021-05-13 17:37:47 +08:00
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")
2021-05-13 21:03:27 +08:00
self.Add = Util.GetGameObject(self.rightInfo, "AddBtn")
self.Hero = Util.GetGameObject(self.rightInfo, "Hero")
2021-05-14 13:21:38 +08:00
self.itemPre = Util.GetGameObject(self.Hero, "itemPre")
2021-05-13 21:03:27 +08:00
self.MaskBtn = Util.GetGameObject(self.rightInfo, "mask")
2021-05-13 17:37:47 +08:00
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(35, 0))
2021-05-13 17:37:47 +08:00
self.ScrollView.moveTween.MomentumAmount = 1
self.ScrollView.moveTween.Strength = 2
2021-05-12 18:24:50 +08:00
end
function PracticeImprint:BindEvent()
Util.AddClick(self.backBtn, function()
self:ClosePanel()
end)
2021-05-13 17:37:47 +08:00
Util.AddClick(self.ImprintInfoBack, function()
self.ImprintInfo:SetActive(false)
end)
2021-05-12 18:24:50 +08:00
end
function PracticeImprint:AddListener()
end
function PracticeImprint:RemoveListener()
end
--待功能扩展(试图打开某个状态)
function PracticeImprint:OnOpen()
self.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main })
2021-05-12 18:24:50 +08:00
end
function PracticeImprint:OnSortingOrderChange()
end
function PracticeImprint:OnShow()
2021-05-14 14:54:57 +08:00
self:Refresh(true,false)
end
function PracticeImprint:Refresh(isTop,isAni,func)
2021-05-13 17:37:47 +08:00
self.allImprintData = PracticeManager.GetAllImprintData()
self.ImprintInfo:SetActive(false)
self.ScrollView:SetData(self.allImprintData, function(index, go)
self:SetPre(index,go,self.allImprintData[index])
2021-05-14 14:54:57 +08:00
end,isTop,isAni)
if func then
func()
end
2021-05-13 17:37:47 +08:00
end
--设置每一期的三个神印
function PracticeImprint:SetPre(index,_go,_data)
local title = Util.GetGameObject(_go, "title/Image"):GetComponent("Image")
title.sprite = self.spLoader:LoadSprite(_data.NamePic1)
2021-05-13 17:37:47 +08:00
for i = 1, 3 do
local Imprint = Util.GetGameObject(_go, "Content/Imprint"..i)
self:SetSingleImprint(Imprint,_data.TeamSkill[i])
end
2021-05-12 18:24:50 +08:00
end
2021-05-13 17:37:47 +08:00
--设置单个神印信息
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")
local maskBlack = Util.GetGameObject(_go, "maskblack")
local name = Util.GetGameObject(_go, "name/Text"):GetComponent("Text")
2021-05-13 17:37:47 +08:00
if not serverData then--未解锁
stateImg.gameObject:SetActive(true)
stateImg.sprite = self.spLoader:LoadSprite("r_Dungeon_lockon")
2021-05-13 17:37:47 +08:00
heroImg.gameObject:SetActive(false)
maskBlack:SetActive(true)
2021-05-13 17:37:47 +08:00
else--已解锁
2021-05-14 13:21:38 +08:00
-- LogGreen(" _imprintId:"..tostring(_imprintId).." serverData.state:"..tostring(serverData.state))
maskBlack:SetActive(false)
2021-05-13 17:37:47 +08:00
if serverData.state == 0 then--未使用
stateImg.gameObject:SetActive(false)
elseif serverData.state == 1 then--已使用
stateImg.gameObject:SetActive(true)
stateImg.sprite = self.spLoader:LoadSprite("t_tianshumijuan_yijihuo_zh")
2021-05-14 14:54:57 +08:00
end
heroImg.gameObject:SetActive(serverData.subId ~= nil and serverData.subId ~= "" and serverData.subId ~= "nil")
if serverData.subId ~= nil and serverData.subId ~= "" and serverData.subId ~= "nil" then
-- LogRed("serverData.subId:"..tostring(serverData.subId))
-- LogGreen(HeroManager.GetSingleHeroData(tostring(serverData.subId)).id)
heroImg.sprite = self.spLoader:LoadSprite(GetSpriteNameByItemId(HeroManager.GetSingleHeroData(tostring(serverData.subId)).id))
2021-05-13 17:37:47 +08:00
end
end
icon.sprite = self.spLoader:LoadSprite(GetResourcePath(configData.Icon))
name.text = configData.Name
2021-05-13 17:37:47 +08:00
Util.AddOnceClick(maskBtn,function ()
self.ImprintInfo:SetActive(true)
self:ShowSingleImprintInfoLayout(serverData,configData)
end)
end
--设置下方神印信息界面
function PracticeImprint:ShowSingleImprintInfoLayout(_serverData,_configData)
2021-05-13 21:03:27 +08:00
--title显示
self.Name.text = _configData.Name
2021-05-13 21:03:27 +08:00
if _configData.Type == 0 then
self.leftTitle.text = "通用神印"
2021-05-13 21:03:27 +08:00
elseif _configData.Type == 1 then
self.leftTitle.text = "附身神印"
2021-05-13 21:03:27 +08:00
end
--右侧部分状态和按钮显示
2021-05-13 17:37:47 +08:00
if not _serverData then
self.rightInfo:SetActive(false)
2021-05-13 21:03:27 +08:00
self.doBtnText.text = string.format("%s解锁",_configData.Unlock)
2021-05-13 17:37:47 +08:00
else
if _configData.Type == 0 then
self.rightInfo:SetActive(false)
elseif _configData.Type == 1 then
self.rightInfo:SetActive(true)
2021-05-13 21:03:27 +08:00
end
if _serverData.state == 0 then
self.doBtnText.text = "选择神印"
elseif _serverData.state == 1 then
2021-05-13 17:37:47 +08:00
self.doBtnText.text = "取消神印"
end
end
2021-05-13 21:03:27 +08:00
--详情
2021-05-13 17:37:47 +08:00
self.leftDetail.text = _configData.Desc
2021-05-13 21:03:27 +08:00
--神印确认/取消按钮
Util.AddOnceClick(self.doBtn,function ()
if _serverData ~= nil then
2021-05-13 17:37:47 +08:00
local old,new,sub = 0,0,""
old = PracticeManager.BigLevelImprintList[_configData.UnlockId]
new = _configData.Id
2021-05-14 14:54:57 +08:00
if _configData.Type == 0 then
sub = ""
elseif _configData.Type == 1 then
2021-05-17 09:50:32 +08:00
sub = _serverData.subId--self.curHeroId
if _serverData.subId == "" or _serverData.subId == "nil" or not _serverData.subId then
PopupTipPanel.ShowTip("请先选择附身神将!")
return
end
2021-05-14 14:54:57 +08:00
end
2021-05-14 13:21:38 +08:00
NetManager.PracticeImprintRequest(old,new,tostring(sub),function ()
2021-05-14 14:54:57 +08:00
self:Refresh(true,true,function ()
self.ImprintInfo:SetActive(true)
self:ShowSingleImprintInfoLayout(PracticeManager.GetSingleImprintData(new))
end)
2021-05-13 17:37:47 +08:00
end)
2021-05-13 21:03:27 +08:00
end
end)
2021-05-14 13:21:38 +08:00
--英雄图标
local heroData
local frame = Util.GetGameObject(self.itemPre, "frame"):GetComponent("Image")
local icon = Util.GetGameObject(self.itemPre, "icon"):GetComponent("Image")
local lv = Util.GetGameObject(self.itemPre, "lv/Text"):GetComponent("Text")
local proIcon = Util.GetGameObject(self.itemPre, "proIcon"):GetComponent("Image")
local starGrid = Util.GetGameObject(self.itemPre, "star")
local starPre = Util.GetGameObject(self.itemPre, "starPre")
2021-05-13 21:03:27 +08:00
--如果神印已开启且是附身神印
if _serverData and _configData.Type == 1 then
self.Add:SetActive(true)
self.Hero:SetActive(false)
2021-05-14 14:54:57 +08:00
if _serverData.subId ~= nil and _serverData.subId ~= "" and _serverData.subId ~= "nil" then
2021-05-13 21:03:27 +08:00
self.Add:SetActive(false)
self.Hero:SetActive(true)
2021-05-14 13:21:38 +08:00
--英雄图标
2021-05-14 14:54:57 +08:00
heroData = HeroManager.GetSingleHeroData(tostring(_serverData.subId))
frame.sprite = self.spLoader:LoadSprite(GetHeroQuantityImageByquality(heroData.heroConfig.Quality,heroData.star))
icon.sprite = self.spLoader:LoadSprite(heroData.icon)
2021-05-14 13:21:38 +08:00
lv.text = heroData.lv
proIcon.sprite = self.spLoader:LoadSprite(GetProStrImageByProNum(heroData.heroConfig.PropertyName))
2021-05-14 13:21:38 +08:00
SetHeroStars(starGrid, heroData.star)
2021-05-13 21:03:27 +08:00
end
Util.AddOnceClick(self.MaskBtn,function()
2021-05-14 13:21:38 +08:00
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.XiuXingSelectHero,_configData,function (_heroData)
2021-05-18 21:00:38 +08:00
--发送请求
NetManager.PracticeImprintRequest(_configData.Id,_configData.Id,tostring(_heroData.dynamicId),function ()
frame.sprite = self.spLoader:LoadSprite(GetHeroQuantityImageByquality(_heroData.heroConfig.Quality,_heroData.star))
icon.sprite = self.spLoader:LoadSprite(_heroData.icon)
lv.text = _heroData.lv
proIcon.sprite = self.spLoader:LoadSprite(GetProStrImageByProNum(_heroData.heroConfig.PropertyName))
SetHeroStars(starGrid, _heroData.star)
--刷新
self:Refresh(true,true,function ()
self.ImprintInfo:SetActive(true)
self:ShowSingleImprintInfoLayout(PracticeManager.GetSingleImprintData(_configData.Id))
2021-05-14 14:54:57 +08:00
end)
end)
2021-05-13 21:03:27 +08:00
end)
2021-05-13 17:37:47 +08:00
end)
end
2021-05-13 21:03:27 +08:00
--神将选择
2021-05-13 17:37:47 +08:00
end
2021-05-12 18:24:50 +08:00
function PracticeImprint:OnClose()
end
function PracticeImprint:OnDestroy()
self.spLoader:Destroy()
SubUIManager.Close(self.UpView)
self.UpView = nil
2021-05-12 18:24:50 +08:00
end
return PracticeImprint