miduo_client/Assets/ManagedResources/~Lua/Modules/Incarnation/IncarnationUpPopup.lua

326 lines
14 KiB
Lua
Raw Normal View History

2022-04-22 18:24:33 +08:00
require("Base/BasePanel")
IncarnationUpPopup = Inherit(BasePanel)
local this = IncarnationUpPopup
local type
local cardData
local curCardId
local curStar
local curLevel
local PropertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
2024-09-06 10:38:56 +08:00
local curSelectMat = {}
local starConfig = nil
local costEnough = true
2022-04-22 18:24:33 +08:00
function this:InitComponent()
this.spLoader = SpriteLoader.New()
this.mask = Util.GetGameObject(self.gameObject, "mask")
this.closeBtn = Util.GetGameObject(self.gameObject, "root/bg/closeBtn")
this.titleText = Util.GetGameObject(self.gameObject, "root/bg/titleText"):GetComponent("Text")
2022-04-24 19:46:59 +08:00
2024-09-06 10:38:56 +08:00
this.prefab = Util.GetGameObject(self.gameObject, "root/prefab")
this.lvLayout = Util.GetGameObject(self.gameObject, "root/verLayout/lvLayout")
this.curLvText = Util.GetGameObject(this.lvLayout, "grid/curLv"):GetComponent("Text")
this.nextLvText = Util.GetGameObject(this.lvLayout, "grid/nextLv"):GetComponent("Text")
2022-04-24 19:46:59 +08:00
2024-09-06 10:38:56 +08:00
this.proyLayout = Util.GetGameObject(self.gameObject, "root/verLayout/proyLayout")
this.curProp = Util.GetGameObject(this.proyLayout, "grid/curProp")
this.nextProp = Util.GetGameObject(this.proyLayout, "grid/nextProp")
2022-04-25 14:42:17 +08:00
2024-09-06 10:38:56 +08:00
this.forceLayout = Util.GetGameObject(self.gameObject, "root/verLayout/forceLayout")
this.curDrop = Util.GetGameObject(this.forceLayout, "grid/curDrop"):GetComponent("Text")
this.nextDrop = Util.GetGameObject(this.forceLayout, "grid/nextDrop"):GetComponent("Text")
this.skillLayout = Util.GetGameObject(self.gameObject, "root/verLayout/skillLayout")
this.curSkillDes = Util.GetGameObject(this.skillLayout, "grid/curSkillDes/text"):GetComponent("Text")
this.nextSkillDes = Util.GetGameObject(this.skillLayout, "grid/nextSkillDes/text"):GetComponent("Text")
2022-04-24 16:50:24 +08:00
2022-04-22 18:24:33 +08:00
--消耗相关
2024-09-06 10:38:56 +08:00
this.costLayout = Util.GetGameObject(self.gameObject, "root/verLayout/costLayout")
2022-04-24 19:46:59 +08:00
this.costGrid = Util.GetGameObject(this.costLayout, "costGrid")
2022-11-02 11:48:41 +08:00
this.costImg = Util.GetGameObject(this.costLayout, "costItem/Image"):GetComponent("Image")
this.costTxt = Util.GetGameObject(this.costLayout, "costItem/Text"):GetComponent("Text")
this.costImg.gameObject:SetActive(false)
this.costTxt.gameObject:SetActive(false)
2024-09-06 10:38:56 +08:00
this.costItem = Util.GetGameObject(this.costLayout, "costGrid/costItem")
this.frame = Util.GetGameObject(this.costItem, "frame"):GetComponent("Image")
this.iconDefault = Util.GetGameObject(this.costItem, "iconDefault")
this.icon = Util.GetGameObject(this.costItem, "icon"):GetComponent("Image")
this.addBtn = Util.GetGameObject(this.costItem, "add")
this.num = Util.GetGameObject(this.costItem, "num"):GetComponent("Text")
this.bianImg = Util.GetGameObject(this.costItem, "bianImg")
2022-04-24 19:46:59 +08:00
this.upLvBtn = Util.GetGameObject(this.costLayout, "upLvBtn")
2024-09-06 10:38:56 +08:00
this.upLvText = Util.GetGameObject(this.costLayout, "upLvBtn/Text"):GetComponent("Text")
2022-04-24 19:46:59 +08:00
this.upStarBtn = Util.GetGameObject(this.costLayout, "upStarBtn")
2024-09-06 10:38:56 +08:00
this.upStarText = Util.GetGameObject(this.costLayout, "upStarBtn/Text"):GetComponent("Text")
this.itemView = SubUIManager.Open(SubUIConfig.ItemView, this.prefab.transform)
2022-04-22 18:24:33 +08:00
end
function this:BindEvent()
Util.AddClick(this.backBtn, function()
self:ClosePanel()
end)
Util.AddClick(this.closeBtn, function()
self:ClosePanel()
end)
Util.AddClick(this.upLvBtn, function()
if this.CheckLevelLimit() then
2024-08-29 21:36:51 +08:00
PopupTipPanel.ShowTip(Language[11213])
2022-04-22 18:24:33 +08:00
return
end
2024-09-06 10:38:56 +08:00
local cardLvConfig = ConfigManager.GetConfigDataByDoubleKey(ConfigName.ChangingCardLevel, "Level", curLevel,
"PoolId", this.cardConfig.LevelUpPool)
if BagManager.GetItemCountById(cardLvConfig.Exp[1]) < cardLvConfig.Exp[2] then
2024-08-29 21:36:51 +08:00
PopupTipPanel.ShowTip(Language[10524])
2022-04-22 18:24:33 +08:00
return
end
this.upLvBtnOnClick()
end)
Util.AddClick(this.upStarBtn, function()
if this.CheckStarLimit() then
2024-08-29 21:36:51 +08:00
PopupTipPanel.ShowTip(Language[11216])
2022-04-22 18:24:33 +08:00
return
end
2024-09-06 10:38:56 +08:00
local selectNum = 0
2022-04-26 13:44:19 +08:00
for i = 1, #curSelectMat do
2024-09-06 10:38:56 +08:00
selectNum = selectNum + curSelectMat[i].num
2022-04-26 13:44:19 +08:00
end
2024-09-06 10:38:56 +08:00
if selectNum < starConfig.PropList[1][2] or not costEnough then
2024-08-29 21:36:51 +08:00
PopupTipPanel.ShowTip(Language[10524])
2022-04-22 18:24:33 +08:00
return
end
this.upStarBtnOnClick()
end)
Util.AddClick(this.addBtn, function()
2024-09-06 10:38:56 +08:00
UIManager.OpenPanel(UIName.IncarnationUpStarListPanel, this, curSelectMat, starConfig.PropList[1],
this.cardConfig.CardId)
2022-04-22 18:24:33 +08:00
end)
end
2024-09-06 10:38:56 +08:00
2022-04-22 18:24:33 +08:00
-- type 1:升级 2:升星 cardId化身卡id
2024-09-06 10:38:56 +08:00
function this:OnOpen(_type, _cardId)
type = _type
curCardId = _cardId
this.cardConfig = ConfigManager.GetConfigData(ConfigName.ChangingCard, _cardId)
2022-04-22 18:24:33 +08:00
this.UpdateWin()
end
function this:AddListener()
end
function this:RemoveListener()
end
function this.upLvBtnOnClick()
2024-09-06 10:38:56 +08:00
NetManager.SendTransformationUpGradeRequest(type, curCardId, nil, this.UpdateWin)
2022-04-22 18:24:33 +08:00
end
function this.upStarBtnOnClick()
2024-09-06 10:38:56 +08:00
NetManager.SendTransformationUpGradeRequest(type, curCardId, curSelectMat, this.UpdateWin)
2022-04-22 18:24:33 +08:00
end
2024-09-06 10:38:56 +08:00
2022-11-10 13:45:03 +08:00
local cardConfig
2022-04-22 18:24:33 +08:00
function this.UpdateWin()
2024-09-06 10:38:56 +08:00
curSelectMat = {}
cardData = IncarnationManager.itemDataList[curCardId]
curStar = cardData.star
curLevel = cardData.level
2024-10-30 15:44:26 +08:00
this.titleText.text = GetLanguageStrById(cardData.name)
2024-09-06 10:38:56 +08:00
local propData = IncarnationManager.GetChangeCardProperty(curCardId)
if type == 1 then
2022-04-24 20:27:05 +08:00
--设置等级信息
2022-04-24 19:46:59 +08:00
Util.GetGameObject(this.curLvText.gameObject, "starImg"):SetActive(false)
Util.GetGameObject(this.nextLvText.gameObject, "starImg"):SetActive(false)
2024-09-06 10:38:56 +08:00
this.curLvText.text = curLevel .. Language[10065]
this.nextLvText.text = (curLevel + 1) .. Language[10065]
2022-04-24 20:27:05 +08:00
2022-04-22 18:24:33 +08:00
this.upLvBtn.gameObject:SetActive(true)
this.upStarBtn.gameObject:SetActive(false)
2022-04-24 19:46:59 +08:00
this.skillLayout.gameObject:SetActive(false)
2022-11-02 11:48:41 +08:00
this.costImg.gameObject:SetActive(false)
this.costTxt.gameObject:SetActive(false)
2024-09-06 10:38:56 +08:00
local cardLvConfig = ConfigManager.GetConfigDataByDoubleKey(ConfigName.ChangingCardLevel, "Level", curLevel,
"PoolId", this.cardConfig.LevelUpPool)
this.curDrop.text = cardLvConfig.ChangingForceExp[2]
this.SetPropInfo(this.curProp, propData)
2022-04-22 18:24:33 +08:00
if this.CheckLevelLimit() then
2022-04-26 18:28:37 +08:00
this.nextLvText.gameObject:SetActive(false)
2022-04-22 18:24:33 +08:00
this.nextProp.gameObject:SetActive(false)
this.costGrid.gameObject:SetActive(false)
2022-04-25 14:42:17 +08:00
this.nextDrop.gameObject:SetActive(false)
--屏蔽化身之力加成属性显示
2022-04-28 11:58:48 +08:00
this.forceLayout.gameObject:SetActive(false)
2024-09-06 10:38:56 +08:00
this.upLvText.text = Language[10209]
2022-04-22 18:24:33 +08:00
else
this.nextProp.gameObject:SetActive(true)
this.costGrid.gameObject:SetActive(true)
2022-04-25 14:42:17 +08:00
this.nextDrop.gameObject:SetActive(true)
this.forceLayout.gameObject:SetActive(false)
2024-09-06 10:38:56 +08:00
local nextPropData = IncarnationManager.GetChangeCardProperty(curCardId, true, false)
this.SetPropInfo(this.nextProp, nextPropData)
2022-04-26 18:28:37 +08:00
this.SetCostItem(cardLvConfig.Exp)
2024-09-06 10:38:56 +08:00
local nextCardLvConfig = ConfigManager.GetConfigDataByDoubleKey(ConfigName.ChangingCardLevel, "Level",
curLevel + 1, "PoolId", this.cardConfig.LevelUpPool)
this.nextDrop.text = "+" .. nextCardLvConfig.ChangingForceExp[2]
this.upLvText.text = Language[11497]
2022-04-22 18:24:33 +08:00
end
else
2022-04-24 20:27:05 +08:00
--设置星级信息
Util.GetGameObject(this.curLvText.gameObject, "starImg"):SetActive(true)
Util.GetGameObject(this.nextLvText.gameObject, "starImg"):SetActive(true)
2024-09-06 10:38:56 +08:00
this.curLvText.text = curStar
LogError("curStar===" .. curStar)
2022-11-02 11:48:41 +08:00
--this.curDrop.text=curStar>0 and curStarConfig.StarUpExp[2] or 0
2024-09-06 10:38:56 +08:00
if curStar == 0 then
this.curDrop.text = 0
2022-11-10 13:45:03 +08:00
else
2024-09-06 10:38:56 +08:00
local curStarConfig = ConfigManager.GetConfigDataByDoubleKey(ConfigName.ChangingCardStar, "PoolId",
this.cardConfig.Star, "Level", curStar - 1)
this.curDrop.text = curStarConfig.StarUpExp[2]
2022-11-10 13:45:03 +08:00
end
2022-04-22 18:24:33 +08:00
this.upLvBtn.gameObject:SetActive(false)
this.upStarBtn.gameObject:SetActive(true)
2022-04-24 19:46:59 +08:00
this.skillLayout.gameObject:SetActive(true)
2022-04-24 16:50:24 +08:00
this.curSkillDes.gameObject:SetActive(true)
2024-09-06 10:38:56 +08:00
this.curSkillDes.text = IncarnationManager.GetSkillDesStr(curCardId, curStar)
this.SetPropInfo(this.curProp, propData)
2022-04-22 18:24:33 +08:00
if this.CheckStarLimit() then
2022-04-25 11:52:09 +08:00
this.nextLvText.gameObject:SetActive(false)
2022-04-22 18:24:33 +08:00
this.nextProp.gameObject:SetActive(false)
this.costGrid.gameObject:SetActive(false)
2022-04-25 11:52:09 +08:00
this.nextSkillDes.transform.parent.gameObject:SetActive(false)
2022-04-25 14:42:17 +08:00
this.nextDrop.gameObject:SetActive(false)
2022-04-28 11:58:48 +08:00
this.forceLayout.gameObject:SetActive(false)
2022-11-02 11:48:41 +08:00
this.costImg.gameObject:SetActive(false)
this.costTxt.gameObject:SetActive(false)
2024-09-06 10:38:56 +08:00
this.upStarText.text = Language[10209]
2022-04-22 18:24:33 +08:00
else
this.nextSkillDes.transform.parent.gameObject:SetActive(true)
2022-04-24 16:50:24 +08:00
this.nextSkillDes.gameObject:SetActive(true)
2022-11-02 11:48:41 +08:00
this.nextLvText.gameObject:SetActive(true)
2024-09-06 10:38:56 +08:00
this.nextSkillDes.text = IncarnationManager.GetSkillDesStr(curCardId, curStar + 1)
2022-04-22 18:24:33 +08:00
this.nextProp.gameObject:SetActive(true)
this.costGrid.gameObject:SetActive(true)
2022-04-25 14:42:17 +08:00
this.nextDrop.gameObject:SetActive(true)
--屏蔽化身之力加成属性显示
this.forceLayout.gameObject:SetActive(false)
2024-09-06 10:38:56 +08:00
local nextPropData = IncarnationManager.GetChangeCardProperty(curCardId, false, true)
this.nextLvText.text = curStar + 1
this.SetPropInfo(this.nextProp, nextPropData)
starConfig = ConfigManager.GetConfigDataByDoubleKey(ConfigName.ChangingCardStar, "PoolId",
this.cardConfig.Star, "Level", curStar)
2022-11-02 11:48:41 +08:00
this.SetCostItem(starConfig.PropList[1])
2024-09-06 10:38:56 +08:00
if curStar == this.cardConfig.StarMax then
this.nextDrop.text = "+" .. 0
2022-11-10 13:45:03 +08:00
else
2024-09-06 10:38:56 +08:00
this.nextDrop.text = "+" .. starConfig.StarUpExp[2]
2022-11-10 13:45:03 +08:00
end
2024-09-06 10:38:56 +08:00
this.upStarText.text = Language[11626]
2022-11-02 11:48:41 +08:00
if starConfig.PropList[2] then
this.costImg.gameObject:SetActive(false)
this.costTxt.gameObject:SetActive(false)
2024-09-06 10:38:56 +08:00
local costItemConfig = ConfigManager.GetConfigData(ConfigName.ItemConfig, starConfig.PropList[2][1])
local haveItemNum = BagManager.GetItemCountById(costItemConfig.Id)
if haveItemNum < starConfig.PropList[2][2] then
costEnough = false
this.costTxt.text = string.format("<color=#FF0000>%s</color>",
haveItemNum .. "/" .. starConfig.PropList[2][2])
2022-11-02 11:48:41 +08:00
else
2024-09-06 10:38:56 +08:00
costEnough = true
this.costTxt.text = string.format("<color=#FFFFFF>%s</color>",
haveItemNum .. "/" .. starConfig.PropList[2][2])
2022-11-02 11:48:41 +08:00
end
2024-09-06 10:38:56 +08:00
this.costImg.sprite = this.spLoader:LoadSprite(GetResourcePath(costItemConfig.ResourceID))
2022-11-02 11:48:41 +08:00
end
2022-04-22 18:24:33 +08:00
end
end
end
2024-09-06 10:38:56 +08:00
function this.SetPropInfo(propObj, propData)
local propGrid = Util.GetGameObject(propObj, "propGrid")
local index = 0
for k, v in pairs(propData) do
local propText = propGrid.transform:GetChild(index):GetComponent("Text")
2024-10-30 15:44:26 +08:00
propText.text = GetLanguageStrById(PropertyConfig[k].Info) ..
":" .. GetPropertyFormatStrOne(PropertyConfig[k].Style, v)
2024-09-06 10:38:56 +08:00
index = index + 1
2022-04-22 18:24:33 +08:00
end
end
function this.SetCostItem(costData)
2024-09-06 10:38:56 +08:00
if type == 1 then
local costItemConfig = ConfigManager.GetConfigData(ConfigName.ItemConfig, costData[1])
this.icon.sprite = this.spLoader:LoadSprite(GetResourcePath(costItemConfig.ResourceID))
this.frame.sprite = this.spLoader:LoadSprite(GetQuantityImageByquality(costItemConfig.Quantity))
2022-04-22 18:24:33 +08:00
this.icon.gameObject:SetActive(true)
this.iconDefault.gameObject:SetActive(false)
this.addBtn.gameObject:SetActive(false)
2024-09-06 10:38:56 +08:00
local haveItemNum = BagManager.GetItemCountById(costItemConfig.Id)
if haveItemNum < costData[2] then
this.num.text = string.format("<color=#FF0000>%s</color>", haveItemNum .. "/" .. costData[2])
2022-04-24 20:27:05 +08:00
else
2024-09-06 10:38:56 +08:00
this.num.text = string.format("<color=#9c794f>%s</color>", haveItemNum .. "/" .. costData[2])
2022-04-24 20:27:05 +08:00
end
2024-09-06 10:38:56 +08:00
2022-04-24 20:27:05 +08:00
this.bianImg.gameObject:SetActive(false)
2022-04-22 18:24:33 +08:00
else
2024-09-06 10:38:56 +08:00
this.frame.sprite = this.spLoader:LoadSprite(GetQuantityImageByquality(costData[1]))
2022-04-22 18:24:33 +08:00
this.icon.gameObject:SetActive(false)
this.iconDefault.gameObject:SetActive(true)
this.addBtn.gameObject:SetActive(true)
2024-09-06 10:38:56 +08:00
this.num.text = string.format("<color=#FF0000>%s</color>", "0/" .. costData[2])
2022-04-24 20:27:05 +08:00
this.bianImg.gameObject:SetActive(true)
2022-04-22 18:24:33 +08:00
end
2022-04-26 15:36:43 +08:00
Util.AddOnceClick(Util.GetGameObject(this.costItem, "frame"), function()
2022-04-22 18:24:33 +08:00
this.itemView:OnBtnCkickEvent(costData[1])
end)
end
2024-09-06 10:38:56 +08:00
function this:UpdateUpStarCost(_num, _curSelectList)
local needNum = starConfig.PropList[1][2] --this.cardConfig.StarUpCost[curStar+1][2]
if _num < needNum then
this.num.text = string.format("<color=#FF0000>%s</color>", _num .. "/" .. needNum)
2022-04-24 20:27:05 +08:00
else
2024-09-06 10:38:56 +08:00
this.num.text = string.format("<color=#FFFFFF>%s</color>", _num .. "/" .. needNum)
2022-04-24 20:27:05 +08:00
end
2024-09-06 10:38:56 +08:00
curSelectMat = _curSelectList
2022-04-22 18:24:33 +08:00
end
--检测当前化身卡星级是否已升满
function this.CheckStarLimit()
2024-09-06 10:38:56 +08:00
cardConfig = ConfigManager.GetConfigData(ConfigName.ChangingCard, curCardId)
if curStar >= cardConfig.StarMax then
2022-04-22 18:24:33 +08:00
return true
end
return false
end
--检测当前化身卡等级是否已升满
function this.CheckLevelLimit()
2024-09-06 10:38:56 +08:00
local cardConfig = ConfigManager.GetConfigData(ConfigName.ChangingCard, curCardId)
if curLevel >= cardConfig.LevelMax then
2022-04-22 18:24:33 +08:00
return true
end
return false
end
function this:OnClose()
2022-04-24 16:50:24 +08:00
Game.GlobalEvent:DispatchEvent(GameEvent.CommonEvent.RefreshIncarnationPanel)
2022-04-27 18:08:55 +08:00
CheckRedPointStatus(RedPointType.incarnation_people)
2023-04-21 13:24:26 +08:00
CheckRedPointStatus(RedPointType.incarnation_Kong)
2022-04-27 18:08:55 +08:00
CheckRedPointStatus(RedPointType.incarnation_buddish)
CheckRedPointStatus(RedPointType.incarnation_demon)
CheckRedPointStatus(RedPointType.incarnation_taoist)
CheckRedPointStatus(RedPointType.incarnation_force)
2022-04-22 18:24:33 +08:00
end
function this:OnDestroy()
2022-04-26 14:47:04 +08:00
self.spLoader:Destroy()
2024-09-06 10:38:56 +08:00
curSelectMat = {}
2022-04-22 18:24:33 +08:00
end
2024-09-06 10:38:56 +08:00
return this