2021-12-06 15:07:34 +08:00
|
|
|
|
local Gem = quick_class("Gem", BasePanel)
|
2021-12-07 11:50:03 +08:00
|
|
|
|
local itemData = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
|
|
|
local gemConfig = ConfigManager.GetConfig(ConfigName.GemConfig)
|
2021-12-08 14:17:18 +08:00
|
|
|
|
local PropertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
|
|
|
|
|
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
|
|
|
local typeName = {
|
|
|
|
|
[1] = "攻击",[2] = "生命",[3] = "增伤",[4] = "减伤",[5] = "人杰",[6] = "佛禅",[7] = "妖灵",[8] = "道玄",
|
|
|
|
|
}
|
2021-12-10 14:57:23 +08:00
|
|
|
|
local imgName = {
|
|
|
|
|
[1] = "m_mingge_gongji",[2] = "m_mingge_shengming",[3] = "m_mingge_zengshang",[4] = "m_mingge_shanghai",
|
|
|
|
|
[5] = "m_mingge_renjie",[6] = "m_mingge_pochan",[7] = "m_mingge_yaoling",[8] = "m_mingge_daoxuan",
|
|
|
|
|
}
|
2021-12-06 14:06:23 +08:00
|
|
|
|
|
2021-12-06 15:07:34 +08:00
|
|
|
|
function Gem:InitComponent()
|
2021-12-06 14:06:23 +08:00
|
|
|
|
self.spLoader = SpriteLoader.New()
|
|
|
|
|
if not self.playerInfoView then
|
|
|
|
|
self.playerInfoView = SubUIManager.Open(SubUIConfig.PlayerInfoView, self.transform)
|
|
|
|
|
end
|
2021-12-06 15:07:34 +08:00
|
|
|
|
self.BtView = SubUIManager.Open(SubUIConfig.BtView, self.transform)
|
|
|
|
|
self.UpView = SubUIManager.Open(SubUIConfig.UpView, self.transform)
|
2021-12-06 14:06:23 +08:00
|
|
|
|
--MidPart
|
|
|
|
|
self.mid = Util.GetGameObject(self.gameObject, "Mid")
|
|
|
|
|
self.img = Util.GetGameObject(self.mid, "Man"):GetComponent("Image")
|
|
|
|
|
self.ManCanvas = Util.GetGameObject(self.mid, "Man"):GetComponent("Canvas")
|
2021-12-06 15:31:29 +08:00
|
|
|
|
self.fx_ui_xiuxingshengxin_cangzhu = Util.GetGameObject(self.gameObject, "Bg/fx_ui_xiuxingshengxin_cangzhu")
|
2021-12-07 11:50:03 +08:00
|
|
|
|
--Gems
|
|
|
|
|
self.gems = Util.GetGameObject(self.gameObject, "Gems")
|
2021-12-07 17:19:07 +08:00
|
|
|
|
self.stones = Util.GetGameObject(self.gameObject, "Stones")
|
2021-12-10 11:40:15 +08:00
|
|
|
|
self.gemName = Util.GetGameObject(self.gameObject, "Stones/Name/Text"):GetComponent("Text")
|
2021-12-07 17:19:07 +08:00
|
|
|
|
self.itemList = {}
|
2021-12-08 14:17:18 +08:00
|
|
|
|
self.propertyList = {}
|
2021-12-10 16:07:46 +08:00
|
|
|
|
self.lightList = {}
|
2021-12-06 14:06:23 +08:00
|
|
|
|
|
|
|
|
|
--页签
|
|
|
|
|
self.btnPractice = Util.GetGameObject(self.gameObject, "Tab/tab1")
|
2021-12-08 17:27:22 +08:00
|
|
|
|
self.helpBtn = Util.GetGameObject(self.gameObject, "helpBtn")
|
|
|
|
|
self.helpPosition=self.helpBtn:GetComponent("RectTransform").localPosition
|
|
|
|
|
self.additionBtn = Util.GetGameObject(self.gameObject, "additionBtn")
|
2021-12-08 14:17:18 +08:00
|
|
|
|
self.curType = 1
|
2021-12-06 14:06:23 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-12-06 15:07:34 +08:00
|
|
|
|
function Gem:BindEvent()
|
2021-12-06 14:06:23 +08:00
|
|
|
|
--帮助按钮
|
|
|
|
|
Util.AddClick(self.helpBtn, function()
|
2021-12-10 11:40:15 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.HelpPopup, HELP_TYPE.Gem, self.helpPosition.x,self.helpPosition.y)
|
2021-12-06 14:06:23 +08:00
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
Util.AddClick(self.btnPractice, function()
|
2021-12-07 16:27:55 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.PracticePanel)
|
|
|
|
|
self:ClosePanel()
|
2021-12-07 15:40:36 +08:00
|
|
|
|
end)
|
2021-12-08 17:27:22 +08:00
|
|
|
|
Util.AddClick(self.helpBtn, function()
|
|
|
|
|
UIManager.OpenPanel(UIName.HelpPopup, HELP_TYPE.Gem, self.helpPosition.x,self.helpPosition.y)
|
|
|
|
|
end)
|
|
|
|
|
Util.AddClick(self.additionBtn, function()
|
2021-12-10 11:40:15 +08:00
|
|
|
|
local tempData = GemManager.GetSortAttri()
|
|
|
|
|
if #tempData > 0 then
|
|
|
|
|
UIManager.OpenPanel(UIName.GeneralInfoPopup, GENERALINFO_TYPE.Gem)
|
|
|
|
|
else
|
|
|
|
|
PopupTipPanel.ShowTip("尚无命格属性加成!")
|
|
|
|
|
end
|
2021-12-08 17:27:22 +08:00
|
|
|
|
end)
|
|
|
|
|
|
2021-12-06 14:06:23 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-12-06 15:07:34 +08:00
|
|
|
|
function Gem:AddListener()
|
2021-12-08 09:29:08 +08:00
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.Gem.RefreshPanel, self.Refresh,self)
|
2021-12-06 14:06:23 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-12-06 15:07:34 +08:00
|
|
|
|
function Gem:RemoveListener()
|
2021-12-08 09:29:08 +08:00
|
|
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Gem.RefreshPanel, self.Refresh,self)
|
2021-12-06 14:06:23 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--待功能扩展(试图打开某个状态)
|
2021-12-06 15:07:34 +08:00
|
|
|
|
function Gem:OnOpen()
|
2021-12-06 14:06:23 +08:00
|
|
|
|
self.UpView:OnOpen({ showType = UpViewOpenType.ShowRight, panelType = PanelType.XiuXing })
|
|
|
|
|
self.BtView:OnOpen(self,{ sortOrder = self.sortingOrder, panelType = PanelTypeView.Practice })
|
2021-12-08 18:21:28 +08:00
|
|
|
|
local oldWarPower = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
|
2021-12-06 14:06:23 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-12-06 15:07:34 +08:00
|
|
|
|
function Gem:OnSortingOrderChange()
|
2021-12-08 14:17:18 +08:00
|
|
|
|
self.BtView:OnOpen(self,{ sortOrder = self.sortingOrder, panelType = PanelTypeView.Practice })
|
2021-12-06 14:06:23 +08:00
|
|
|
|
self.ManCanvas.sortingOrder = self.sortingOrder + 2
|
2021-12-06 15:31:29 +08:00
|
|
|
|
Util.SetParticleSortLayer(self.fx_ui_xiuxingshengxin_cangzhu, self.sortingOrder + 1)
|
2021-12-06 14:06:23 +08:00
|
|
|
|
-- 头像层级
|
|
|
|
|
if self.playerInfoView then
|
|
|
|
|
self.playerInfoView:SetLayer(self.sortingOrder)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2021-12-06 15:07:34 +08:00
|
|
|
|
function Gem:OnShow()
|
2021-12-06 14:06:23 +08:00
|
|
|
|
self.playerInfoView:OnShow()
|
2021-12-06 15:31:29 +08:00
|
|
|
|
Util.SetParticleSortLayer(self.fx_ui_xiuxingshengxin_cangzhu, self.sortingOrder + 1)
|
|
|
|
|
self:Refresh()
|
|
|
|
|
end
|
|
|
|
|
function Gem:Refresh()
|
2021-12-06 14:06:23 +08:00
|
|
|
|
self:RefreshMid()
|
2021-12-07 11:50:03 +08:00
|
|
|
|
self:SetGems()
|
2021-12-08 14:17:18 +08:00
|
|
|
|
self:SetStones(GemManager.myGemList[self.curType],self.curType)
|
2021-12-06 14:06:23 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--刷新中部人物
|
2021-12-06 15:07:34 +08:00
|
|
|
|
function Gem:RefreshMid()
|
2021-12-06 14:06:23 +08:00
|
|
|
|
local playerImg = NameManager.roleSex == 0 and "x_xiuxing_liangongren_nan" or "x_xiuxing_liangongren_nv"
|
|
|
|
|
self.img.sprite = self.spLoader:LoadSprite(playerImg)
|
|
|
|
|
self.ManCanvas.sortingOrder = self.sortingOrder + 2
|
|
|
|
|
end
|
|
|
|
|
|
2021-12-07 11:50:03 +08:00
|
|
|
|
--设置中部宝石数据
|
|
|
|
|
function Gem:SetGems()
|
|
|
|
|
local gemData = GemManager.myGemList
|
|
|
|
|
for i = 1, 8 do
|
|
|
|
|
local itemGo = Util.GetGameObject(self.gems,"item ("..i..")")
|
2021-12-10 14:57:23 +08:00
|
|
|
|
local nameImg = Util.GetGameObject(itemGo,"Name"):GetComponent("Image")
|
2021-12-10 16:07:46 +08:00
|
|
|
|
self.lightList[i] = Util.GetGameObject(itemGo,"Light")
|
2021-12-10 14:57:23 +08:00
|
|
|
|
nameImg.sprite = self.spLoader:LoadSprite(imgName[i])
|
2021-12-08 09:29:08 +08:00
|
|
|
|
for j = 1, 3 do
|
|
|
|
|
local stoneGo = Util.GetGameObject(itemGo,"stone ("..j..")")
|
|
|
|
|
local level = Util.GetGameObject(stoneGo,"Text"):GetComponent("Text")
|
2021-12-10 14:57:23 +08:00
|
|
|
|
local icon = Util.GetGameObject(stoneGo,"icon"):GetComponent("Image")
|
|
|
|
|
local img = Util.GetGameObject(stoneGo,"icon"):GetComponent("Image")
|
|
|
|
|
local name = nil
|
2021-12-08 09:29:08 +08:00
|
|
|
|
level.text = ""
|
2021-12-08 15:40:43 +08:00
|
|
|
|
if gemData[i] and gemData[i][j] and gemData[i][j] > 0 then
|
2021-12-08 09:29:08 +08:00
|
|
|
|
name = GetSpriteNameByItemId(gemData[i][j])
|
|
|
|
|
level.text = gemConfig[gemData[i][j]].Level
|
2021-12-07 11:50:03 +08:00
|
|
|
|
end
|
2021-12-10 14:57:23 +08:00
|
|
|
|
if name ~= nil then
|
|
|
|
|
icon.gameObject:SetActive(true)
|
|
|
|
|
icon.sprite = self.spLoader:LoadSprite(name)
|
|
|
|
|
else
|
|
|
|
|
icon.gameObject:SetActive(false)
|
|
|
|
|
end
|
2021-12-07 11:50:03 +08:00
|
|
|
|
end
|
|
|
|
|
Util.AddOnceClick(itemGo,function ()
|
2021-12-08 14:17:18 +08:00
|
|
|
|
self.curType = i
|
2021-12-08 09:29:08 +08:00
|
|
|
|
self:SetStones(gemData[i],i)
|
2021-12-07 11:50:03 +08:00
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2021-12-08 14:17:18 +08:00
|
|
|
|
--设置下部宝石数据
|
2021-12-08 09:29:08 +08:00
|
|
|
|
function Gem:SetStones(_data,index)
|
|
|
|
|
if _data then--最终删除
|
|
|
|
|
LogWarn("[1]:"..tostring(_data[1]).." [2]:"..tostring(_data[2]).." [3]:"..tostring(_data[3]))
|
|
|
|
|
else
|
|
|
|
|
LogWarn("无数据")
|
|
|
|
|
end
|
2021-12-07 17:19:07 +08:00
|
|
|
|
local data = _data
|
2021-12-10 11:40:15 +08:00
|
|
|
|
self.gemName.text = typeName[index].."命格"
|
2021-12-10 16:07:46 +08:00
|
|
|
|
for i = 1, #self.lightList do
|
|
|
|
|
self.lightList:SetActive(self.curType == index)
|
|
|
|
|
end
|
2021-12-07 17:19:07 +08:00
|
|
|
|
for i = 1, 3 do
|
|
|
|
|
local stoneGo = Util.GetGameObject(self.stones,"Stone ("..i..")")
|
|
|
|
|
local item = Util.GetGameObject(stoneGo,"Item")
|
|
|
|
|
local mask = Util.GetGameObject(stoneGo,"Mask")
|
|
|
|
|
local property = Util.GetGameObject(stoneGo,"Property")
|
|
|
|
|
local textPre = Util.GetGameObject(property,"Text")
|
2021-12-08 14:17:18 +08:00
|
|
|
|
local name = Util.GetGameObject(stoneGo,"Name"):GetComponent("Text")
|
|
|
|
|
|
|
|
|
|
textPre:GetComponent("Text").text = ""
|
2021-12-07 17:19:07 +08:00
|
|
|
|
textPre:SetActive(false)
|
2021-12-08 14:17:18 +08:00
|
|
|
|
property:SetActive(false)
|
2021-12-08 09:29:08 +08:00
|
|
|
|
item:SetActive(false)
|
2021-12-08 14:17:18 +08:00
|
|
|
|
name.text = ""
|
2021-12-08 09:29:08 +08:00
|
|
|
|
if data and data[i] and data[i] > 0 then
|
2021-12-07 17:19:07 +08:00
|
|
|
|
if not self.itemList[i] then
|
|
|
|
|
local view = SubUIManager.Open(SubUIConfig.ItemView,item.transform)
|
|
|
|
|
self.itemList[i] = view
|
|
|
|
|
end
|
2021-12-08 09:29:08 +08:00
|
|
|
|
self.itemList[i]:OnOpen(false, {data[i],0}, 1.1, false,false,false,self.sortingOrder + 1)
|
2021-12-07 17:19:07 +08:00
|
|
|
|
self.itemList[i].gameObject:SetActive(true)
|
2021-12-08 09:29:08 +08:00
|
|
|
|
item:SetActive(true)
|
2021-12-10 14:57:23 +08:00
|
|
|
|
name.text = gemConfig[data[i]].Name
|
2021-12-08 14:17:18 +08:00
|
|
|
|
self:SetProperty(gemConfig[data[i]],data,property,textPre)
|
2021-12-07 17:19:07 +08:00
|
|
|
|
end
|
|
|
|
|
Util.AddOnceClick(mask,function ()
|
2021-12-08 14:17:18 +08:00
|
|
|
|
if data and data[i] and data[i] > 0 then
|
|
|
|
|
UIManager.OpenPanel(UIName.RewardGemSingleShowPopup,data[i],2,nil,index,i)
|
|
|
|
|
else
|
|
|
|
|
UIManager.OpenPanel(UIName.GeneralBigPopup,GENERAL_POPUP_TYPE.SelectGem,index,i)
|
|
|
|
|
end
|
2021-12-07 17:19:07 +08:00
|
|
|
|
end)
|
|
|
|
|
end
|
2021-12-07 11:50:03 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-12-08 14:17:18 +08:00
|
|
|
|
function Gem:SetProperty(configData,data,parent,text)
|
|
|
|
|
if not configData then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
if not self.propertyList[parent] then
|
|
|
|
|
self.propertyList[parent] = {}
|
|
|
|
|
end
|
|
|
|
|
for k = 1, #self.propertyList[parent] do
|
|
|
|
|
self.propertyList[parent][k]:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
for j = 1, #configData.Property do
|
|
|
|
|
local data = configData.Property[j]
|
|
|
|
|
local item = self.propertyList[parent][j]
|
|
|
|
|
parent:SetActive(true)
|
|
|
|
|
if not item then
|
|
|
|
|
item = newObjToParent(text,parent.transform)
|
|
|
|
|
self.propertyList[parent][j] = item
|
|
|
|
|
end
|
|
|
|
|
item:SetActive(true)
|
|
|
|
|
item:GetComponent("Text").text = string.format( "%s+%s",PropertyConfig[data[1]].Info,data[2]/100).."%"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2021-12-06 15:07:34 +08:00
|
|
|
|
function Gem:OnClose()
|
2021-12-06 14:06:23 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-12-06 15:07:34 +08:00
|
|
|
|
function Gem:OnDestroy()
|
2021-12-06 14:06:23 +08:00
|
|
|
|
self.spLoader:Destroy()
|
|
|
|
|
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-12-07 17:19:07 +08:00
|
|
|
|
self.itemList = {}
|
2021-12-08 14:17:18 +08:00
|
|
|
|
self.propertyList = {}
|
2021-12-06 14:06:23 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-12-06 15:07:34 +08:00
|
|
|
|
return Gem
|