require("Base/BasePanel") GodWeaponUpPanel = Inherit(BasePanel) local this = GodWeaponUpPanel local tabType=1 --1升星 2升级 local godWeaponData --初始化组件(用于子类重写) function this:InitComponent() this.btnBack = Util.GetGameObject(self.gameObject, "btnBack") this.spLoader = SpriteLoader.New() this.icon= Util.GetGameObject(self.gameObject, "iconBg/icon"):GetComponent("Image") this.nameText=Util.GetGameObject(self.gameObject, "nameInfo/nameText"):GetComponent("Text") this.curPropGrid=Util.GetGameObject(self.gameObject, "infoLayout/propertyInfo/allProp/curProp") this.nextPropGrid=Util.GetGameObject(self.gameObject, "infoLayout/propertyInfo/allProp/nextProp") this.upStarTab=Util.GetGameObject(self.gameObject,"tabBg/tabBox/upStarTab") this.upLvTab=Util.GetGameObject(self.gameObject,"tabBg/tabBox/upLvTab") this.selectBtn=Util.GetGameObject(self.gameObject,"tabBg/tabBox/selectBtn") this.selectText=Util.GetGameObject(self.gameObject,"tabBg/tabBox/selectBtn/Text"):GetComponent("Text") this.curLv=Util.GetGameObject(self.gameObject,"infoLayout/costMatBg/curLv/Text"):GetComponent("Text") this.costGrid=Util.GetGameObject(self.gameObject,"infoLayout/costMatBg/costGrid") this.skillLayout=Util.GetGameObject(self.gameObject,"infoLayout/skillLayout") this.upStarBtn=Util.GetGameObject(self.gameObject,"infoLayout/btnLayout/upStarBtn") this.upLvBtn=Util.GetGameObject(self.gameObject,"infoLayout/btnLayout/upLvBtn") this.limitText=Util.GetGameObject(self.gameObject,"infoLayout/btnLayout/limitText"):GetComponent("Text") this.jiantou=Util.GetGameObject(self.gameObject,"infoLayout/propertyInfo/jiantou") this.starGrid=Util.GetGameObject(self.gameObject,"starGrid/starGrid") this.skillScroll=Util.GetGameObject(self.gameObject,"infoLayout/skillLayout/skillScroll/skillGrid") this.curSkillInfo=Util.GetGameObject(self.gameObject,"infoLayout/skillLayout/skillScroll/skillGrid/curSkillInfo") this.nextSkillInfo=Util.GetGameObject(self.gameObject,"infoLayout/skillLayout/skillScroll/skillGrid/nextSkillInfo") this.costItemViews={} end --绑定事件(用于子类重写) function this:BindEvent() Util.AddClick(this.btnBack, function() self:ClosePanel() end) Util.AddClick(this.upStarTab, function() tabType=1 this.SetSelectBtn() this.UpdateWinInfo() end) Util.AddClick(this.upLvTab, function() tabType=2 this.SetSelectBtn() this.UpdateWinInfo() end) Util.AddClick(this.upStarBtn, function() end) Util.AddClick(this.upLvBtn, function() end) end function this.SetSelectBtn() local _btnTab if tabType==1 then _btnTab=this.upStarTab this.selectText.text="升星" else _btnTab=this.upLvTab this.selectText.text="升级" end this.selectBtn.transform:SetParent(_btnTab.transform) this.selectBtn.transform.localPosition = Vector3.zero this.selectBtn.transform.localScale = Vector3.one end --界面打开时调用(用于子类重写) function this:OnOpen(_type,_data) tabType=_type godWeaponData=_data this.SetSelectBtn() this.icon.sprite = this.spLoader:LoadSprite(GetResourcePath(godWeaponData.config.Icon)) this.nameText.text=godWeaponData.config.Name this.UpdateWinInfo() end function this.UpdateWinInfo() this.curLv.text="等级:"..godWeaponData.lv local starSize = Vector2.New(80,80) PokemonManager.SetHeroStars(this.spLoader, this.starGrid, godWeaponData.star,1,starSize) local curPropDic local nextPropDic local costItems={} local isLimit=false LogBlue(godWeaponData.star.."||||"..godWeaponData.lv.."####"..godWeaponData.config.Quality) if tabType==1 then isLimit=godWeaponData.star>=5 this.skillLayout.gameObject:SetActive(true) this.upStarBtn.gameObject:SetActive(true) this.upLvBtn.gameObject:SetActive(false) this.curLv.transform.parent.gameObject:SetActive(false) curPropDic=GodWeaponManager.GetSinglePokemonAddProData(godWeaponData.Did,godWeaponData.star,godWeaponData.lv) if not isLimit then nextPropDic=GodWeaponManager.GetSinglePokemonAddProData(godWeaponData.Did,godWeaponData.star+1,godWeaponData.lv) local starConfig=ConfigManager.GetConfigDataByDoubleKey(ConfigName.ShenbingStar,"Star",godWeaponData.star,"Quality",godWeaponData.config.Quality) costItems[1]={} costItems[1][1]=godWeaponData.id costItems[1][2]=starConfig.ConsumeItemNum end this.limitText.text="星级已满" else isLimit=godWeaponData.lv>=200 this.skillLayout.gameObject:SetActive(false) this.upStarBtn.gameObject:SetActive(false) this.upLvBtn.gameObject:SetActive(true) this.curLv.transform.parent.gameObject:SetActive(true) curPropDic=GodWeaponManager.GetSinglePokemonAddProData(godWeaponData.Did,godWeaponData.star,godWeaponData.lv) if not isLimit then nextPropDic=GodWeaponManager.GetSinglePokemonAddProData(godWeaponData.Did,godWeaponData.star,godWeaponData.lv+1) costItems=ConfigManager.GetConfigDataByDoubleKey(ConfigName.ShenBingLevel,"Level",godWeaponData.lv,"Quality",godWeaponData.config.Quality).Consume end this.limitText.text="等级已满" end this.SetPropInfo(curPropDic,this.curPropGrid) ---判断等级星级是否达到上限 if isLimit then this.jiantou.gameObject:SetActive(false) this.upStarBtn.gameObject:SetActive(false) this.upLvBtn.gameObject:SetActive(false) this.limitText.gameObject:SetActive(true) this.nextPropGrid.gameObject:SetActive(false) this.costGrid.gameObject:SetActive(false) else this.costGrid.gameObject:SetActive(true) this.SetPropInfo(nextPropDic,this.nextPropGrid) this.SetCostItemInfo(costItems) end local curSkillInfos= GodWeaponManager.GetSingleGodWeaponSkillDes(godWeaponData.Did) local nextSkillInfos=GodWeaponManager.GetSingleGodWeaponSkillDes(godWeaponData.Did,godWeaponData.star+1) this.SetSkillInfo(this.curSkillInfo,"升星前技能",curSkillInfos) this.SetSkillInfo(this.nextSkillInfo,"升星后技能",nextSkillInfos) LayoutRebuilder.ForceRebuildLayoutImmediate(this.skillScroll.transform) end ---设置属性信息 function this.SetPropInfo(_propDic,_propGrid) local propInfoList={} local index=1 for key, value in pairs(_propDic) do propInfoList[index]={} local propConfig=ConfigManager.GetConfigData(ConfigName.PropertyConfig,key) propInfoList[index].name=propConfig.Info propInfoList[index].val=value index=index+1 end for i = 1, _propGrid.transform.childCount do local propText=_propGrid.transform:GetChild(i-1).gameObject if i>#propInfoList then propText:SetActive(false) else propText:SetActive(true) propText:GetComponent("Text").text=propInfoList[i].name Util.GetGameObject(propText,"val"):GetComponent("Text").text=propInfoList[i].val end end end --设置升星技能信息显示 function this.SetSkillInfo(_skillInfoObj,_titleStr,_skillDatas) Util.GetGameObject(_skillInfoObj,"title"):GetComponent("Text").text=_titleStr local desStr="" for i = 1, #_skillDatas do desStr=desStr..string.format("【%s】%s",_skillDatas[i].title,_skillDatas[i].des) if i< #_skillDatas then desStr=desStr.."\n" end end Util.GetGameObject(_skillInfoObj,"des"):GetComponent("Text").text=desStr LayoutRebuilder.ForceRebuildLayoutImmediate(_skillInfoObj.transform) end --设置消耗材料显示 function this.SetCostItemInfo(_costItems) if not this.costItemViews then this.costItemViews = {} end for k,v in ipairs(this.costItemViews) do v.gameObject:SetActive(false) end for i = 1, #_costItems do if i<#this.costItemViews then this.costItemViews[i].OnOpen(false,{_costItems[i][1],_costItems[i][2]},0.9,true,false,false,this.sortingOrder) else local view= SubUIManager.Open(SubUIConfig.ItemView, this.costGrid.transform) view:OnOpen(false,{_costItems[i][1],_costItems[i][2]},0.9,true,false,false,this.sortingOrder) this.costItemViews[i]=view end end end function this:OnSortingOrderChange() this.sortingOrder = self.sortingOrder end --界面关闭时调用(用于子类重写) function this:OnClose() end --界面销毁时调用(用于子类重写) function this:OnDestroy() this.spLoader:Destroy() end return this