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

231 lines
8.9 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={}
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")
this.itemView= SubUIManager.Open(SubUIConfig.ItemView, this.prefab.transform)
2022-04-24 19:46:59 +08:00
this.lvLayout=Util.GetGameObject(self.gameObject, "root/lvLayout")
this.curLvText=Util.GetGameObject(this.lvLayout, "curLv"):GetComponent("Text")
this.nextLvText=Util.GetGameObject(this.lvLayout, "nextLv"):GetComponent("Text")
this.proyLayout=Util.GetGameObject(self.gameObject, "root/proyLayout")
this.curProp=Util.GetGameObject(this.proyLayout, "curProp")
this.nextProp=Util.GetGameObject(this.proyLayout, "nextProp")
this.skillLayout=Util.GetGameObject(self.gameObject, "root/skillLayout")
this.curSkillDes=Util.GetGameObject(this.skillLayout, "curSkillDes"):GetComponent("Text")
this.nextSkillDes=Util.GetGameObject(this.skillLayout, "nextSkillDes"):GetComponent("Text")
2022-04-24 16:50:24 +08:00
2022-04-22 18:24:33 +08:00
--消耗相关
2022-04-24 19:46:59 +08:00
this.costLayout=Util.GetGameObject(self.gameObject, "root/costLayout")
this.costGrid = Util.GetGameObject(this.costLayout, "costGrid")
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 19:46:59 +08:00
this.upLvBtn = Util.GetGameObject(this.costLayout, "upLvBtn")
this.upStarBtn = Util.GetGameObject(this.costLayout, "upStarBtn")
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
if #curSelectMat<this.cardConfig.StarUpCost[curStar+1][2] then
PopupTipPanel.ShowTip("材料不足")
return
end
this.upStarBtnOnClick()
end)
Util.AddClick(this.addBtn, function()
UIManager.OpenPanel(UIName.IncarnationUpStarListPanel,this,curSelectMat,this.cardConfig.StarUpCost[curStar+1])
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
function this.UpdateWin()
curSelectMat={}
cardData=IncarnationManager.itemDataList[curCardId]
curStar=cardData.star
curLevel=cardData.level
LogBlue("等级:"..curLevel.." 星级:"..curStar)
this.titleText.text=cardData.name
local propData=IncarnationManager.GetChangeCardProperty(curCardId)
if type==1 then
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)..""
else
Util.GetGameObject(this.curLvText.gameObject, "starImg"):SetActive(true)
Util.GetGameObject(this.nextLvText.gameObject, "starImg"):SetActive(true)
this.curLvText.text=curStar
this.nextLvText.text=curStar+1
end
if type==1 then
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-04-22 18:24:33 +08:00
this.SetPropInfo(this.curProp,curLevel,propData)
if this.CheckLevelLimit() then
this.nextProp.gameObject:SetActive(false)
this.costGrid.gameObject:SetActive(false)
else
this.nextProp.gameObject:SetActive(true)
this.costGrid.gameObject:SetActive(true)
local nextPropData=IncarnationManager.GetChangeCardProperty(curCardId,true,false)
this.SetPropInfo(this.nextProp,curLevel+1,nextPropData)
local cardLvConfig=ConfigManager.GetConfigDataByDoubleKey(ConfigName.ChangingCardLevel,"Level",curLevel,"PoolId",this.cardConfig.LevelUpPool)
this.SetCostItem(cardLvConfig.Exp)
end
else
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-22 18:24:33 +08:00
this.SetPropInfo(this.curProp,curStar,propData)
if this.CheckStarLimit() then
this.nextProp.gameObject:SetActive(false)
this.costGrid.gameObject:SetActive(false)
2022-04-24 16:50:24 +08:00
this.nextSkillDes.gameObject:SetActive(false)
2022-04-22 18:24:33 +08:00
else
2022-04-24 16:50:24 +08:00
this.nextSkillDes.gameObject:SetActive(true)
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)
local nextPropData=IncarnationManager.GetChangeCardProperty(curCardId,false,true)
this.SetPropInfo(this.nextProp,curStar+1,nextPropData)
this.SetCostItem(this.cardConfig.StarUpCost[curStar+1])
end
end
end
function this.SetPropInfo(propObj,lv,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)
this.num.text=BagManager.GetItemCountById(costItemConfig.Id).."/"..costData[2]
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)
Util.GetGameObject(this.costItem, "num"):GetComponent("Text").text= "0/"..costData[2]
end
Util.AddClick(Util.GetGameObject(this.costItem, "frame"), function()
this.itemView:OnBtnCkickEvent(costData[1])
end)
end
function this:UpdateUpStarCost(_num,_curSelectList)
Util.GetGameObject(this.costItem, "num"):GetComponent("Text").text= _num.."/"..this.cardConfig.StarUpCost[curStar+1][2]
curSelectMat=_curSelectList
end
--检测当前化身卡星级是否已升满
function this.CheckStarLimit()
local cardConfig=ConfigManager.GetConfigData(ConfigName.ChangingCard,curCardId)
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:OnSortingOrderChange()
end
function this:OnClose()
2022-04-24 16:50:24 +08:00
Game.GlobalEvent:DispatchEvent(GameEvent.CommonEvent.RefreshIncarnationPanel)
2022-04-22 18:24:33 +08:00
end
function this:OnDestroy()
end
return this