318 lines
14 KiB
Lua
318 lines
14 KiB
Lua
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={}
|
||
local starConfig=nil
|
||
local costEnough=true
|
||
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.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)
|
||
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(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")
|
||
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<starConfig.PropList[1][2] or not costEnough then
|
||
PopupTipPanel.ShowTip("材料不足")
|
||
return
|
||
end
|
||
this.upStarBtnOnClick()
|
||
end)
|
||
Util.AddClick(this.addBtn, function()
|
||
UIManager.OpenPanel(UIName.IncarnationUpStarListPanel,this,curSelectMat,starConfig.PropList[1],this.cardConfig.CardId)
|
||
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
|
||
local cardConfig
|
||
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)
|
||
this.costImg.gameObject:SetActive(false)
|
||
this.costTxt.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(false)
|
||
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
|
||
LogError("curStar==="..curStar)
|
||
|
||
--this.curDrop.text=curStar>0 and curStarConfig.StarUpExp[2] or 0
|
||
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
|
||
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.costImg.gameObject:SetActive(false)
|
||
this.costTxt.gameObject:SetActive(false)
|
||
this.upStarText.text="已达上限"
|
||
else
|
||
this.nextSkillDes.transform.parent.gameObject:SetActive(true)
|
||
this.nextSkillDes.gameObject:SetActive(true)
|
||
this.nextLvText.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(false)
|
||
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)
|
||
this.SetCostItem(starConfig.PropList[1])
|
||
if curStar==this.cardConfig.StarMax then
|
||
this.nextDrop.text="+"..0
|
||
else
|
||
this.nextDrop.text="+"..starConfig.StarUpExp[2]
|
||
end
|
||
|
||
this.upStarText.text="升 星"
|
||
if starConfig.PropList[2] then
|
||
this.costImg.gameObject:SetActive(false)
|
||
this.costTxt.gameObject:SetActive(false)
|
||
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
|
||
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(false)
|
||
end
|
||
Util.AddOnceClick(Util.GetGameObject(this.costItem, "frame"), function()
|
||
this.itemView:OnBtnCkickEvent(costData[1])
|
||
end)
|
||
end
|
||
|
||
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)
|
||
else
|
||
this.num.text= string.format("<color=#FFFFFF>%s</color>",_num.."/"..needNum)
|
||
end
|
||
curSelectMat=_curSelectList
|
||
end
|
||
|
||
--检测当前化身卡星级是否已升满
|
||
function this.CheckStarLimit()
|
||
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_Kong)
|
||
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 |