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

277 lines
12 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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")
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")
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")
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")
--消耗相关
this.costLayout=Util.GetGameObject(self.gameObject, "root/verLayout/costLayout")
this.costGrid = Util.GetGameObject(this.costLayout, "costGrid")
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")
this.upLvBtn = Util.GetGameObject(this.costLayout, "upLvBtn")
this.upLvText=Util.GetGameObject(this.costLayout, "upLvBtn/Text"):GetComponent("Text")
this.upStarBtn = Util.GetGameObject(this.costLayout, "upStarBtn")
this.upStarText=Util.GetGameObject(this.costLayout, "upStarBtn/Text"):GetComponent("Text")
this.itemView= SubUIManager.Open(SubUIConfig.ItemView, this.prefab.transform)
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
local selectNum=0
for i = 1, #curSelectMat do
selectNum=selectNum+curSelectMat[i].num
end
if selectNum<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
this.titleText.text=cardData.name
local propData=IncarnationManager.GetChangeCardProperty(curCardId)
if type==1 then
--设置等级信息
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)..""
this.upLvBtn.gameObject:SetActive(true)
this.upStarBtn.gameObject:SetActive(false)
this.skillLayout.gameObject:SetActive(false)
local cardLvConfig=ConfigManager.GetConfigDataByDoubleKey(ConfigName.ChangingCardLevel,"Level",curLevel,"PoolId",this.cardConfig.LevelUpPool)
this.curDrop.text=cardLvConfig.ChangingForceExp[2]
this.SetPropInfo(this.curProp,propData)
if this.CheckLevelLimit() then
this.nextLvText.gameObject:SetActive(false)
this.nextProp.gameObject:SetActive(false)
this.costGrid.gameObject:SetActive(false)
this.nextDrop.gameObject:SetActive(false)
this.forceLayout.gameObject:SetActive(false)
this.upLvText.text="已达上限"
else
this.nextProp.gameObject:SetActive(true)
this.costGrid.gameObject:SetActive(true)
this.nextDrop.gameObject:SetActive(true)
this.forceLayout.gameObject:SetActive(true)
local nextPropData=IncarnationManager.GetChangeCardProperty(curCardId,true,false)
this.SetPropInfo(this.nextProp,nextPropData)
this.SetCostItem(cardLvConfig.Exp)
local nextCardLvConfig=ConfigManager.GetConfigDataByDoubleKey(ConfigName.ChangingCardLevel,"Level",curLevel+1,"PoolId",this.cardConfig.LevelUpPool)
this.nextDrop.text="+"..nextCardLvConfig.ChangingForceExp[2]
this.upLvText.text="升 级"
end
else
--设置星级信息
Util.GetGameObject(this.curLvText.gameObject, "starImg"):SetActive(true)
Util.GetGameObject(this.nextLvText.gameObject, "starImg"):SetActive(true)
this.curLvText.text=curStar
this.curDrop.text=curStar>0 and this.cardConfig.StarUpExp[curStar][2] or 0
this.upLvBtn.gameObject:SetActive(false)
this.upStarBtn.gameObject:SetActive(true)
this.skillLayout.gameObject:SetActive(true)
this.curSkillDes.gameObject:SetActive(true)
this.curSkillDes.text=IncarnationManager.GetSkillDesStr(curCardId,curStar)
this.SetPropInfo(this.curProp,propData)
if this.CheckStarLimit() then
this.nextLvText.gameObject:SetActive(false)
this.nextProp.gameObject:SetActive(false)
this.costGrid.gameObject:SetActive(false)
this.nextSkillDes.transform.parent.gameObject:SetActive(false)
this.nextDrop.gameObject:SetActive(false)
this.forceLayout.gameObject:SetActive(false)
this.upStarText.text="已达上限"
else
this.nextSkillDes.gameObject:SetActive(true)
this.nextSkillDes.text=IncarnationManager.GetSkillDesStr(curCardId,curStar+1)
this.nextProp.gameObject:SetActive(true)
this.costGrid.gameObject:SetActive(true)
this.nextDrop.gameObject:SetActive(true)
this.forceLayout.gameObject:SetActive(true)
local nextPropData=IncarnationManager.GetChangeCardProperty(curCardId,false,true)
this.nextLvText.text=curStar+1
this.SetPropInfo(this.nextProp,nextPropData)
this.SetCostItem(this.cardConfig.StarUpCost[curStar+1])
this.nextDrop.text="+"..this.cardConfig.StarUpExp[curStar+1][2]
this.upStarText.text="升 星"
end
end
end
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")
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)
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)
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)
this.num.text= string.format("<color=#FF0000>%s</color>","0/"..costData[2])
this.bianImg.gameObject:SetActive(true)
end
Util.AddOnceClick(Util.GetGameObject(this.costItem, "frame"), function()
this.itemView:OnBtnCkickEvent(costData[1])
end)
end
function this:UpdateUpStarCost(_num,_curSelectList)
local needNum=this.cardConfig.StarUpCost[curStar+1][2]
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
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:OnClose()
Game.GlobalEvent:DispatchEvent(GameEvent.CommonEvent.RefreshIncarnationPanel)
CheckRedPointStatus(RedPointType.incarnation_people)
CheckRedPointStatus(RedPointType.incarnation_buddish)
CheckRedPointStatus(RedPointType.incarnation_demon)
CheckRedPointStatus(RedPointType.incarnation_taoist)
CheckRedPointStatus(RedPointType.incarnation_force)
end
function this:OnDestroy()
self.spLoader:Destroy()
curSelectMat={}
end
return this