207 lines
7.6 KiB
Lua
207 lines
7.6 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={}
|
|||
|
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.costTitle = Util.GetGameObject(self.gameObject, "root/costTitle"):GetComponent("Text")
|
|||
|
this.upLvBtn = Util.GetGameObject(self.gameObject, "root/upLvBtn")
|
|||
|
this.upStarBtn = Util.GetGameObject(self.gameObject, "root/upStarBtn")
|
|||
|
this.costGrid = Util.GetGameObject(self.gameObject, "root/costGrid")
|
|||
|
this.costItem=Util.GetGameObject(self.gameObject, "root/costGrid/costItem")
|
|||
|
this.curProp=Util.GetGameObject(self.gameObject, "root/curProp")
|
|||
|
this.nextProp=Util.GetGameObject(self.gameObject, "root/nextProp")
|
|||
|
this.prefab=Util.GetGameObject(self.gameObject, "root/prefab")
|
|||
|
this.itemView= SubUIManager.Open(SubUIConfig.ItemView, this.prefab.transform)
|
|||
|
|
|||
|
--消耗相关
|
|||
|
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")
|
|||
|
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
|
|||
|
this.costTitle.text="升级消耗"
|
|||
|
this.upLvBtn.gameObject:SetActive(true)
|
|||
|
this.upStarBtn.gameObject:SetActive(false)
|
|||
|
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.costTitle.text="升星消耗"
|
|||
|
this.upLvBtn.gameObject:SetActive(false)
|
|||
|
this.upStarBtn.gameObject:SetActive(true)
|
|||
|
this.SetPropInfo(this.curProp,curStar,propData)
|
|||
|
if this.CheckStarLimit() 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,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)
|
|||
|
if type==1 then
|
|||
|
Util.GetGameObject(propObj, "level"):GetComponent("Text").text="等级"..lv
|
|||
|
else
|
|||
|
Util.GetGameObject(propObj, "level"):GetComponent("Text").text="星级"..lv
|
|||
|
end
|
|||
|
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()
|
|||
|
end
|
|||
|
|
|||
|
function this:OnDestroy()
|
|||
|
|
|||
|
end
|
|||
|
|
|||
|
return this
|