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

318 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)
local curSelectMat={}
2022-11-02 11:48:41 +08:00
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
2022-04-22 18:24:33 +08:00
this.prefab=Util.GetGameObject(self.gameObject, "root/prefab")
2022-04-24 20:27:05 +08:00
this.lvLayout=Util.GetGameObject(self.gameObject, "root/verLayout/lvLayout")
2022-04-25 11:52:09 +08:00
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
2022-04-24 20:27:05 +08:00
this.proyLayout=Util.GetGameObject(self.gameObject, "root/verLayout/proyLayout")
2022-04-25 11:52:09 +08:00
this.curProp=Util.GetGameObject(this.proyLayout, "grid/curProp")
this.nextProp=Util.GetGameObject(this.proyLayout, "grid/nextProp")
2022-04-24 19:46:59 +08:00
2022-04-25 14:42:17 +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")
2022-04-24 20:27:05 +08:00
this.skillLayout=Util.GetGameObject(self.gameObject, "root/verLayout/skillLayout")
2022-04-25 11:52:09 +08:00
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
--消耗相关
2022-04-24 20:27:05 +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)
2022-04-24 19:46:59 +08:00
this.costItem=Util.GetGameObject(this.costLayout, "costGrid/costItem")
2022-04-22 18:24:33 +08:00
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")
2022-04-24 20:27:05 +08:00
this.bianImg=Util.GetGameObject(this.costItem, "bianImg")
2022-04-24 19:46:59 +08:00
2024-01-12 19:17:15 +08:00
this.upLvBtn = Util.GetGameObject(self.gameObject, "root/bg/upLvBtn")
this.upLvText=Util.GetGameObject(self.gameObject, "root/bg/upLvBtn/Text"):GetComponent("Text")
this.upStarBtn = Util.GetGameObject(self.gameObject, "root/bg/upStarBtn")
this.upStarText=Util.GetGameObject(self.gameObject, "root/bg/upStarBtn/Text"):GetComponent("Text")
2022-04-26 15:36:43 +08:00
this.itemView= SubUIManager.Open(SubUIConfig.ItemView, this.prefab.transform)
2022-11-02 11:48:41 +08:00
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
PopupTipPanel.ShowTip("等级已满")
return
end
local cardLvConfig=ConfigManager.GetConfigDataByDoubleKey(ConfigName.ChangingCardLevel,"Level",curLevel,"PoolId",this.cardConfig.LevelUpPool)
if BagManager.GetItemCountById(cardLvConfig.Exp[1])<cardLvConfig.Exp[2] then
PopupTipPanel.ShowTip("材料不足")
return
end
this.upLvBtnOnClick()
end)
Util.AddClick(this.upStarBtn, function()
if this.CheckStarLimit() then
PopupTipPanel.ShowTip("星级已满")
return
end
2022-04-26 13:44:19 +08:00
local selectNum=0
for i = 1, #curSelectMat do
selectNum=selectNum+curSelectMat[i].num
end
2022-11-02 11:48:41 +08:00
if selectNum<starConfig.PropList[1][2] or not costEnough then
2022-04-22 18:24:33 +08:00
PopupTipPanel.ShowTip("材料不足")
return
end
this.upStarBtnOnClick()
end)
Util.AddClick(this.addBtn, function()
2022-11-02 11:48:41 +08:00
UIManager.OpenPanel(UIName.IncarnationUpStarListPanel,this,curSelectMat,starConfig.PropList[1],this.cardConfig.CardId)
2022-04-22 18:24:33 +08:00
end)
end
-- type 1:升级 2:升星 cardId化身卡id
function this:OnOpen(_type,_cardId)
type=_type
curCardId=_cardId
this.cardConfig=ConfigManager.GetConfigData(ConfigName.ChangingCard,_cardId)
this.UpdateWin()
end
function this:AddListener()
end
function this:RemoveListener()
end
function this.upLvBtnOnClick()
NetManager.SendTransformationUpGradeRequest(type,curCardId,nil,this.UpdateWin)
end
function this.upStarBtnOnClick()
NetManager.SendTransformationUpGradeRequest(type,curCardId,curSelectMat,this.UpdateWin)
end
2022-11-10 13:45:03 +08:00
local cardConfig
2022-04-22 18:24:33 +08:00
function this.UpdateWin()
curSelectMat={}
cardData=IncarnationManager.itemDataList[curCardId]
curStar=cardData.star
curLevel=cardData.level
this.titleText.text=cardData.name
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)
this.curLvText.text=curLevel..""
this.nextLvText.text=(curLevel+1)..""
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)
2022-04-25 14:42:17 +08:00
local cardLvConfig=ConfigManager.GetConfigDataByDoubleKey(ConfigName.ChangingCardLevel,"Level",curLevel,"PoolId",this.cardConfig.LevelUpPool)
this.curDrop.text=cardLvConfig.ChangingForceExp[2]
2022-04-25 11:52:09 +08:00
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)
this.upLvText.text="已达上限"
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)
2022-04-22 18:24:33 +08:00
local nextPropData=IncarnationManager.GetChangeCardProperty(curCardId,true,false)
2022-04-25 11:52:09 +08:00
this.SetPropInfo(this.nextProp,nextPropData)
2022-04-26 18:28:37 +08:00
this.SetCostItem(cardLvConfig.Exp)
2022-04-25 14:42:17 +08:00
local nextCardLvConfig=ConfigManager.GetConfigDataByDoubleKey(ConfigName.ChangingCardLevel,"Level",curLevel+1,"PoolId",this.cardConfig.LevelUpPool)
this.nextDrop.text="+"..nextCardLvConfig.ChangingForceExp[2]
2022-04-28 11:58:48 +08:00
this.upLvText.text="升 级"
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)
this.curLvText.text=curStar
2022-11-02 11:48:41 +08:00
LogError("curStar==="..curStar)
2022-11-10 13:45:03 +08:00
2022-11-02 11:48:41 +08:00
--this.curDrop.text=curStar>0 and curStarConfig.StarUpExp[2] or 0
2022-11-10 13:45:03 +08:00
if curStar==0 then
this.curDrop.text=0
else
local curStarConfig= ConfigManager.GetConfigDataByDoubleKey(ConfigName.ChangingCardStar,"PoolId",this.cardConfig.Star,"Level",curStar-1)
this.curDrop.text=curStarConfig.StarUpExp[2]
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)
this.curSkillDes.text=IncarnationManager.GetSkillDesStr(curCardId,curStar)
2022-04-25 11:52:09 +08:00
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)
2022-04-28 11:58:48 +08:00
this.upStarText.text="已达上限"
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)
2022-04-24 16:50:24 +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)
2022-04-22 18:24:33 +08:00
local nextPropData=IncarnationManager.GetChangeCardProperty(curCardId,false,true)
2022-04-25 14:42:17 +08:00
this.nextLvText.text=curStar+1
2022-04-25 11:52:09 +08:00
this.SetPropInfo(this.nextProp,nextPropData)
2022-11-02 11:48:41 +08:00
starConfig=ConfigManager.GetConfigDataByDoubleKey(ConfigName.ChangingCardStar,"PoolId",this.cardConfig.Star,"Level",curStar)
this.SetCostItem(starConfig.PropList[1])
2022-11-10 13:45:03 +08:00
if curStar==this.cardConfig.StarMax then
this.nextDrop.text="+"..0
else
this.nextDrop.text="+"..starConfig.StarUpExp[2]
end
2022-04-28 11:58:48 +08:00
this.upStarText.text="升 星"
2022-11-02 11:48:41 +08:00
if starConfig.PropList[2] then
this.costImg.gameObject:SetActive(false)
this.costTxt.gameObject:SetActive(false)
2022-11-02 11:48:41 +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])
else
costEnough=true
this.costTxt.text=string.format("<color=#FFFFFF>%s</color>",haveItemNum.."/"..starConfig.PropList[2][2])
end
this.costImg.sprite=this.spLoader:LoadSprite(GetResourcePath(costItemConfig.ResourceID))
end
2022-04-22 18:24:33 +08:00
end
end
end
2022-04-25 11:52:09 +08:00
function this.SetPropInfo(propObj,propData)
2022-04-24 19:46:59 +08:00
2022-04-22 18:24:33 +08:00
local propGrid=Util.GetGameObject(propObj, "propGrid")
local index=0
for k,v in pairs(propData) do
local propText=propGrid.transform:GetChild(index):GetComponent("Text")
propText.text = PropertyConfig[k].Info..":"..GetPropertyFormatStrOne(PropertyConfig[k].Style,v)
index=index+1
end
end
function this.SetCostItem(costData)
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))
this.icon.gameObject:SetActive(true)
this.iconDefault.gameObject:SetActive(false)
this.addBtn.gameObject:SetActive(false)
2022-04-24 20:27:05 +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])
else
this.num.text=string.format("<color=#FFFFFF>%s</color>",haveItemNum.."/"..costData[2])
end
this.bianImg.gameObject:SetActive(false)
2022-04-22 18:24:33 +08:00
else
this.frame.sprite=this.spLoader:LoadSprite(GetQuantityImageByquality(costData[1]))
this.icon.gameObject:SetActive(false)
this.iconDefault.gameObject:SetActive(true)
this.addBtn.gameObject:SetActive(true)
2022-04-24 20:27:05 +08:00
this.num.text= string.format("<color=#FF0000>%s</color>","0/"..costData[2])
2024-01-12 19:17:15 +08:00
this.bianImg.gameObject:SetActive(false)
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
function this:UpdateUpStarCost(_num,_curSelectList)
2022-11-02 11:48:41 +08:00
local needNum=starConfig.PropList[1][2] --this.cardConfig.StarUpCost[curStar+1][2]
2022-04-24 20:27:05 +08:00
if _num<needNum then
this.num.text= string.format("<color=#FF0000>%s</color>",_num.."/"..needNum)
else
this.num.text= string.format("<color=#FFFFFF>%s</color>",_num.."/"..needNum)
end
2022-04-22 18:24:33 +08:00
curSelectMat=_curSelectList
end
--检测当前化身卡星级是否已升满
function this.CheckStarLimit()
2022-11-10 13:45:03 +08:00
cardConfig=ConfigManager.GetConfigData(ConfigName.ChangingCard,curCardId)
2022-04-22 18:24:33 +08:00
if curStar>=cardConfig.StarMax then
return true
end
return false
end
--检测当前化身卡等级是否已升满
function this.CheckLevelLimit()
local cardConfig=ConfigManager.GetConfigData(ConfigName.ChangingCard,curCardId)
if curLevel>=cardConfig.LevelMax then
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()
curSelectMat={}
2022-04-22 18:24:33 +08:00
end
return this