require("Base/BasePanel") HeroPotencyLvUpPanel = Inherit(BasePanel) local this = HeroPotencyLvUpPanel --长按升级状态 local _isReqLvUp=false local oldPower = 0 local newPower = 0 local oldPropMap={} local barWidth=700 local TabBox = require("Modules/Common/TabBox") local _TabData={ [1] = { default = "UI_hz_gonghui_19",lock="UI_hz_gonghui_19", select = "UI_hz_gonghui_18", type=1 }, [2] = { default = "UI_hz_gonghui_19",lock="UI_hz_gonghui_19", select = "UI_hz_gonghui_18", type=2 }, [3] = { default = "UI_hz_gonghui_19",lock="UI_hz_gonghui_19", select = "UI_hz_gonghui_18", type=3 }, [4] = { default = "UI_hz_gonghui_19",lock="UI_hz_gonghui_19", select = "UI_hz_gonghui_18", type=4 }, [5] = { default = "UI_hz_gonghui_19",lock="UI_hz_gonghui_19", select = "UI_hz_gonghui_18", type=5 }, [6] = { default = "UI_hz_gonghui_19",lock="UI_hz_gonghui_19", select = "UI_hz_gonghui_18", type=6 }, [7] = { default = "UI_hz_gonghui_19",lock="UI_hz_gonghui_19", select = "UI_hz_gonghui_18", type=7 }, [8] = { default = "UI_hz_gonghui_19",lock="UI_hz_gonghui_19", select = "UI_hz_gonghui_18", type=8 }, } local _TabFontColor = { default = Color.New(130 / 255, 128 / 255, 120 / 255, 1), select = Color.New(243 / 255, 235 / 255, 202 / 255, 1), lock = UIColor.GRAY, } local dynamicId="" local type=0 local config=nil local curIndex=0 local data local preList={} local curTabIndex=0 local parPanel=nil local isCan=true local lv= 0 --初始化组件(用于子类重写)FourQuadrantPopup function this:InitComponent() this.spLoader = SpriteLoader.New() this.mask = Util.GetGameObject(self.gameObject, "mask") this.backBtn = Util.GetGameObject(self.gameObject, "bg/btnBack") this.titleText = Util.GetGameObject(self.gameObject, "bg/titleText"):GetComponent("Text") this.limitHint = Util.GetGameObject(self.gameObject, "bg/limitHint"):GetComponent("Text") this.griftLv = Util.GetGameObject(self.gameObject, "bg/giftLv"):GetComponent("Text") this.lvTxt = Util.GetGameObject(self.gameObject, "bg/lvTxt"):GetComponent("Text") this.upBtn = Util.GetGameObject(self.gameObject, "bg/upBtn") this.jianTou = Util.GetGameObject(self.gameObject, "bg/jiantou") this.upStarBtn = Util.GetGameObject(self.gameObject, "bg/oneKeyBtn") this.proUpInfo=Util.GetGameObject(self.gameObject, "bg/proUpInfo"):GetComponent("Text") this.upLvTrigger = Util.GetEventTriggerListener(this.upBtn) this.grayImage=Util.GetGameObject(self.gameObject, "bg/gray"):GetComponent("Image") this.upStarPropWin = Util.GetGameObject(self.gameObject, "upStarPropWin") this.propWinGrid = Util.GetGameObject(self.gameObject, "upStarPropWin/grid") this.propWinCloseBtn = Util.GetGameObject(self.gameObject, "upStarPropWin/closeBtn") this.starLv = Util.GetGameObject(self.gameObject, "bg/starLv") this.professionIcon = Util.GetGameObject(self.gameObject, "bg/professionIcon"):GetComponent("Image") this.grid=Util.GetGameObject(self.gameObject,"grid") this.itemPre=Util.GetGameObject(self.gameObject,"itemPre") this.selectImg=Util.GetGameObject(self.gameObject,"selectImg") this.btnList={} this.tabBox = Util.GetGameObject(self.gameObject, "TabBox") this.box = Util.GetGameObject(self.gameObject, "TabBox/box") this.hintTip= Util.GetGameObject(self.gameObject, "bg/hintTip"):GetComponent("Text") this.TabCtrl = TabBox.New() this.TabCtrl:SetTabAdapter(this.TabAdapter) this.TabCtrl:SetChangeTabCallBack(this.SwitchView) --this.TabCtrl:SetTabIsLockCheck(this.IsTabLock) for i=1,8 do this.btnList[i]=Util.GetGameObject(this.box, "tab"..i) end end function this.IsTabLock(index) --LogError("检测是否上锁") if data[_TabData[index].type] then return false else return true,PoTencyTypeName[_TabData[index].type].."未开启" end return true,PoTencyTypeName[_TabData[index].type].."未开启" end -- tab节点显示自定义 function this.TabAdapter(tab, index, status) local tabLab = Util.GetGameObject(tab, "Text") local img=Util.GetGameObject(tab,"Image") local red=Util.GetGameObject(tab,"Redpot") red:SetActive(HeroManager.CheckPotencyRedPointByType(dynamicId,_TabData[index].type)) img:GetComponent("Image").sprite = this.spLoader:LoadSprite(_TabData[index][status]) tabLab:GetComponent("Text").text = PoTencyTypeName[_TabData[index].type] tabLab:GetComponent("Text").color = _TabFontColor[status] Util.GetGameObject(tab,"LockImage"):SetActive(status == "lock") if status=="default" then img:GetComponent("RectTransform").sizeDelta = Vector2.New(105,58) elseif status=="select" then img:GetComponent("RectTransform").sizeDelta = Vector2.New(105,70) end --this.btnList[index]=tab end --切换视图 function this.SwitchView(index) type=_TabData[index].type --LogError("btnList==========="..#this.btnList.." index=="..index) isCan=true curTabIndex=index --ConfigManager.getcon config=ConfigManager.TryGetConfigDataByKey(ConfigName.PotentialNewConfig,"Type",type) local giftLv=GiftManager.GetHeroPotencyLvById(dynamicId) if data[type] then lv=data[type].lv this.hintTip.gameObject:SetActive(false) LogError("giftLv======================"..data[type].giftLv.." 本地计算giftLV"..giftLv.." lv=="..lv) else lv=0 this.hintTip.text=PoTencyTypeName[_TabData[index].type].."潜能未开启" this.hintTip.gameObject:SetActive(true) end this.professionIcon.sprite=this.spLoader:LoadSprite(config.Icon) local curLv=lv+giftLv local lvEquipConfig= ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.PotentialNew,"Type",type,"Level",lv) local curEquipConfig= ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.PotentialNew,"Type",type,"Level",curLv) local nextEquipConfig= ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.PotentialNew,"Type",type,"Level",curLv+1) this.limitHint.text=lv.."级" this.griftLv.text="+"..giftLv if nextEquipConfig then this.lvTxt.gameObject:SetActive(true) this.jianTou:SetActive(true) local curPro=0 if curEquipConfig then curPro=curEquipConfig.Attribute end this.proUpInfo.text=PoTencyTypeName[_TabData[index].type].."基础属性提升"..curPro/100 .."%" this.lvTxt.text=nextEquipConfig.Attribute/100 .."%" else this.lvTxt.gameObject:SetActive(false) this.jianTou:SetActive(false) this.proUpInfo.text=PoTencyTypeName[_TabData[index].type].."基础属性提升"..curEquipConfig.Attribute/100 .."%" end if lvEquipConfig and lvEquipConfig.Consume and #lvEquipConfig.Consume>0 and tonumber(lvEquipConfig.Consume[1][1])~=nil then this.grid:SetActive(true) this.upBtn:SetActive(true) this.upStarBtn:SetActive(true) for i=1,#preList do preList[i]:SetActive(false) end for i=1,#lvEquipConfig.Consume do if preList[i]==nil then preList[i]=newObject(this.itemPre) end preList[i]:SetActive(true) preList[i].transform:SetParent(this.grid.transform) preList[i].transform.localScale = Vector3.one preList[i].transform.localPosition=Vector3.zero; local cost=lvEquipConfig.Consume[i] local frame=Util.GetGameObject(preList[i],"frame"):GetComponent("Image") local icon=Util.GetGameObject(preList[i],"icon"):GetComponent("Image") local num=Util.GetGameObject(preList[i],"num"):GetComponent("Text") local costId=0 local itemConfig=ConfigManager.GetConfigData(ConfigName.ItemConfig,cost[1]) frame.sprite=this.spLoader:LoadSprite(GetQuantityImageByquality(itemConfig.Quantity)) icon.sprite=this.spLoader:LoadSprite(GetResourcePath(itemConfig.ResourceID)) local haveNum=BagManager.GetItemCountById(cost[1]) if haveNum>=cost[2] then num.text=string.format("%s/%s", cost[2],haveNum) else isCan=false num.text=string.format("%s/%s",cost[2],haveNum) end Util.AddClick(icon.gameObject,function() UIManager.OpenPanel(UIName.RewardItemSingleShowPopup,cost[1]) end) end else this.grid:SetActive(false) this.upBtn:SetActive(false) this.upStarBtn:SetActive(false) end this.titleText.text=config.Name end --绑定事件(用于子类重写) function this:BindEvent() Util.AddClick(this.backBtn, function() self:ClosePanel() end) Util.AddClick(this.mask, function() self:ClosePanel() end) --升级 Util.AddOnceClick(this.upBtn, function() if isCan then NetManager.PotentialUpLvRequest(dynamicId,type,1,function() PopupTipPanel.ShowTip("升级成功") this.TabCtrl:Init(this.tabBox, _TabData,curTabIndex) --this.SwitchView(curTabIndex) end) else PopupTipPanel.ShowTip("材料不足") end end) --一键升级 Util.AddClick(this.upStarBtn, function() if isCan==false then PopupTipPanel.ShowTip("材料不足") return end local list=ConfigManager.TryGetAllConfigsDataByKey(ConfigName.PotentialNew,"Type",type) local costNum=0 local costList={} local targetLv=0 for k=1,#list do local v=list[k] if v.Level>=lv then if v.Consume and #v.Consume>0 and tonumber(v.Consume[1][1])~=nil then for i=1,#v.Consume do local key=v.Consume[i][1] local value=v.Consume[i][2] if costList[key]==nil then costList[key]=0 end costList[key]=costList[key]+value --如果材料 if BagManager.GetItemCountById(key) >= costList[key] then targetLv = v.Level else break end end else break end end end --是否直接升到最大 --if isMax==false then targetLv=targetLv+1 --end LogError("targeylv============"..targetLv.." lv===="..lv) NetManager.PotentialUpLvRequest(dynamicId,type,targetLv-lv,function() PopupTipPanel.ShowTip("升级成功") this.TabCtrl:Init(this.tabBox, _TabData,curTabIndex) --this.SwitchView(curTabIndex) end) end) Util.AddClick(this.propWinCloseBtn, function() this.upStarPropWin:SetActive(false); end) end --添加事件监听(用于子类重写) function this:AddListener() Game.GlobalEvent:AddEvent(GameEvent.FourQuadrant.ShowPower, this.ShowPower) end --移除事件监听(用于子类重写) function this:RemoveListener() Game.GlobalEvent:RemoveEvent(GameEvent.FourQuadrant.ShowPower, this.ShowPower) end --界面打开时调用(用于子类重写) function this:OnOpen(_type,_did,_config,_parPanel) dynamicId=_did type=_type config=_config parPanel=_parPanel for i=1,#_TabData do if _TabData[i].type==_type then curTabIndex=i end end data=HeroManager.GetPotentialData(dynamicId) this.TabCtrl:Init(this.tabBox, _TabData,curTabIndex) --this.TabCtrl:ChangeTab(curTabIndex) this.SwitchView(curTabIndex) oldPower = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL) end function this:OnShow() end ---显示战斗力提升 function this.ShowPower() newPower = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL) if newPower~=oldPower then UIManager.OpenPanel(UIName.WarPowerChangeNotifyPanelV2,{oldValue = oldPower,newValue = newPower}) oldPower = newPower end end --进阶刷新界面 function this.UpStarUpdate() this.UpdateData(this.professionId) end --检测当前强化进度是否可以进阶 function this.CheckIsUpStar() end --检测界面页签红点 function this.CheckWinRedPoint() end --界面关闭时调用(用于子类重写) function this:OnClose() if parPanel then parPanel.RefreshWindowData() end end function this:OnDestroy() this.spLoader:Destroy() preList={} end return HeroPotencyLvUpPanel