require("Base/BasePanel") FourQuadrantPopup = Inherit(BasePanel) local this = FourQuadrantPopup local ProfessionType = { [1] = 2,--输出 [2] = 1,--肉盾 [3] = 3,--控制 [4] = 4,--辅助 } local propertyType = { [1] = 2,--攻击 [2] = 1,--生命 [3] = 3,--护甲 [4] = 4,--魔抗 } --属性id对应属性名称 local PropertyName={ [1] = "生命", [2] = "攻击", [3] = "护甲", [4] = "魔抗", } local lastPropertyLimit={}--上一级属性上限 local propertyLimit={}--属性上限 local fourQuadConfig local upStarProperty={}--进阶属性 --长按升级状态 local _isClicked = false local _isLongPress = false local _isReqLvUp=false local oldPower = 0 local newPower = 0 this.timePressStarted = 0--监听长按时间 local oldPropMap={} local barWidth=700 --初始化组件(用于子类重写)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.limitCost = Util.GetGameObject(self.gameObject, "bg/limitHint/costIcon"):GetComponent("Image") this.shuchuBtn = Util.GetGameObject(self.gameObject, "bg/TabBox/box/shuchuBtn") this.roudunBtn =Util.GetGameObject(self.gameObject, "bg/TabBox/box/roudunBtn") this.kongzhiBtn = Util.GetGameObject(self.gameObject, "bg/TabBox/box/kongzhiBtn") this.fuzhuBtn = Util.GetGameObject(self.gameObject, "bg/TabBox/box/fuzhuBtn") this.selectBtn = Util.GetGameObject(self.gameObject, "bg/TabBox/selectBtn") this.upBtn = Util.GetGameObject(self.gameObject, "bg/upBtn") this.upStarBtn = Util.GetGameObject(self.gameObject, "bg/upStarBtn") this.helpBtn = Util.GetGameObject(self.gameObject, "bg/HelpBtn") this.helpPosition=this.helpBtn:GetComponent("RectTransform").localPosition this.propertyGrid=Util.GetGameObject(self.gameObject, "bg/propertyGrid") this.costPreParent=Util.GetGameObject(self.gameObject, "bg/materialGrid") this.upStarHint=Util.GetGameObject(self.gameObject, "bg/upStarHint"):GetComponent("Text") this.upLvTrigger = Util.GetEventTriggerListener(this.upBtn) this.grayImage=Util.GetGameObject(self.gameObject, "bg/gray"):GetComponent("Image") this.upStarPropBtn = Util.GetGameObject(self.gameObject, "bg/upStarPropBtn") 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.gongmingBtn = Util.GetGameObject(self.gameObject, "bg/gongmingBtn") this.skillBtn = Util.GetGameObject(self.gameObject, "bg/skillBtn") this.skillBtn:SetActive(false) this.professionIcon = Util.GetGameObject(self.gameObject, "bg/professionIcon"):GetComponent("Image") this.btnList={ [1]=this.roudunBtn, [2]=this.shuchuBtn, [3]=this.kongzhiBtn, [4]=this.fuzhuBtn,} this.propPreMap={} for i = 1, #propertyType do local obj=this.propertyGrid.transform:GetChild(i-1) local propObjMap={} propObjMap.bar=Util.GetGameObject(obj.gameObject,"progressBg/progressBar"):GetComponent("RectTransform") propObjMap.addValue=Util.GetGameObject(obj.gameObject,"progressBg/addValue"):GetComponent("Text") propObjMap.propertyValueText=Util.GetGameObject(obj.gameObject,"propertyValue"):GetComponent("Text") propObjMap.propertyNameText=Util.GetGameObject(obj.gameObject,"propertyName"):GetComponent("Text") propObjMap.propertyIcon=Util.GetGameObject(obj.gameObject,"propertyIcon"):GetComponent("Image") propObjMap.fade=nil this.propPreMap[propertyType[i]]=propObjMap end this.itemView= SubUIManager.Open(SubUIConfig.ItemView, this.limitCost.transform) end --绑定事件(用于子类重写) function this:BindEvent() Util.AddClick(this.backBtn, function() self:ClosePanel() end) Util.AddClick(this.mask, function() self:ClosePanel() end) Util.AddClick(this.shuchuBtn, function() local professionId=ProfessionType[1] this.SetSelectBtn(professionId) this.UpdateData(professionId) end) Util.AddClick(this.roudunBtn, function() local professionId=ProfessionType[2] this.SetSelectBtn(professionId) this.UpdateData(professionId) end) Util.AddClick(this.kongzhiBtn, function() local professionId=ProfessionType[3] this.SetSelectBtn(professionId) this.UpdateData(professionId) end) Util.AddClick(this.fuzhuBtn, function() local professionId=ProfessionType[4] this.SetSelectBtn(professionId) this.UpdateData(professionId) end) Util.AddClick(this.gongmingBtn, function() UIManager.OpenPanel(UIName.FourQuadrantGongmingPopup) end) Util.AddClick(this.skillBtn, function() UIManager.OpenPanel(UIName.GeneralInfoPopup,GENERALINFO_TYPE.FourQuadrant,this.professionId,this.professionLv,this.curProfessionName) end) Util.AddClick(this.limitCost.gameObject, function() this.itemView:OnBtnCkickEvent(this.upStarCostitem.Id) end) Util.AddOnceClick(this.upBtn, function() if this.CheckIsUpStar() then return end local costArr=fourQuadConfig.LvupCost for i = 1, #costArr do if BagManager.GetTotalItemNum(costArr[i][1]) 0.4 then _isLongPress = true if not _isReqLvUp then _isReqLvUp = true this.timePressStarted=Time.realtimeSinceStartup local costArr=fourQuadConfig.LvupCost for i = 1, #costArr do if BagManager.GetTotalItemNum(costArr[i][1])0) local propertyList=professionInfo and professionInfo.propertyList or nil fourQuadConfig = ConfigManager.GetConfigDataByKey(ConfigName.FourQuadrantConfig,"Star",this.professionLv) ---获取属性上限(属性id:属性上限值) for i = 1, #fourQuadConfig.PropLimit do propertyLimit[fourQuadConfig.PropLimit[i][1]]=fourQuadConfig.PropLimit[i][2] end if this.professionLv>0 then local lastStarLv=this.professionLv-1 local lastFourQuadConfig = ConfigManager.GetConfigDataByKey(ConfigName.FourQuadrantConfig,"Star",lastStarLv) ---获取上一级属性上限(属性id:属性上限值) for i = 1, #lastFourQuadConfig.PropLimit do lastPropertyLimit[lastFourQuadConfig.PropLimit[i][1]]=lastFourQuadConfig.PropLimit[i][2] end else lastPropertyLimit={} end upStarProperty=PracticeManager.fourQuadrantUpStarPropMap[_professionId] this.SaveOldProp(propertyList) this.UpdateBtnStateAndCostShow() this.UpdateProperty(propertyList) this.UpdateStarLv() this.professionIcon.sprite = this.spLoader:LoadSprite(GetHeroProfessionById(_professionId)) end ---更新职业等级显示 function this.UpdateStarLv() local lvCount=this.starLv.transform.childCount for i = 0, lvCount-1 do local star=this.starLv.transform:GetChild(i).gameObject if i=5 then this.upStarHint.text=string.format("四象心法-%s已强化圆满!",this.curProfessionName) this.upBtn.gameObject:SetActive(false) this.upStarBtn.gameObject:SetActive(false) this.upStarHint.gameObject:SetActive(true) elseif this.CheckXiuxingLv() then this.upBtn.gameObject:SetActive(false) this.upStarBtn.gameObject:SetActive(true) this.upStarHint.gameObject:SetActive(false) costArr=fourQuadConfig.RankupCost this.upStarBtn.gameObject:GetComponent("Image").material=nil else this.upBtn.gameObject:SetActive(false) this.upStarBtn.gameObject:SetActive(true) this.upStarHint.gameObject:SetActive(true) this.upStarBtn.gameObject:GetComponent("Image").material=this.grayImage.material end _isClicked = false _isLongPress = false else this.upBtn.gameObject:SetActive(true) this.upStarBtn.gameObject:SetActive(false) this.upStarHint.gameObject:SetActive(false) costArr=fourQuadConfig.LvupCost end --设置消耗显示 for i = 1, this.costPreParent.transform.childCount do local costObj=this.costPreParent.transform:GetChild(i-1).gameObject; if i<=#costArr then local costStr=costArr[i] costObj:SetActive(true); local icon = Util.GetGameObject(costObj,"Image"):GetComponent("Image") local num = costObj:GetComponent("Text") icon.sprite = this.spLoader:LoadSprite(GetSpriteNameByItemId(costStr[1])) local cueHasNum=BagManager.GetTotalItemNum(costArr[i][1]) num.text = string.format("%s/%s",PrintWanNum2(cueHasNum),costStr[2]) if cueHasNum%s/%s",PrintWanNum2(cueHasNum),costStr[2]) end local itemBtn=Util.GetGameObject(costObj,"Image") local itemId=costStr[1] Util.AddOnceClick(itemBtn, function() LogRed("itemid:"..itemId) this.itemView:OnBtnCkickEvent(itemId) end) else costObj:SetActive(false); end end end function this.UpdateUpStarTip() if fourQuadConfig.RankupCost then this.upStarCostitem= ConfigManager.GetConfigData(ConfigName.ItemConfig,fourQuadConfig.RankupCost[1][1]) this.limitHint.gameObject:SetActive(true) if this.CheckIsUpStar() then this.limitCost.gameObject:SetActive(false) this.limitHint.text=string.format("进阶后,四种属性全部提升%s%%",10) else local itemName=this.upStarCostitem.Name local itemIcon=GetResourcePath(this.upStarCostitem.ResourceID) this.limitHint.text=string.format("四种属性强化至上限后使用 %s进阶",itemName) this.limitCost.gameObject:SetActive(true) this.limitCost.sprite=this.spLoader:LoadSprite(itemIcon) this.itemView:OnOpen(false, {this.upStarCostitem.Id,1}, 0, false,false,false) end else this.limitHint.gameObject:SetActive(false) end end ---更新属性信息 function this.UpdateProperty(_propertyInfoList) local _propertyInfoMap={} if _propertyInfoList then for i = 1, #_propertyInfoList do _propertyInfoMap[_propertyInfoList[i].propertyId]=_propertyInfoList[i].propertyNum end end for i = 1, #propertyType do local propertyId=propertyType[i] this.propPreMap[propertyId].propertyIcon.sprite=this.spLoader:LoadSprite(PropertyTypeIconDef[propertyId]) this.propPreMap[propertyId].propertyNameText.text=string.format("%s英雄%s",this.curProfessionName,PropertyName[propertyId]) local propertyNum=_propertyInfoMap[propertyId] and _propertyInfoMap[propertyId] or 0; local curPropLimit=propertyLimit[propertyId] local propBar=this.propPreMap[propertyId].bar if this.professionLv>0 then local progressNum=_propertyInfoMap[propertyId]-lastPropertyLimit[propertyId] local progressLimit=curPropLimit-lastPropertyLimit[propertyId] propBar.sizeDelta= Vector2.New(progressNum/progressLimit*barWidth,propBar.sizeDelta.y) else propBar.sizeDelta = Vector2.New(propertyNum/curPropLimit*barWidth,propBar.sizeDelta.y) end this.propPreMap[propertyId].propertyValueText.text=string.format("%s/%s",propertyNum,curPropLimit) end this.UpdateBtnStateAndCostShow() _isReqLvUp = false this.CheckWinRedPoint() this.ShowAddPropNum(this.professionId) 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.SaveOldProp(_propertyInfoList) if _propertyInfoList then for i = 1, #_propertyInfoList do oldPropMap[_propertyInfoList[i].propertyId]=_propertyInfoList[i].propertyNum end end end --显示属性值增加 function this.ShowAddPropNum(_professionId) local propertyList=PracticeManager.FourQuadrantData[_professionId].propertyList if propertyList then for i = 1, #propertyList do local propertyInfo=propertyList[i] local oldPropNum=0 if oldPropMap[propertyInfo.propertyId] then oldPropNum=oldPropMap[propertyInfo.propertyId] end local addNum=propertyInfo.propertyNum-oldPropNum if addNum>0 then this.propPreMap[propertyInfo.propertyId].addValue.text=string.format("+%s",addNum); this.propPreMap[propertyInfo.propertyId].addValue.gameObject:SetActive(true) if this.propPreMap[propertyInfo.propertyId].fade then this.propPreMap[propertyInfo.propertyId].fade:Kill() end this.propPreMap[propertyInfo.propertyId].addValue:DOFade(1, 0) this.propPreMap[propertyInfo.propertyId].fade= this.propPreMap[propertyInfo.propertyId].addValue:DOFade(0, 3):OnComplete(function() this.propPreMap[propertyInfo.propertyId].fade=nil end) end oldPropMap[propertyInfo.propertyId]=propertyInfo.propertyNum end end end --进阶刷新界面 function this.UpStarUpdate() this.UpdateData(this.professionId) end --检测当前强化进度是否可以进阶 function this.CheckIsUpStar() local professionInfo=PracticeManager.FourQuadrantData[this.professionId] if not professionInfo.propertyList then return false end for i = 1, #professionInfo.propertyList do local propertyInfo= professionInfo.propertyList[i]; if propertyInfo.propertyNum%s期后方可进阶",xiuxingConfig.RealmName) if PracticeManager.PracticeBigLevel