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-13 21:03:27 +08:00
|
|
|
|
local ItemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
2021-05-17 09:50:32 +08:00
|
|
|
|
local oldPower = 0
|
|
|
|
|
local newPower = 0
|
|
|
|
|
local oldBigLevel = 0
|
2021-05-11 15:09:25 +08:00
|
|
|
|
|
|
|
|
|
function Practice:InitComponent()
|
2021-05-19 15:06:02 +08:00
|
|
|
|
self.spLoader = SpriteLoader.New()
|
2021-05-11 15:09:25 +08:00
|
|
|
|
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")
|
2021-05-13 17:37:47 +08:00
|
|
|
|
self.starNum = Util.GetGameObject(self.starBtn, "starNum"):GetComponent("Text")
|
2021-05-11 17:23:19 +08:00
|
|
|
|
--MidPart
|
|
|
|
|
self.mid = Util.GetGameObject(self.gameObject, "Mid")
|
2021-05-19 10:23:39 +08:00
|
|
|
|
self.levelName = Util.GetGameObject(self.mid, "LevelName"):GetComponent("Image")
|
|
|
|
|
self.img = Util.GetGameObject(self.mid, "Man"):GetComponent("Image")
|
2021-05-11 17:23:19 +08:00
|
|
|
|
--BottomPart
|
|
|
|
|
self.bottom = Util.GetGameObject(self.gameObject, "Bottom")
|
|
|
|
|
self.items = Util.GetGameObject(self.bottom, "Items")
|
2021-05-19 14:46:51 +08:00
|
|
|
|
self.PointPre = Util.GetGameObject(self.items, "PointPre")
|
|
|
|
|
self.lines = Util.GetGameObject(self.bottom, "Lines")
|
|
|
|
|
self.LinePre = Util.GetGameObject(self.lines, "LinePre")
|
2021-05-11 17:23:19 +08:00
|
|
|
|
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-19 14:46:51 +08:00
|
|
|
|
self.pointList = {}
|
|
|
|
|
self.lineList = {}
|
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-14 17:48:47 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.RoleProInfoPopup,PracticeManager.GetCurAllGetAddForShow(),nil,false,nil)
|
2021-05-11 17:23:19 +08:00
|
|
|
|
end)
|
|
|
|
|
Util.AddClick(self.imprintBtn, function()
|
2021-05-12 18:24:50 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.PracticeImprintPanel)
|
2021-05-11 17:23:19 +08:00
|
|
|
|
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-12 18:47:47 +08:00
|
|
|
|
Util.AddClick(self.button, function()
|
2021-05-13 21:03:27 +08:00
|
|
|
|
if self:UpgradeCheck() then return end
|
2021-05-12 20:53:34 +08:00
|
|
|
|
NetManager.UpPracticeLevelRequest(function ()
|
2021-05-17 09:50:32 +08:00
|
|
|
|
newPower = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
|
|
|
|
|
UIManager.OpenPanel(UIName.WarPowerChangeNotifyPanelV2,{oldValue = oldPower,newValue = newPower})
|
|
|
|
|
oldPower = newPower
|
2021-05-19 19:53:00 +08:00
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Player.OnChangeName)
|
2021-05-17 09:50:32 +08:00
|
|
|
|
if PracticeManager.PracticeBigLevel - oldBigLevel == 1 then
|
2021-05-19 19:53:00 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.CongratulationPopup,CONGRATULATION_TYPE.Practice,XinXianConfig[PracticeManager.PracticeLevel])
|
2021-05-17 09:50:32 +08:00
|
|
|
|
end
|
2021-05-12 20:53:34 +08:00
|
|
|
|
self:OnShow()
|
|
|
|
|
end)
|
2021-05-12 18:47:47 +08:00
|
|
|
|
end)
|
2021-05-11 15:09:25 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-05-13 21:03:27 +08:00
|
|
|
|
--Check
|
|
|
|
|
function Practice:UpgradeCheck()
|
|
|
|
|
if PracticeManager.StarNum < self.curLevelConfig.NeedStarNum then
|
|
|
|
|
PopupTipPanel.ShowTip("无法破境,请前往山河社稷图获取更多星星!")
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
if self.curLevelConfig.LevelUpCost then
|
|
|
|
|
for i = 1, #self.curLevelConfig.LevelUpCost do
|
|
|
|
|
local data = self.curLevelConfig.LevelUpCost[i]
|
|
|
|
|
if BagManager.GetTotalItemNum(data[1]) < data[2] then
|
|
|
|
|
PopupTipPanel.ShowTip(string.format("%s不足!",ItemConfig[data[1]].Name))
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
|
2021-05-11 15:09:25 +08:00
|
|
|
|
function Practice:AddListener()
|
2021-05-13 17:37:47 +08:00
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.Bag.BagGold, self.OnShow,self)
|
2021-05-11 15:09:25 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Practice:RemoveListener()
|
2021-05-13 17:37:47 +08:00
|
|
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Bag.BagGold, self.OnShow,self)
|
2021-05-11 15:09:25 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--待功能扩展(试图打开某个状态)
|
|
|
|
|
function Practice:OnOpen()
|
2021-05-20 18:00:45 +08:00
|
|
|
|
self.UpView:OnOpen({ showType = UpViewOpenType.ShowRight, panelType = PanelType.XiuXing })
|
2021-05-20 09:48:52 +08:00
|
|
|
|
self.BtView:OnOpen(self,{ sortOrder = self.sortingOrder, panelType = PanelTypeView.Practice })
|
2021-05-11 15:09:25 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Practice:OnSortingOrderChange()
|
|
|
|
|
orginLayer = self.sortingOrder
|
|
|
|
|
-- 头像层级
|
|
|
|
|
if self.playerInfoView then
|
|
|
|
|
self.playerInfoView:SetLayer(self.sortingOrder)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Practice:OnShow()
|
2021-05-17 15:20:20 +08:00
|
|
|
|
self.playerInfoView: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-17 11:57:54 +08:00
|
|
|
|
LogYellow("当前修行等级Id:"..tostring(PracticeManager.PracticeLevel))
|
2021-05-17 09:50:32 +08:00
|
|
|
|
oldPower = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
|
|
|
|
|
oldBigLevel = PracticeManager.PracticeBigLevel
|
2021-05-19 16:14:09 +08:00
|
|
|
|
self.pointData = PracticeManager.GetPointsData()
|
|
|
|
|
self.lineData = PracticeManager.GetLinesData()
|
2021-05-11 17:23:19 +08:00
|
|
|
|
self:RefreshMid()
|
2021-05-12 17:40:38 +08:00
|
|
|
|
self:RefreshPoints()
|
2021-05-19 14:46:51 +08:00
|
|
|
|
self:RefreshLines()
|
2021-05-12 17:40:38 +08:00
|
|
|
|
self:RefreshBtn()
|
2021-05-11 17:23:19 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Practice:RefreshMid()
|
2021-05-20 09:48:52 +08:00
|
|
|
|
self.levelName.sprite = self.spLoader:LoadSprite(self.curLevelConfig.NamePic1)
|
2021-05-13 17:37:47 +08:00
|
|
|
|
self.starNum.text = PlayerManager.level
|
2021-05-20 17:37:56 +08:00
|
|
|
|
local playerImg = NameManager.roleSex == 0 and "x_xiuxing_liangongren_nan" or "x_xiuxing_liangongren_nv"
|
|
|
|
|
self.img.sprite = self.spLoader:LoadSprite(playerImg)
|
2021-05-12 17:40:38 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-05-19 14:46:51 +08:00
|
|
|
|
--刷新点
|
2021-05-12 17:40:38 +08:00
|
|
|
|
function Practice:RefreshPoints()
|
2021-05-19 14:46:51 +08:00
|
|
|
|
if not self.pointList then
|
|
|
|
|
self.pointList = {}
|
|
|
|
|
end
|
|
|
|
|
for k,v in ipairs(self.pointList) do
|
|
|
|
|
v.gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
for i = 1, #self.pointData do
|
|
|
|
|
local data = self.pointData[i]
|
|
|
|
|
if not self.pointList[i] then
|
|
|
|
|
self.pointList[i] = newObject(self.PointPre)
|
|
|
|
|
self.pointList[i].transform:SetParent(self.items.transform)
|
|
|
|
|
self.pointList[i].transform.localScale = Vector3.one
|
|
|
|
|
self.pointList[i].transform.localPosition = Vector3.zero
|
|
|
|
|
end
|
|
|
|
|
self.pointList[i]:SetActive(true)
|
2021-05-20 09:48:52 +08:00
|
|
|
|
self.pointList[i]:GetComponent("Image").sprite = self.spLoader:LoadSprite(data.Img)
|
2021-05-19 14:46:51 +08:00
|
|
|
|
self.pointList[i]:GetComponent("RectTransform").localPosition = data.Pos
|
2021-05-19 16:14:09 +08:00
|
|
|
|
Util.AddOnceClick(self.pointList[i],function ()
|
|
|
|
|
UIManager.OpenPanel(UIName.GeneralInfoPopup,GENERALINFO_TYPE.PracticeLevel,data)
|
|
|
|
|
end)
|
2021-05-19 14:46:51 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--刷新 点间的线
|
|
|
|
|
function Practice:RefreshLines()
|
|
|
|
|
if not self.lineList then
|
|
|
|
|
self.lineList = {}
|
|
|
|
|
end
|
|
|
|
|
for k,v in ipairs(self.lineList) do
|
|
|
|
|
v.gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
for i = 1, #self.lineData do
|
|
|
|
|
local data = self.lineData[i]
|
|
|
|
|
if not self.lineList[i] then
|
|
|
|
|
self.lineList[i] = newObject(self.LinePre)
|
|
|
|
|
self.lineList[i].transform:SetParent(self.lines.transform)
|
|
|
|
|
self.lineList[i].transform.localScale = Vector3.one
|
|
|
|
|
self.lineList[i].transform.localPosition = Vector3.zero
|
|
|
|
|
end
|
|
|
|
|
self.lineList[i]:SetActive(true)
|
|
|
|
|
local imgName = data.State == 1 and "x_xiuxing_xian_01" or "x_xiuxing_xian_02"
|
2021-05-20 09:48:52 +08:00
|
|
|
|
self.lineList[i]:GetComponent("Image").sprite = self.spLoader:LoadSprite(imgName)
|
2021-05-19 14:46:51 +08:00
|
|
|
|
self.lineList[i]:GetComponent("RectTransform").localPosition = data.Pos
|
|
|
|
|
self.lineList[i]:GetComponent("RectTransform").rotation = Quaternion.Euler(data.Rota)
|
|
|
|
|
end
|
2021-05-11 15:09:25 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-05-12 17:40:38 +08:00
|
|
|
|
function Practice:RefreshBtn()
|
2021-05-17 09:50:32 +08:00
|
|
|
|
if XinXianConfig[PracticeManager.PracticeLevel + 1] then
|
|
|
|
|
self.button:SetActive(true)
|
|
|
|
|
if self.curLevelConfig.LevelUpCost then--如果下级消耗不为空则为突破阶段
|
|
|
|
|
if not self.itemList then
|
|
|
|
|
self.itemList = {}
|
2021-05-12 17:40:38 +08:00
|
|
|
|
end
|
2021-05-17 09:50:32 +08:00
|
|
|
|
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")
|
2021-05-19 15:06:02 +08:00
|
|
|
|
icon.sprite = self.spLoader:LoadSprite(GetSpriteNameByItemId(data[1]))
|
2021-05-17 09:50:32 +08:00
|
|
|
|
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)
|
2021-05-12 17:40:38 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-05-17 09:50:32 +08:00
|
|
|
|
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 > PlayerManager.level then
|
|
|
|
|
self.needStar.text = string.format("<color=red>%s</color>",self.curLevelConfig.NeedStarNum)
|
|
|
|
|
end
|
|
|
|
|
self.buttonText.text = "破 境"
|
|
|
|
|
end
|
2021-05-12 17:40:38 +08:00
|
|
|
|
else
|
2021-05-17 09:50:32 +08:00
|
|
|
|
self.button:SetActive(false)
|
2021-05-12 17:40:38 +08:00
|
|
|
|
self.needs:SetActive(false)
|
|
|
|
|
self.content:SetActive(true)
|
2021-05-17 09:50:32 +08:00
|
|
|
|
Util.GetGameObject(self.content,"Text"):SetActive(false)
|
|
|
|
|
Util.GetGameObject(self.content,"Image"):SetActive(false)
|
|
|
|
|
self.needStar.text = "恭喜你已修行至世间巅峰"
|
2021-05-12 17:40:38 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2021-05-11 15:09:25 +08:00
|
|
|
|
function Practice:OnClose()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Practice:OnDestroy()
|
2021-05-19 15:06:02 +08:00
|
|
|
|
self.spLoader:Destroy()
|
2021-05-11 15:09:25 +08:00
|
|
|
|
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-19 14:46:51 +08:00
|
|
|
|
self.pointList = {}
|
|
|
|
|
self.lineList = {}
|
2021-05-11 15:09:25 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return Practice
|