miduo_client/Assets/ManagedResources/~Lua/Modules/RoleInfo/TalismanInfoPanel.lua

378 lines
15 KiB
Lua
Raw Normal View History

2025-03-14 11:58:20 +08:00
----- 法宝进阶面板 -----
2020-05-09 13:31:21 +08:00
require("Base/BasePanel")
TalismanInfoPanel = Inherit(BasePanel)
local this = TalismanInfoPanel
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
2024-09-06 10:38:56 +08:00
local propertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
local passiveSkillConfig = ConfigManager.GetConfig(ConfigName.PassiveSkillConfig)
local artResourcesConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
local curTalismanConFig --EquipTalismana表数据
2020-05-09 13:31:21 +08:00
local nextTalismanConFig --EquipTalismana下一等级表数据
2024-09-06 10:38:56 +08:00
local curHeroData --当前英雄数据
local heroListData --全部英雄数据
local _heroListData = {} --注意 这是筛选后的数据 本脚本当前英雄数据是从这里再被筛选出来的 匹配未满级的Hero
local data = {} --英雄表下法宝属性
local maxLv = 0 --法宝最大进阶等级
local curLv = 0 --当前法宝等级
local isMaxStar = false --默认不是最大进阶等级
2020-05-09 13:31:21 +08:00
--属性容器
local proList = {}
--进阶奖励容器
2024-09-06 10:38:56 +08:00
local upStarGrid = {}
local itemGrid = {}
2020-05-09 13:31:21 +08:00
local orginLayer
local index = 0
function TalismanInfoPanel:InitComponent()
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2024-09-06 10:38:56 +08:00
orginLayer = 0
self.upView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform, { showType = UpViewOpenType.ShowLeft })
self.effect = Util.GetGameObject(self.gameObject, "Effect")
2020-05-09 13:31:21 +08:00
self.backBtn = Util.GetGameObject(self.gameObject, "btnBack/btnBack")
self.upStarBtn = Util.GetGameObject(self.gameObject, "upStarBtn")
self.leftBtn = Util.GetGameObject(self.gameObject, "LeftBtn")
self.rightBtn = Util.GetGameObject(self.gameObject, "RightBtn")
2024-09-06 10:38:56 +08:00
self.helpBtn = Util.GetGameObject(self.gameObject, "HelpBtn")
self.helpPosition = self.helpBtn:GetComponent("RectTransform").localPosition
2020-05-09 13:31:21 +08:00
--法宝战力
self.force = Util.GetGameObject(self.gameObject, "PowerBtn/Value"):GetComponent("Text")
2024-09-06 10:38:56 +08:00
self.addForce = Util.GetGameObject(self.gameObject, "PowerBtn/AddValue"):GetComponent("Text")
self.upLvEffect = Util.GetGameObject(self.gameObject, "PowerBtn/Effect")
2020-05-09 13:31:21 +08:00
--法宝icon
self.talismanRoot = Util.GetGameObject(self.gameObject, "TalismanRoot"):GetComponent("Image")
self.talismanIcon = Util.GetGameObject(self.gameObject, "TalismanRoot/icon"):GetComponent("Image")
--英雄名称
2024-09-06 10:38:56 +08:00
self.talismanOldNameObj = Util.GetGameObject(self.gameObject, "TalismanRoot/Panel/OldName")
2020-05-09 13:31:21 +08:00
self.talismanOldName = Util.GetGameObject(self.talismanOldNameObj, "Text"):GetComponent("Text")
2024-09-06 10:38:56 +08:00
self.talismanNewNameObj = Util.GetGameObject(self.gameObject, "TalismanRoot/Panel/NewName")
self.talismanNewName = Util.GetGameObject(self.talismanNewNameObj, "Text"):GetComponent("Text")
self.image = Util.GetGameObject(self.gameObject, "TalismanRoot/Image"):GetComponent("Image") --三角图标
2020-05-09 13:31:21 +08:00
--属性
2024-09-06 10:38:56 +08:00
self.upStarMaterialInfo = Util.GetGameObject(self.transform, "downGo/upStarMaterialInfo")
self.noUpStarText = Util.GetGameObject(self.transform, "downGo/noUpStarText")
2020-05-09 13:31:21 +08:00
--属性预设
2024-09-06 10:38:56 +08:00
self.proPre = Util.GetGameObject(self.gameObject, "downGo/proGrid/Root/ProPre")
2020-05-09 13:31:21 +08:00
--属性列表父物体
2024-09-06 10:38:56 +08:00
self.proRoot = Util.GetGameObject(self.gameObject, "downGo/proGrid/Root")
2020-05-09 13:31:21 +08:00
--天赋激活信息
self.skillInfoText = Util.GetGameObject(self.transform, "downGo/skillInfo/Mask/Text"):GetComponent("Text")
--进阶材料根节点
2024-09-06 10:38:56 +08:00
for i = 1, 3 do
upStarGrid[i] = Util.GetGameObject(self.gameObject, "downGo/upStarMaterialInfo/upStarGrid/item" .. i)
2020-05-09 13:31:21 +08:00
end
--金币 姚晶材料
2024-09-06 10:38:56 +08:00
for n = 1, 2 do
itemGrid[n] = Util.GetGameObject(self.gameObject, "downGo/upStarMaterialInfo/itemGrid/item" .. n)
2020-05-09 13:31:21 +08:00
end
end
function TalismanInfoPanel:BindEvent()
Util.AddClick(self.backBtn, function()
2024-09-06 10:38:56 +08:00
UIManager.OpenPanel(UIName.RoleTalismanPanelV2, curHeroData, heroListData)
2020-05-09 13:31:21 +08:00
self:ClosePanel()
end)
Util.AddClick(self.upStarBtn, function()
2024-09-06 10:38:56 +08:00
if HeroManager.GetTalismanLv(curHeroData.dynamicId) >= maxLv then
2024-08-29 21:36:51 +08:00
PopupTipPanel.ShowTip(Language[12697])
2020-05-09 13:31:21 +08:00
return
end
--需要判断材料够不够
2024-09-06 10:38:56 +08:00
local tip = {}
for i = 1, #curTalismanConFig.RankupBasicMaterial do
local id = curTalismanConFig.RankupBasicMaterial[i][1] --物品ID
local needNum = curTalismanConFig.RankupBasicMaterial[i][2] --需要物品数量
local haveNum = BagManager.GetItemCountById(id) --已有物品数量
if haveNum < needNum then
table.insert(tip, GetLanguageStrById(itemConfig[id].Name))
2020-05-09 13:31:21 +08:00
end
end
2024-09-06 10:38:56 +08:00
if #tip > 0 then --有东西不足了
if #tip == 1 then --一个不足时
PopupTipPanel.ShowTip(string.format(Language[10320], tip[1]))
2020-05-09 13:31:21 +08:00
else
for j = 1, #tip do --多个不足 加逗号
2024-09-06 10:38:56 +08:00
if j ~= 1 then
tip[j] = "" .. tip[j]
2020-05-09 13:31:21 +08:00
end
end
2024-09-06 10:38:56 +08:00
PopupTipPanel.ShowTip(string.format(Language[10320], table.concat(tip)))
2020-05-09 13:31:21 +08:00
end
return
end
2024-09-06 10:38:56 +08:00
NetManager.TalismanUpStarRequest(tostring(curHeroData.dynamicId), function(msg)
HeroManager.SetTalismanLv(curHeroData.dynamicId, curHeroData.talismanList + 1) --本地标记等级
--设置战斗力脏数据
HeroPropManager.SetDirtyByType(curHeroData.dynamicId, Hero_Prop_Type.Talisman)
2024-09-06 10:38:56 +08:00
UIManager.OpenPanel(UIName.TalismanUpStarSuccessPanel, curHeroData, function()
2020-05-09 13:31:21 +08:00
self:OnShowPanelData()
2024-09-06 10:38:56 +08:00
end, function() self:ClosePanel() end)
2020-05-09 13:31:21 +08:00
end)
end)
Util.AddClick(self.leftBtn, function()
self:LeftBtnOnClick()
end)
Util.AddClick(self.rightBtn, function()
self:RightBtnOnClick()
end)
--帮助按钮
Util.AddClick(self.helpBtn, function()
2024-09-06 10:38:56 +08:00
UIManager.OpenPanel(UIName.HelpPopup, HELP_TYPE.NewTalismanUp, self.helpPosition.x, self.helpPosition.y)
2020-05-09 13:31:21 +08:00
end)
end
function TalismanInfoPanel:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.BugCoin.OnBuyCoinUpdate, this.ShowUpStarGridData)
end
function TalismanInfoPanel:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.BugCoin.OnBuyCoinUpdate, this.ShowUpStarGridData)
end
function TalismanInfoPanel:OnSortingOrderChange()
Util.AddParticleSortLayer(self.effect, self.sortingOrder - orginLayer)
orginLayer = self.sortingOrder
end
2024-09-06 10:38:56 +08:00
function TalismanInfoPanel:OnOpen(_curHeroData, _heroListData)
2020-05-09 13:31:21 +08:00
curHeroData = _curHeroData
2024-09-06 10:38:56 +08:00
heroListData = _heroListData
2020-05-09 13:31:21 +08:00
end
function TalismanInfoPanel:OnShow()
2024-09-06 10:38:56 +08:00
self.upView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Talisman })
2020-05-09 13:31:21 +08:00
isMaxStar = false
--拿到全部已激活数据 需要筛选出未满级的数据
for i = 1, #heroListData do
2024-09-06 10:38:56 +08:00
local d = ConfigManager.GetConfigData(ConfigName.HeroConfig, heroListData[i].id)
.EquipTalismana --当前法宝数据 data[1]星级 data[2]法宝ID
local mLv = TalismanManager.AllTalismanEndStar[d[2]]
local lv = HeroManager.GetTalismanLv(heroListData[i].dynamicId)
if lv < mLv then
table.insert(_heroListData, heroListData[i])
2020-05-09 13:31:21 +08:00
end
end
2024-09-06 10:38:56 +08:00
for j = 1, #_heroListData do
2020-05-09 13:31:21 +08:00
if curHeroData == _heroListData[j] then
index = j
end
end
--已激活法宝的Hero为1时 隐藏左右按钮
2024-09-06 10:38:56 +08:00
self.leftBtn:SetActive(#heroListData > 1)
self.rightBtn:SetActive(#heroListData > 1)
2020-05-09 13:31:21 +08:00
self:OnShowPanelData()
end
--显示
function TalismanInfoPanel:OnShowPanelData()
2024-09-06 10:38:56 +08:00
data = ConfigManager.GetConfigData(ConfigName.HeroConfig, curHeroData.id)
.EquipTalismana --当前法宝数据 data[1]星级 data[2]法宝ID
2020-05-09 13:31:21 +08:00
--获取最大等级
TalismanManager.GetStartAndEndStar()
2024-09-06 10:38:56 +08:00
maxLv = 50
2020-05-09 13:31:21 +08:00
--获取当前法宝等级
2024-09-06 10:38:56 +08:00
curLv = HeroManager.GetTalismanLv(curHeroData.dynamicId)
2020-05-09 13:31:21 +08:00
--获取当前等级与下一等级表数据
2024-09-06 10:38:56 +08:00
local nextLv = 0
if (curLv + 1) <= maxLv then
nextLv = curLv + 1
2020-05-09 13:31:21 +08:00
end
isMaxStar = curLv >= maxLv
2024-09-06 10:38:56 +08:00
curTalismanConFig = ConfigManager.GetConfigDataByDoubleKey(ConfigName.EquipTalismana, "Level", curLv, "TalismanaId",
data[2])
if isMaxStar == false then
nextTalismanConFig = ConfigManager.GetConfigDataByDoubleKey(ConfigName.EquipTalismana, "TalismanaId", data[2],
"Level", nextLv)
2022-08-30 15:55:37 +08:00
end
2024-09-06 10:38:56 +08:00
2020-05-09 13:31:21 +08:00
--法宝战力
2024-09-06 10:38:56 +08:00
local curPower = TalismanManager.CalculateWarForceBase(curTalismanConFig, 0)
2022-08-30 15:55:37 +08:00
-- local nextPower=TalismanManager.CalculateWarForceBase(nextTalismanConFig,0)
2020-05-09 13:31:21 +08:00
self.force.text = curPower
2022-08-30 15:55:37 +08:00
-- self.addForce.text="+"..(nextPower-curPower)
2020-05-09 13:31:21 +08:00
--法宝Icon 边框品质
2021-04-21 13:12:04 +08:00
self.talismanRoot.sprite = this.spLoader:LoadSprite(TalismanBubble[itemConfig[data[2]].Quantity])
self.talismanIcon.sprite = this.spLoader:LoadSprite(GetResourcePath(itemConfig[data[2]].ResourceID))
2020-05-09 13:31:21 +08:00
self.talismanNewNameObj:SetActive(not isMaxStar)
2024-09-06 10:38:56 +08:00
self.image.enabled = not isMaxStar
if isMaxStar == false then
self.talismanOldName.text = string.format("%s+%s", GetLanguageStrById(itemConfig[data[2]].Name), curLv)
self.talismanNewName.text = string.format("%s<color=#FE5022>+%s</color>",
GetLanguageStrById(itemConfig[data[2]].Name), curLv + 1)
2020-05-09 13:31:21 +08:00
else
2024-09-06 10:38:56 +08:00
self.talismanOldName.text = string.format("%s+%s", GetLanguageStrById(itemConfig[data[2]].Name), maxLv)
2020-05-09 13:31:21 +08:00
end
self:ShowProAndSkillData()
this.ShowUpStarGridData() --self真的很坑
end
--显示属性提升、天赋激活信息
function TalismanInfoPanel:ShowProAndSkillData()
self.upStarMaterialInfo:SetActive(not isMaxStar)
self.noUpStarText:SetActive(isMaxStar)
--设置属性提升
2024-09-06 10:38:56 +08:00
for i = 1, #curTalismanConFig.Property do
local item = proList[i]
2020-05-09 13:31:21 +08:00
if not item then
2024-09-06 10:38:56 +08:00
item = newObjToParent(self.proPre, self.proRoot)
item.name = "ProPre" .. i
proList[i] = item
2020-05-09 13:31:21 +08:00
end
2024-09-06 10:38:56 +08:00
local icon = Util.GetGameObject(proList[i], "Icon"):GetComponent("Image")
local proName = Util.GetGameObject(proList[i], "ProName"):GetComponent("Text")
local proValue = Util.GetGameObject(proList[i], "ProValue"):GetComponent("Text")
local nextProValue = Util.GetGameObject(proList[i], "NextProValue"):GetComponent("Text")
local skillId = curTalismanConFig.Property[i][1]
local curValue = curTalismanConFig.Property[i][2]
local nextValue = 0
if not isMaxStar then
nextValue = nextTalismanConFig.Property[i][2]
2022-08-30 15:55:37 +08:00
end
2024-09-06 10:38:56 +08:00
icon.sprite = this.spLoader:LoadSprite(artResourcesConfig[propertyConfig[skillId].PropertyIcon].Name)
2020-05-09 13:31:21 +08:00
icon:SetNativeSize()
2024-09-06 10:38:56 +08:00
proName.text = GetLanguageStrById(propertyConfig[skillId].Info)
proValue.text = curValue
nextProValue.text = nextValue
2020-05-09 13:31:21 +08:00
end
--显示法宝天赋
--筛选出符合要求的数据
2024-09-06 10:38:56 +08:00
local dowerAllData = ConfigManager.GetAllConfigsDataByKey(ConfigName.EquipTalismana, "TalismanaId", data[2])
local dowerData = {} --当前法宝全部技能开放数据
for i = 1, #dowerAllData do
2020-05-09 13:31:21 +08:00
if dowerAllData[i].OpenSkillRules then
2024-09-06 10:38:56 +08:00
table.insert(dowerData, dowerAllData[i])
2020-05-09 13:31:21 +08:00
end
end
2024-09-06 10:38:56 +08:00
table.sort(dowerData, function(a, b) return a.OpenSkillRules[1] < b.OpenSkillRules[1] end)
local targetLv = self:GetTargetLv(dowerData)
if isMaxStar == false then
local skillId = ConfigManager.GetConfigDataByDoubleKey(ConfigName.EquipTalismana, "Level", targetLv,
"TalismanaId", data[2]).OpenSkillRules[1]
self.skillInfoText.text = string.format(Language[12259], GetLanguageStrById(passiveSkillConfig[skillId].Desc),
self:GetTargetLv(dowerData))
2022-08-30 15:55:37 +08:00
else
2024-09-06 10:38:56 +08:00
self.skillInfoText.text = ""
2022-08-30 15:55:37 +08:00
end
2020-05-09 13:31:21 +08:00
end
--根据当前法宝等级获取法宝最近的下一等级
function TalismanInfoPanel:GetTargetLv(dowerData)
2024-09-06 10:38:56 +08:00
for j = 1, #dowerData do
if dowerData[j].Level > curLv then
2020-05-09 13:31:21 +08:00
return dowerData[j].Level
end
end
end
--显示进阶信息
function this.ShowUpStarGridData()
if isMaxStar then return end
--关闭激活
2024-09-06 10:38:56 +08:00
for n = 1, #upStarGrid do
2020-05-09 13:31:21 +08:00
upStarGrid[n].gameObject:SetActive(false)
end
2024-09-06 10:38:56 +08:00
for m = 1, #itemGrid do
2020-05-09 13:31:21 +08:00
itemGrid[m].gameObject:SetActive(false)
end
--数据拆分
2024-09-06 10:38:56 +08:00
local upStarData = {} --不包含金币姚晶的数据
local itemData = {} --金币姚晶的数据
2020-05-09 13:31:21 +08:00
--根据消耗材料显示
2024-09-06 10:38:56 +08:00
for i = 1, #curTalismanConFig.RankupBasicMaterial do
local _data = curTalismanConFig.RankupBasicMaterial[i]
local itemId = _data[1]
if itemId == 14 or itemId == 16 then
2020-05-09 13:31:21 +08:00
table.insert(itemData, _data)
else
table.insert(upStarData, _data)
end
end
--赋值
2024-09-06 10:38:56 +08:00
for x = 1, #upStarData do
2020-05-09 13:31:21 +08:00
upStarGrid[x].gameObject:SetActive(true)
2024-09-06 10:38:56 +08:00
local id = upStarData[x][1] --物品ID
local needNum = upStarData[x][2] --需要物品数量
local haveNum = BagManager.GetItemCountById(id) --已有物品数量
2020-05-09 13:31:21 +08:00
2024-09-06 10:38:56 +08:00
local info = ""
if haveNum >= needNum then
info = haveNum .. "/" .. needNum
2020-05-09 13:31:21 +08:00
else
2024-09-06 10:38:56 +08:00
info = "<color=red>" .. haveNum .. "/" .. needNum .. "</color>"
2020-05-09 13:31:21 +08:00
end
2024-09-06 10:38:56 +08:00
local frame = Util.GetGameObject(upStarGrid[x], "frame"):GetComponent("Image")
local icon = Util.GetGameObject(upStarGrid[x], "icon"):GetComponent("Image")
local num = Util.GetGameObject(upStarGrid[x], "num"):GetComponent("Text")
frame.sprite = this.spLoader:LoadSprite(GetHeroQuantityImageByquality(itemConfig[id].Quantity))
icon.sprite = this.spLoader:LoadSprite(GetResourcePath(itemConfig[id].ResourceID))
num.text = info
Util.AddOnceClick(frame.gameObject, function()
UIManager.OpenPanel(UIName.RewardItemSingleShowPopup, id)
2020-05-09 13:31:21 +08:00
end)
end
2024-09-06 10:38:56 +08:00
for y = 1, #itemData do
2020-05-09 13:31:21 +08:00
itemGrid[y].gameObject:SetActive(true)
2024-09-06 10:38:56 +08:00
local id = itemData[y][1] --物品ID
local haveNum = BagManager.GetItemCountById(id) --已有物品数量
local needNum = itemData[y][2] --需要物品数量
local icon = Util.GetGameObject(itemGrid[y], "icon"):GetComponent("Image")
local num = Util.GetGameObject(itemGrid[y], "num"):GetComponent("Text")
icon.sprite = this.spLoader:LoadSprite(GetResourcePath(itemConfig[id].ResourceID))
if haveNum >= needNum then
num.text = PrintWanNum2(needNum)
2020-05-09 13:31:21 +08:00
else
2024-09-06 10:38:56 +08:00
num.text = "<color=red>" .. PrintWanNum2(needNum) .. "</color>"
2020-05-09 13:31:21 +08:00
end
end
end
--右切换按钮点击
function TalismanInfoPanel:RightBtnOnClick()
index = (index + 1 <= #_heroListData and index + 1 or 1)
curHeroData = _heroListData[index]
2024-09-06 10:38:56 +08:00
if HarmonyManager.IsChangeColor(curHeroData.dynamicId) then
2021-01-11 21:04:12 +08:00
self:RightBtnOnClick()
else
self:OnShowPanelData()
end
2020-05-09 13:31:21 +08:00
end
2024-09-06 10:38:56 +08:00
2020-05-09 13:31:21 +08:00
--左切换按钮点击
function TalismanInfoPanel:LeftBtnOnClick()
index = (index - 1 > 0 and index - 1 or #_heroListData)
curHeroData = _heroListData[index]
2024-09-06 10:38:56 +08:00
if HarmonyManager.IsChangeColor(curHeroData.dynamicId) then
2021-01-11 21:04:12 +08:00
self:LeftBtnOnClick()
else
self:OnShowPanelData()
end
2020-05-09 13:31:21 +08:00
end
function TalismanInfoPanel:OnClose()
end
function TalismanInfoPanel:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2020-05-09 13:31:21 +08:00
SubUIManager.Close(self.upView)
2024-09-06 10:38:56 +08:00
proList = {}
2020-05-09 13:31:21 +08:00
end
2024-09-06 10:38:56 +08:00
return TalismanInfoPanel