miduo_client/Assets/ManagedResources/~Lua/Modules/RoleInfo/EquipTreasureResonancePanel...

286 lines
15 KiB
Lua
Raw Normal View History

2021-04-21 13:12:04 +08:00
require("Base/BasePanel")
2020-05-09 13:31:21 +08:00
EquipTreasureResonancePanel = Inherit(BasePanel)
local this = EquipTreasureResonancePanel
local jewelConfig = ConfigManager.GetConfig(ConfigName.JewelConfig)
local propertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
local TabBox = require("Modules/Common/TabBox")
local _TabData={
2021-03-02 16:53:12 +08:00
[1] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = Language[11756] },
[2] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = Language[11757] },
2020-05-09 13:31:21 +08:00
}
local _TabFontColor = { default = Color.New(130 / 255, 128 / 255, 120 / 255, 1),
select = Color.New(243 / 255, 235 / 255, 202 / 255, 1)}
local curHeroData
local curTabIndex = 1--当前是强化 还是 精炼
local equipTreasureList = {}--宝器对象
local curJewelResonanceConfig--当前共鸣静态数据
local nextJewelResonanceConfig--下一共鸣静态数据
local curProList = {}--当前共鸣属性
local nextProList = {}--下一共鸣属性
--初始化组件(用于子类重写)
function EquipTreasureResonancePanel:InitComponent()
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2020-05-09 13:31:21 +08:00
this.TabCtrl = TabBox.New()
this.tabBox = Util.GetGameObject(self.transform, "TabBox")
this.btnBack = Util.GetGameObject(self.transform, "btnBack")
this.curProListCurLv = Util.GetGameObject(self.transform, "materialImageBg/curProList/curLv"):GetComponent("Text")
this.nextProListCurLv = Util.GetGameObject(self.transform, "materialImageBg/nextProList/curLv"):GetComponent("Text")
this.nextProList = Util.GetGameObject(self.transform, "materialImageBg/nextProList")
2020-05-15 16:52:35 +08:00
this.nextHint=Util.GetGameObject(self.transform, "materialImageBg/nextProList/Text"):GetComponent("Text")
this.hintInfo=Util.GetGameObject(self.transform, "titleBg/hintInfo"):GetComponent("Text")
2020-05-09 13:31:21 +08:00
for i = 1, 2 do
equipTreasureList[i] = Util.GetGameObject(self.transform, "grid/equipTreasure ("..i..")")
curProList[i] = Util.GetGameObject(self.transform, "materialImageBg/curProList/pro/Pro ("..i..")")
nextProList[i] = Util.GetGameObject(self.transform, "materialImageBg/nextProList/pro/Pro ("..i..")")
end
2020-05-15 16:52:35 +08:00
this.targetObj=Util.GetGameObject(self.transform, "titleBg/Image (2)")
2020-05-09 13:31:21 +08:00
end
--绑定事件(用于子类重写)
function EquipTreasureResonancePanel:BindEvent()
Util.AddClick(this.btnBack, function()
self:ClosePanel()
end)
end
--添加事件监听(用于子类重写)
function EquipTreasureResonancePanel:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.Treasure.TreasureLvUp, this.CurrEquipDataChange)
end
--移除事件监听(用于子类重写)
function EquipTreasureResonancePanel:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.Treasure.TreasureLvUp, this.CurrEquipDataChange)
end
function this.CurrEquipDataChange()
this.OnShowData()
end
--界面打开时调用(用于子类重写)
function EquipTreasureResonancePanel:OnOpen(_curHeroData,_curTabIndex)
curHeroData = _curHeroData
curTabIndex = _curTabIndex or 1
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function EquipTreasureResonancePanel:OnShow()
this.TabCtrl:SetTabAdapter(this.TabAdapter)
this.TabCtrl:Init(this.tabBox, _TabData,curTabIndex)
2020-06-30 18:59:44 +08:00
this.TabCtrl:SetChangeTabCallBack(this.SwitchView)
2020-05-09 13:31:21 +08:00
this.OnShowData()
end
--限时内容
function this.OnShowData()
2020-05-15 16:52:35 +08:00
--获取穿戴宝物强化/精炼的最小等级
2020-05-09 13:31:21 +08:00
local minLv--最小等级
local maxlv --最大等级
2020-05-09 13:31:21 +08:00
for i = 1, #curHeroData.jewels do
local curEquipTreasureData = EquipTreasureManager.GetSingleEquipTreasreData(curHeroData.jewels[i])
if curTabIndex == 1 then
if minLv then
if curEquipTreasureData.lv < minLv then
minLv = curEquipTreasureData.lv
end
else
minLv = curEquipTreasureData.lv
end
if maxlv then
if curEquipTreasureData.maxLv < maxlv then
maxlv = curEquipTreasureData.maxLv
end
else
maxlv = curEquipTreasureData.maxLv
end
2021-03-02 16:53:12 +08:00
this.hintInfo.text=Language[11758]
2020-05-09 13:31:21 +08:00
elseif curTabIndex == 2 then
if minLv then
if curEquipTreasureData.refineLv < minLv then
minLv = curEquipTreasureData.refineLv
end
else
minLv = curEquipTreasureData.refineLv
end
if maxlv then
if curEquipTreasureData.maxRefineLv < maxlv then
maxlv = curEquipTreasureData.maxRefineLv
end
else
maxlv = curEquipTreasureData.maxRefineLv
end
2021-03-02 16:53:12 +08:00
this.hintInfo.text=Language[11759]
2020-05-09 13:31:21 +08:00
end
end
2020-06-30 18:59:44 +08:00
LogBlue("minLv:"..minLv)
LogBlue("maxlv:"..maxlv)
2020-05-09 13:31:21 +08:00
curJewelResonanceConfig = nil
nextJewelResonanceConfig = nil
local allCurTypeJewelResonanceConfig = ConfigManager.GetAllConfigsDataByKey(ConfigName.JewelResonanceConfig,"Type",curTabIndex)
2020-05-15 16:52:35 +08:00
table.sort(allCurTypeJewelResonanceConfig,function(a,b)
return a.SortId<b.SortId
end)
2020-06-30 18:59:44 +08:00
LogBlue(#allCurTypeJewelResonanceConfig)
2020-05-09 13:31:21 +08:00
for i = 1, #allCurTypeJewelResonanceConfig do
2020-05-15 16:52:35 +08:00
--获取当前强化/精炼 大师等级数据
2020-06-30 18:59:44 +08:00
if allCurTypeJewelResonanceConfig[i].Level <= minLv then
2020-05-09 13:31:21 +08:00
if curJewelResonanceConfig then
2020-05-15 16:52:35 +08:00
if curJewelResonanceConfig.SortId < allCurTypeJewelResonanceConfig[i].SortId then
2020-05-09 13:31:21 +08:00
curJewelResonanceConfig = allCurTypeJewelResonanceConfig[i]
end
else
curJewelResonanceConfig = allCurTypeJewelResonanceConfig[i]
end
end
2020-05-15 16:52:35 +08:00
--获取下一级强化/精炼 大师等级数据
if allCurTypeJewelResonanceConfig[i].Level > minLv and allCurTypeJewelResonanceConfig[i].Level <= maxlv then
2020-05-09 13:31:21 +08:00
if curJewelResonanceConfig then
2020-05-15 16:52:35 +08:00
if nextJewelResonanceConfig==nil then
if allCurTypeJewelResonanceConfig[i].SortId == curJewelResonanceConfig.SortId+1 then
nextJewelResonanceConfig = allCurTypeJewelResonanceConfig[i]
end
2020-05-09 13:31:21 +08:00
end
end
end
end
--curJewelResonanceConfig = ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.JewelResonanceConfig,"Type",curTabIndex,"SortId",nextJewelResonanceConfig.SortId - 1)
for i = 1, #curHeroData.jewels do
this.OnShowSingleEquipTreasure(equipTreasureList[i],curHeroData.jewels[i])
end
this.OnShowPro()
end
function this.OnShowSingleEquipTreasure(go,equipTreasureDid)
local isMaxLv = false
local curEquipTreasureData = EquipTreasureManager.GetSingleEquipTreasreData(equipTreasureDid)
if not curEquipTreasureData then return end
local configData = jewelConfig[curEquipTreasureData.id]
2021-04-21 13:12:04 +08:00
Util.GetGameObject(go.transform,"equip/icon"):GetComponent("Image").sprite=this.spLoader:LoadSprite(curEquipTreasureData.icon)
Util.GetGameObject(go.transform,"equip/proImage"):GetComponent("Image").sprite=this.spLoader:LoadSprite(GetProStrImageByProNum(configData.Race))
Util.GetGameObject(go.transform,"equip/frame"):GetComponent("Image").sprite=this.spLoader:LoadSprite(curEquipTreasureData.frame)
2021-01-26 17:08:39 +08:00
Util.GetGameObject(go.transform,"name"):GetComponent("Text").text = GetLanguageStrById(curEquipTreasureData.itemConfig.Name)
2020-05-09 13:31:21 +08:00
Util.GetGameObject(go.transform,"equip/strongLv"):GetComponent("Text").text = curEquipTreasureData.lv
Util.GetGameObject(go.transform,"equip/refineLv"):GetComponent("Text").text = curEquipTreasureData.refineLv
if curTabIndex == 1 then
if nextJewelResonanceConfig and nextJewelResonanceConfig.Level then
2020-05-15 16:52:35 +08:00
if curEquipTreasureData.lv>=curEquipTreasureData.maxLv then
2021-03-02 16:53:12 +08:00
Util.GetGameObject(go.transform,"btn/Text"):GetComponent("Text").text = Language[11062]
2020-05-15 16:52:35 +08:00
else
2021-03-02 16:53:12 +08:00
Util.GetGameObject(go.transform,"btn/Text"):GetComponent("Text").text = Language[11760]
2020-05-15 16:52:35 +08:00
end
2020-05-09 13:31:21 +08:00
Util.GetGameObject(go.transform,"progress"):GetComponent("Text").text = curEquipTreasureData.lv.."/"..nextJewelResonanceConfig.Level
2020-05-15 16:52:35 +08:00
Util.GetGameObject(go.transform,"equip/proBar"):GetComponent("Image").fillAmount = curEquipTreasureData.lv/nextJewelResonanceConfig.Level
2020-05-09 13:31:21 +08:00
else
if curEquipTreasureData.lv >= curEquipTreasureData.maxLv then
2021-03-02 16:53:12 +08:00
Util.GetGameObject(go.transform,"progress"):GetComponent("Text").text = Language[11761]
Util.GetGameObject(go.transform,"btn/Text"):GetComponent("Text").text = Language[11062]
Util.GetGameObject(go.transform,"equip/proBar"):GetComponent("Image").fillAmount =1
else
2021-03-02 16:53:12 +08:00
Util.GetGameObject(go.transform,"btn/Text"):GetComponent("Text").text = Language[11760]
Util.GetGameObject(go.transform,"progress"):GetComponent("Text").text = curEquipTreasureData.lv.."/"..curJewelResonanceConfig.Level
Util.GetGameObject(go.transform,"equip/proBar"):GetComponent("Image").fillAmount = curEquipTreasureData.lv/curJewelResonanceConfig.Level
end
2020-05-09 13:31:21 +08:00
end
2020-05-15 16:52:35 +08:00
2020-05-09 13:31:21 +08:00
--点击强化按钮
Util.AddOnceClick(Util.GetGameObject(go.transform,"btn"), function()
if curEquipTreasureData.lv==curEquipTreasureData.maxLv then
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[11762])
2020-05-09 13:31:21 +08:00
return
end
UIManager.OpenPanel(UIName.EquipTreasureStrongPopup,curEquipTreasureData,1)
end)
elseif curTabIndex == 2 then
if nextJewelResonanceConfig and nextJewelResonanceConfig.Level then
2020-05-15 16:52:35 +08:00
if curEquipTreasureData.refineLv>=curEquipTreasureData.maxRefineLv then
2021-03-02 16:53:12 +08:00
Util.GetGameObject(go.transform,"btn/Text"):GetComponent("Text").text = Language[11062]
2020-05-15 16:52:35 +08:00
else
2021-03-02 16:53:12 +08:00
Util.GetGameObject(go.transform,"btn/Text"):GetComponent("Text").text = Language[11763]
2020-05-15 16:52:35 +08:00
end
2020-05-09 13:31:21 +08:00
Util.GetGameObject(go.transform,"progress"):GetComponent("Text").text = curEquipTreasureData.refineLv.."/"..nextJewelResonanceConfig.Level
2020-05-15 16:52:35 +08:00
Util.GetGameObject(go.transform,"equip/proBar"):GetComponent("Image").fillAmount = curEquipTreasureData.refineLv/nextJewelResonanceConfig.Level
2020-05-09 13:31:21 +08:00
else
if curEquipTreasureData.refineLv>=curEquipTreasureData.maxRefineLv then
2021-03-02 16:53:12 +08:00
Util.GetGameObject(go.transform,"progress"):GetComponent("Text").text = Language[11761]
Util.GetGameObject(go.transform,"btn/Text"):GetComponent("Text").text = Language[11062]
Util.GetGameObject(go.transform,"equip/proBar"):GetComponent("Image").fillAmount = 1
else
2021-03-02 16:53:12 +08:00
Util.GetGameObject(go.transform,"btn/Text"):GetComponent("Text").text = Language[11763]
Util.GetGameObject(go.transform,"progress"):GetComponent("Text").text = curEquipTreasureData.refineLv.."/"..curJewelResonanceConfig.Level
Util.GetGameObject(go.transform,"equip/proBar"):GetComponent("Image").fillAmount = curEquipTreasureData.refineLv/curJewelResonanceConfig.Level
end
2020-05-09 13:31:21 +08:00
end
--点击精炼按钮
Util.AddOnceClick(Util.GetGameObject(go.transform,"btn"), function()
if curEquipTreasureData.refineLv==curEquipTreasureData.maxRefineLv then
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[11762])
2020-05-09 13:31:21 +08:00
return
end
UIManager.OpenPanel(UIName.EquipTreasureStrongPopup,curEquipTreasureData,2)
end)
end
end
--属性展示
function this.OnShowPro()
2020-05-15 16:52:35 +08:00
local currLv=0
2020-05-09 13:31:21 +08:00
if curJewelResonanceConfig and curJewelResonanceConfig.Level then
for i = 1, #curJewelResonanceConfig.Property do
2021-01-26 17:08:39 +08:00
Util.GetGameObject(curProList[i], "curProName"):GetComponent("Text").text = GetLanguageStrById(propertyConfig[curJewelResonanceConfig.Property[i][1]].Info)
2020-05-09 13:31:21 +08:00
Util.GetGameObject(curProList[i], "curProVal"):GetComponent("Text").text = GetPropertyFormatStr(propertyConfig[curJewelResonanceConfig.Property[i][1]].Style,curJewelResonanceConfig.Property[i][2])
end
2020-05-15 16:52:35 +08:00
currLv=curJewelResonanceConfig.Level
2020-05-09 13:31:21 +08:00
else
this.curProListCurLv.text = 0
2020-05-15 16:52:35 +08:00
if nextJewelResonanceConfig and nextJewelResonanceConfig.Property then
for i = 1, #nextJewelResonanceConfig.Property do
2021-01-26 17:08:39 +08:00
Util.GetGameObject(curProList[i], "curProName"):GetComponent("Text").text = GetLanguageStrById(propertyConfig[nextJewelResonanceConfig.Property[i][1]].Info)
2020-05-15 16:52:35 +08:00
Util.GetGameObject(curProList[i], "curProVal"):GetComponent("Text").text = GetPropertyFormatStr(propertyConfig[nextJewelResonanceConfig.Property[i][1]].Style,0)
end
2020-05-09 13:31:21 +08:00
end
end
2020-05-15 16:52:35 +08:00
if curTabIndex==1 then
2021-03-02 16:53:12 +08:00
this.curProListCurLv.text =string.format(Language[11764],curJewelResonanceConfig.SortId)
2020-05-15 16:52:35 +08:00
else
2021-03-02 16:53:12 +08:00
this.curProListCurLv.text =string.format(Language[11765],curJewelResonanceConfig.SortId)
2020-05-15 16:52:35 +08:00
end
2020-05-09 13:31:21 +08:00
if nextJewelResonanceConfig and nextJewelResonanceConfig.Level then
this.nextProList:SetActive(true)
2020-05-15 16:52:35 +08:00
this.targetObj.gameObject:SetActive(true)
if curTabIndex==1 then
2021-03-02 16:53:12 +08:00
this.nextProListCurLv.text = string.format(Language[11766],nextJewelResonanceConfig.SortId)
this.nextHint.text=string.format(Language[11767],nextJewelResonanceConfig.Level)
2020-05-15 16:52:35 +08:00
else
2021-03-02 16:53:12 +08:00
this.nextProListCurLv.text = string.format(Language[11768],nextJewelResonanceConfig.SortId)
this.nextHint.text=string.format(Language[11769],nextJewelResonanceConfig.Level)
2020-05-15 16:52:35 +08:00
end
2020-05-09 13:31:21 +08:00
for i = 1, #nextJewelResonanceConfig.Property do
2021-01-26 17:08:39 +08:00
Util.GetGameObject(nextProList[i], "curProName"):GetComponent("Text").text = GetLanguageStrById(propertyConfig[nextJewelResonanceConfig.Property[i][1]].Info)
2020-05-09 13:31:21 +08:00
Util.GetGameObject(nextProList[i], "curProVal"):GetComponent("Text").text = GetPropertyFormatStr(propertyConfig[nextJewelResonanceConfig.Property[i][1]].Style,nextJewelResonanceConfig.Property[i][2])
end
else
this.nextProList:SetActive(false)
2020-05-15 16:52:35 +08:00
this.targetObj.gameObject:SetActive(false)
2020-05-09 13:31:21 +08:00
end
end
-- tab节点显示自定义
function this.TabAdapter(tab, index, status)
local tabLab = Util.GetGameObject(tab, "Text")
local tabImage = Util.GetGameObject(tab,"Image")
2021-04-21 13:12:04 +08:00
tabImage:GetComponent("Image").sprite = this.spLoader:LoadSprite(_TabData[index][status])
2020-05-09 13:31:21 +08:00
tabLab:GetComponent("Text").text = _TabData[index].name
tabLab:GetComponent("Text").color = _TabFontColor[status]
end
--切换视图
function this.SwitchView(index)
curTabIndex = index
this.OnShowData()
end
--界面关闭时调用(用于子类重写)
function EquipTreasureResonancePanel:OnClose()
end
--界面销毁时调用(用于子类重写)
function EquipTreasureResonancePanel:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2020-05-09 13:31:21 +08:00
end
return EquipTreasureResonancePanel