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])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%s",haveItemNum.."/"..starConfig.PropList[2][2]) else costEnough=true this.costTxt.text=string.format("%s",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%s",haveItemNum.."/"..costData[2]) else this.num.text=string.format("%s",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("%s","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%s",_num.."/"..needNum) else this.num.text= string.format("%s",_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