2021-05-11 15:09:25 +08:00
|
|
|
local Practice = quick_class("Practice", BasePanel)
|
|
|
|
local orginLayer
|
2021-05-11 17:23:19 +08:00
|
|
|
local XinXianConfig = ConfigManager.GetConfig(ConfigName.XiuXianConfig)
|
2021-05-11 15:09:25 +08:00
|
|
|
|
|
|
|
function Practice:InitComponent()
|
|
|
|
orginLayer = 0
|
2021-05-11 17:23:19 +08:00
|
|
|
if not self.playerInfoView then
|
|
|
|
self.playerInfoView = SubUIManager.Open(SubUIConfig.PlayerInfoView, self.transform)
|
|
|
|
end
|
2021-05-11 15:09:25 +08:00
|
|
|
self.BtView = SubUIManager.Open(SubUIConfig.BtView, self.transform)
|
|
|
|
self.UpView = SubUIManager.Open(SubUIConfig.UpView, self.transform)
|
2021-05-11 17:23:19 +08:00
|
|
|
--Btns
|
|
|
|
self.helpBtn = Util.GetGameObject(self.gameObject, "Btns/helpBtn")
|
2021-05-11 15:09:25 +08:00
|
|
|
self.helpPosition=self.helpBtn:GetComponent("RectTransform").localPosition
|
2021-05-11 17:23:19 +08:00
|
|
|
self.previewBtn = Util.GetGameObject(self.gameObject, "Btns/previewBtn")
|
|
|
|
self.additionBtn = Util.GetGameObject(self.gameObject, "Btns/additionBtn")
|
|
|
|
self.imprintBtn = Util.GetGameObject(self.gameObject, "Btns/imprintBtn")
|
|
|
|
self.starBtn = Util.GetGameObject(self.gameObject, "Btns/starBtn")
|
|
|
|
self.starNum = Util.GetGameObject(self.starBtn, "starNum")
|
|
|
|
--MidPart
|
|
|
|
self.mid = Util.GetGameObject(self.gameObject, "Mid")
|
|
|
|
self.levelName = Util.GetGameObject(self.mid, "Text"):GetComponent("Text")
|
|
|
|
self.img = Util.GetGameObject(self.mid, "Img"):GetComponent("Image")
|
|
|
|
--BottomPart
|
|
|
|
self.bottom = Util.GetGameObject(self.gameObject, "Bottom")
|
|
|
|
self.items = Util.GetGameObject(self.bottom, "Items")
|
|
|
|
self.needs = Util.GetGameObject(self.bottom, "Needs")
|
|
|
|
self.needPre = Util.GetGameObject(self.needs, "pre")
|
|
|
|
self.button = Util.GetGameObject(self.bottom, "Button")
|
|
|
|
self.buttonText = Util.GetGameObject(self.button, "Text"):GetComponent("Text")
|
2021-05-12 17:40:38 +08:00
|
|
|
self.content = Util.GetGameObject(self.bottom, "Content")
|
|
|
|
self.textBtn = Util.GetGameObject(self.content, "Text")
|
|
|
|
self.needStar = Util.GetGameObject(self.content, "num"):GetComponent("Text")
|
|
|
|
self.itemList = {}
|
2021-05-11 15:09:25 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function Practice:BindEvent()
|
|
|
|
--帮助按钮
|
|
|
|
Util.AddClick(self.helpBtn, function()
|
|
|
|
UIManager.OpenPanel(UIName.HelpPopup, HELP_TYPE.VIP, self.helpPosition.x,self.helpPosition.y)
|
|
|
|
end)
|
|
|
|
|
|
|
|
Util.AddClick(self.BtnBack, function()
|
|
|
|
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
|
|
|
|
self:ClosePanel()
|
|
|
|
end)
|
2021-05-11 17:23:19 +08:00
|
|
|
Util.AddClick(self.previewBtn, function()
|
2021-05-12 17:40:38 +08:00
|
|
|
UIManager.OpenPanel(UIName.GeneralBigPopup,GENERAL_POPUP_TYPE.PracticeStatePreview)
|
2021-05-11 17:23:19 +08:00
|
|
|
end)
|
|
|
|
Util.AddClick(self.additionBtn, function()
|
2021-05-12 17:40:38 +08:00
|
|
|
UIManager.OpenPanel(UIName.RoleProInfoPopup,PracticeManager.GetCurAllGetAdd(),nil,false,nil)
|
2021-05-11 17:23:19 +08:00
|
|
|
end)
|
|
|
|
Util.AddClick(self.imprintBtn, function()
|
|
|
|
LogGreen("self.imprintBtn")
|
|
|
|
end)
|
2021-05-12 17:40:38 +08:00
|
|
|
Util.AddClick(self.textBtn, function()
|
|
|
|
LogGreen("打开山河社稷图")
|
|
|
|
end)
|
|
|
|
Util.AddClick(self.starBtn, function()
|
|
|
|
LogGreen("打开山河社稷图")
|
|
|
|
end)
|
2021-05-11 15:09:25 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function Practice:AddListener()
|
|
|
|
end
|
|
|
|
|
|
|
|
function Practice:RemoveListener()
|
|
|
|
end
|
|
|
|
|
|
|
|
--待功能扩展(试图打开某个状态)
|
|
|
|
function Practice:OnOpen()
|
|
|
|
self.UpView:OnOpen({ showType = UpViewOpenType.ShowRight, panelType = PanelType.Main })
|
|
|
|
self.BtView:OnOpen({ sortOrder = self.sortingOrder, panelType = PanelTypeView.Practice })
|
|
|
|
end
|
|
|
|
|
|
|
|
function Practice:OnSortingOrderChange()
|
2021-05-11 17:23:19 +08:00
|
|
|
-- Util.AddParticleSortLayer(self.effect, self.sortingOrder - orginLayer)
|
2021-05-11 15:09:25 +08:00
|
|
|
orginLayer = self.sortingOrder
|
|
|
|
-- 头像层级
|
|
|
|
if self.playerInfoView then
|
|
|
|
self.playerInfoView:SetLayer(self.sortingOrder)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function Practice:OnShow()
|
2021-05-11 17:23:19 +08:00
|
|
|
FormationManager.RefreshMainFormationPower()
|
2021-05-12 17:40:38 +08:00
|
|
|
self.curLevelConfig = PracticeManager.GetCurConfigData()
|
2021-05-11 17:23:19 +08:00
|
|
|
self:RefreshMid()
|
2021-05-12 17:40:38 +08:00
|
|
|
self:RefreshPoints()
|
|
|
|
self:RefreshBtn()
|
2021-05-11 17:23:19 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function Practice:RefreshMid()
|
2021-05-12 17:40:38 +08:00
|
|
|
self.levelName.text = string.format("%s期",self.curLevelConfig.RealmName)
|
|
|
|
end
|
|
|
|
|
|
|
|
function Practice:RefreshPoints()
|
2021-05-11 17:23:19 +08:00
|
|
|
-- body
|
2021-05-11 15:09:25 +08:00
|
|
|
end
|
|
|
|
|
2021-05-12 17:40:38 +08:00
|
|
|
function Practice:RefreshBtn()
|
|
|
|
if self.curLevelConfig.LevelUpCost then--如果下级消耗不为空则为突破阶段
|
|
|
|
if not self.itemList then
|
|
|
|
self.itemList = {}
|
|
|
|
end
|
|
|
|
for k,v in ipairs(self.itemList) do
|
|
|
|
v.gameObject:SetActive(false)
|
|
|
|
end
|
|
|
|
for i = 1, #self.curLevelConfig.LevelUpCost do
|
|
|
|
local data = self.curLevelConfig.LevelUpCost[i]
|
|
|
|
if not self.itemList[i] then
|
|
|
|
self.itemList[i] = newObject(self.needPre)
|
|
|
|
self.itemList[i].transform:SetParent(self.needs.transform)
|
|
|
|
self.itemList[i].transform.localScale = Vector3.one
|
|
|
|
self.itemList[i].transform.localPosition = Vector3.zero
|
|
|
|
end
|
|
|
|
local icon = Util.GetGameObject(self.itemList[i],"icon"):GetComponent("Image")
|
|
|
|
local num = Util.GetGameObject(self.itemList[i],"num"):GetComponent("Text")
|
|
|
|
icon.sprite = Util.LoadSprite(GetSpriteNameByItemId(data[1]))
|
|
|
|
num.text = data[2]
|
|
|
|
if BagManager.GetTotalItemNum(data[1]) < data[2] then
|
|
|
|
num.text = string.format("<color=red>%s</color>",data[2])
|
|
|
|
end
|
|
|
|
self.itemList[i]:SetActive(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
self.needs:SetActive(true)
|
|
|
|
self.content:SetActive(false)
|
|
|
|
self.buttonText.text = Language[11805]
|
|
|
|
else
|
|
|
|
self.needs:SetActive(false)
|
|
|
|
self.content:SetActive(true)
|
|
|
|
self.needStar.text = self.curLevelConfig.NeedStarNum
|
|
|
|
if self.curLevelConfig.NeedStarNum < 300 then
|
|
|
|
self.needStar.text = string.format("<color=red>%s</color>",self.curLevelConfig.NeedStarNum)
|
|
|
|
end
|
|
|
|
self.buttonText.text = "破 境"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-05-11 15:09:25 +08:00
|
|
|
function Practice:OnClose()
|
|
|
|
end
|
|
|
|
|
|
|
|
function Practice:OnDestroy()
|
|
|
|
SubUIManager.Close(self.UpView)
|
|
|
|
SubUIManager.Close(self.BtView)
|
|
|
|
self.UpView = nil
|
|
|
|
self.BtView = nil
|
|
|
|
if self.playerInfoView then
|
|
|
|
SubUIManager.Close(self.playerInfoView)
|
|
|
|
self.playerInfoView = nil
|
|
|
|
end
|
2021-05-12 17:40:38 +08:00
|
|
|
self.itemList = {}
|
2021-05-11 15:09:25 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
return Practice
|