require("Base/BasePanel") RoleListPanel = Inherit(BasePanel) local this = RoleListPanel local sortType = 1 -- 1:品阶 2:等级 local proId=0--0 全部 1 火 2风 3 水 4 地 5 光 6 暗 local tarHero = {} local teamHero = {} local roleDatas={} this.isFirstOpen=true local tabs = {} local tabsImg = {"z_icon_01_zh", "r_hero_huo 1_zh", "r_hero_feng 1_zh", "r_hero_shui 1_zh", "r_hero_dadi 1_zh","z_icon_qingjinbao"} local soulPrintData={} local orginLayer = 0 local orginLayer2 = 0 local isFristOpenTime = Timer.New() function RoleListPanel:InitComponent() this.spLoader = SpriteLoader.New() this.BtnBack = Util.GetGameObject(self.transform, "rightUp/btnBack") this.cardPre = poolManager:LoadAsset("card", PoolManager.AssetType.GameObject) UIManager.DoLanguageCheck(this.spLoader, this.cardPre) this.cardPre.transform:SetParent(self.transform) this.cardPre:GetComponent("RectTransform").localScale = Vector3.New(1,1,1) local starPre = poolManager:LoadAsset("starGrid", PoolManager.AssetType.GameObject) starPre.transform:SetParent(Util.GetGameObject(self.transform, "card(Clone)/card/star").transform) local particles1=starPre:GetComponentsInChildren(typeof(UnityEngine.ParticleSystem)) for key, value in pairs(particles1:ToTable()) do local mat=value:GetComponent(typeof(UnityEngine.Renderer)) if mat.material.shader.name=="CGwell FX/Additive Lv1" then mat.material.shader=poolManager:LoadAsset("Add Lv1_1",poolManager.AssetType.Other) elseif mat.material.shader.name=="UI Particles/Additive" then mat.material.shader=poolManager:LoadAsset("UI-Particle-Add_1",poolManager.AssetType.Other) end end local particles=this.cardPre:GetComponentsInChildren(typeof(UnityEngine.ParticleSystem)) for key, value in pairs(particles:ToTable()) do local mat=value:GetComponent(typeof(UnityEngine.Renderer)) if mat.material.shader.name=="CGwell FX/Additive Lv1" then mat.material.shader=poolManager:LoadAsset("Add Lv1_1",poolManager.AssetType.Other) elseif mat.material.shader.name=="UI Particles/Additive" then mat.material.shader=poolManager:LoadAsset("UI-Particle-Add_1",poolManager.AssetType.Other) elseif mat.material.shader.name=="YXZ/Effect/Mix Masking(Without Moving)_alphablend" then mat.material.shader=poolManager:LoadAsset("YXZ_MixMaskingWithoutMoving_alphablend_1",poolManager.AssetType.Other) end end local meshs=this.cardPre:GetComponentsInChildren(typeof(UnityEngine.MeshRenderer)) for key, value in pairs(meshs:ToTable()) do if value.material.shader.name=="Custom/S_03_UV_alpha_add" then value.material.shader=poolManager:LoadAsset("S_03_uv_alpha_add_1",poolManager.AssetType.Other) end end local meshs2=this.cardPre:GetComponentsInChildren(typeof(UnityEngine.SkinnedMeshRenderer)) for key, value in pairs(meshs2:ToTable()) do if value.material.shader.name=="YXZ/Effect/TransparentRim" then value.material.shader=poolManager:LoadAsset("YXZ_Effect_TransparentRim_1",poolManager.AssetType.Other) end end this.btnPrant = Util.GetGameObject(self.gameObject, "Tabs") for i = 0, 6 do tabs[i] = Util.GetGameObject(self.transform, "Tabs/grid/box/Btn" .. i) local name=Util.GetGameObject(tabs[i], "Text"):GetComponent("Text") name.text=PropertyType[i] -- if tabsImg[i + 1] then -- Util.GetGameObject(tabs[i], "Image"):GetComponent("Image").sprite = this.spLoader:LoadSprite(tabsImg[i + 1]) -- end end this.ShaiXuanBtn = Util.GetGameObject(self.gameObject, "ShaiXuanBtn") this.ShaiXuanBtnLv = Util.GetGameObject(self.gameObject, "ShaiXuanBtn/Lv") this.ShaiXuanBtnLv:GetComponent("Image").sprite = this.spLoader:LoadSprite("r_tongyong_dengjiqiehuan_zh") this.ShaiXuanBtnQu = Util.GetGameObject(self.gameObject, "ShaiXuanBtn/Qu") this.ShaiXuanBtnQu:GetComponent("Image").sprite = this.spLoader:LoadSprite("r_tongyong_pingjieqiehuan_zh") this.selectBtn = Util.GetGameObject(self.gameObject, "Tabs/selectBtn") this.heroNumText = Util.GetGameObject(self.gameObject, "heroNum") this.ScrollBar = Util.GetGameObject(self.gameObject, "Scrollbar"):GetComponent("Scrollbar") this.fenJieBtn = Util.GetGameObject(self.gameObject, "fenJieBtn") --this.fenJieBtn:SetActive(false) this.formationBtn = Util.GetGameObject(self.gameObject, "formationBtn") this.haogandu = Util.GetGameObject(self.gameObject, "haogandu") this.haoganduLv = Util.GetGameObject(this.haogandu, "lv"):GetComponent("Text") --this.haogandu.gameObject:SetActive(false) this.haoganduRed = Util.GetGameObject(this.haogandu, "redPoint") if not this.playerInfoView then this.playerInfoView = SubUIManager.Open(SubUIConfig.PlayerInfoView, this.transform) -- this.playerInfoView.gameObject:AddComponent(typeof(UnityEngine.Canvas)).overrideSorting=true --this.playerInfoView.overrideSorting=true end this.BtView =SubUIManager.Open(SubUIConfig.BtView, self.gameObject.transform) this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform) --this.UpView.gameObject:AddComponent(typeof(UnityEngine.Canvas)).overrideSorting=true --this.UpView.overrideSorting=true local v2 = Util.GetGameObject(self.gameObject, "scroll"):GetComponent("RectTransform").rect this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, Util.GetGameObject(self.transform, "scroll").transform, this.cardPre, this.ScrollBar, Vector2.New(-v2.x*2, -v2.y*2+20), 1, 5, Vector2.New(25,8)) this.ScrollView.moveTween.MomentumAmount = 1 this.ScrollView.moveTween.Strength = 1 this.maxk = Util.GetGameObject(self.gameObject, "maxk") end --绑定事件(用于子类重写) function RoleListPanel:BindEvent() Util.AddClick(this.BtnBack, function() PlaySoundWithoutClick(SoundConfig.Sound_UICancel) HeroManager.heroListPanelSortID=SortTypeConst.Natural HeroManager.heroListPanelProID=ProIdConst.All UIManager.OpenPanel(UIName.MainPanel) end) for i = 0, 6 do Util.AddClick(tabs[i], function() if this.isFirstOpen == false then if i == proId then proId=ProIdConst.All HeroManager.heroListPanelProID=ProIdConst.All else proId=i HeroManager.heroListPanelProID=proId end this:GetCurSortHeroListData() end end) end Util.AddClick(this.ShaiXuanBtn, function() if sortType == SortTypeConst.Lv then sortType = SortTypeConst.Natural HeroManager.heroListPanelSortID=SortTypeConst.Natural else sortType = SortTypeConst.Lv HeroManager.heroListPanelSortID=SortTypeConst.Lv end this.ShaiXuanBtnLv:SetActive(sortType ~= SortTypeConst.Lv) this.ShaiXuanBtnQu:SetActive(sortType ~= SortTypeConst.Natural) this:GetCurSortHeroListData() end) Util.AddClick(this.fenJieBtn, function() UIManager.OpenPanel(UIName.HandBookHeroAndEquipListPanel,1) -- if ActTimeCtrlManager.SingleFuncState(24) then -- UIManager.OpenPanel(UIName.HeroAndEquipResolvePanel,1) -- else -- PopupTipPanel.ShowTip(ActTimeCtrlManager.GetFuncTip(24)) -- end end) Util.AddClick(this.formationBtn, function() if ActTimeCtrlManager.SingleFuncState(54) then -- UIManager.OpenPanel(UIName.FormationSetPanel) UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.SAVE_FORMATION) else PopupTipPanel.ShowTip(ActTimeCtrlManager.GetFuncTip(54)) end end) Util.AddClick(this.haogandu, function() --UIManager.OpenPanel(UIName.LikeAbilityPanel) if ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.LikeAbility) then UIManager.OpenPanel(UIName.LikeAbilityPanel) else PopupTipPanel.ShowTip(ActTimeCtrlManager.GetFuncTip(FUNCTION_OPEN_TYPE.LikeAbility)) end end) CheckRedPointStatus(RedPointType.LikeabilityRed) BindRedPointObject(RedPointType.LikeabilityRed,this.haoganduRed) end --添加事件监听(用于子类重写) function RoleListPanel:AddListener() end --移除事件监听(用于子类重写) function RoleListPanel:RemoveListener() end function this:OnSortingOrderChange() if this.ScrollView then this.ScrollView:ForeachItemGO(function (index, go) Util.SetParticleSortLayer(go, self.sortingOrder) end) end orginLayer = self.sortingOrder if this.BtView then this.BtView:SetOrderStatus({ sortOrder = self.sortingOrder }) end -- -- 头像层级 if this.playerInfoView then --this.playerInfoView:SetLayer(self.sortingOrder+2) --SetParticleSortLayer(this.playerInfoView,self.sortingOrder+2) end -- if this.UpView then -- SetParticleSortLayer(this.UpView,self.sortingOrder+2) -- end end --界面打开时调用(用于子类重写) function RoleListPanel:OnShow() --检测成员红点 CheckRedPointStatus(RedPointType.Role) tarHero=HeroManager.GetAllHeroDatas() teamHero=FormationManager.GetWuJinFormationHeroIds(FormationTypeDef.FORMATION_NORMAL) this.isFirstOpen=true this.maxk:SetActive(true) this.heroNumText:GetComponent("Text").text=string.format(Language[11821],#tarHero) this.UpView:OnOpen({ showType = UpViewOpenType.ShowRight, panelType = PanelType.RoleInfo }) this.BtView:OnOpen(self, {sortOrder = self.sortingOrder,panelType = PanelTypeView.MemberPanel}) SoundManager.PlayMusic(SoundConfig.BGM_Main) sortType = HeroManager.heroListPanelSortID proId = HeroManager.heroListPanelProID this:GetCurSortHeroListData() -- if ActTimeCtrlManager.SingleFuncState(24) then -- Util.SetGray(this.fenJieBtn, false) -- else -- Util.SetGray(this.fenJieBtn, true) -- end if ActTimeCtrlManager.SingleFuncState(54) then Util.SetGray(this.formationBtn, false) else Util.SetGray(this.formationBtn, true) end -- if this.ScrollView then -- this.ScrollView:SetIndex(1) -- end -- 刷新一次编队战斗力 FormationManager.RefreshMainFormationPower() this.haogandu.gameObject:SetActive(ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.LikeAbility)) local totalCurNum,totalLv,totalNum = LikabilityManager.GetTotalHeroLikeLv(-1) this.haoganduLv.text = totalLv --this.haogandu.gameObject:SetActive(true)--ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.LikeAbility)) end --组合当前选项数据 function this:GetCurSortHeroListData() local heros = {} if proId ~= ProIdConst.All then heros = HeroManager.GetHeroDataByProperty(proId) else heros = tarHero end this:SetRoleList(heros) this:SetSelectBtn() end function this:ChangeProId(id) proId=id end --设置英雄列表数据 function this:SetRoleList(_roleDatas) roleDatas=_roleDatas this:SortHeroDatas(_roleDatas) HeroManager.heroSortedDatas = roleDatas this.heroNumText:GetComponent("Text").text=string.format(Language[11821],#_roleDatas) this.ScrollView:SetData(_roleDatas, function (index, go) this.SingleHeroDataShow(go, roleDatas[index]) end) if this.isFirstOpen then if isFristOpenTime then isFristOpenTime:Stop() isFristOpenTime = nil end isFristOpenTime = Timer.New(function() this.isFirstOpen = false this.maxk:SetActive(false) end, 0.8):Start() end orginLayer2 =self.sortingOrder orginLayer = self.sortingOrder end function this.SingleHeroDataShow(_go,_heroData) local heroData = _heroData SetHeroBg(this.spLoader, Util.GetGameObject(_go.transform, "card"),Util.GetGameObject(_go.transform, "card/bg"),_heroData.star,heroData.heroConfig.Quality,this.sortingOrder + 1) if HarmonyManager.IsChangeColor(heroData.dynamicId) then Util.GetGameObject(_go.transform, "card/lv/Text"):GetComponent("Text").text = ""..heroData.lv.."" elseif HarmonyManager:IsEnvoy(heroData.dynamicId) and HarmonyManager.GetSingleAdditionsData(HarmonyAddType.AddLv) then local temp= HarmonyManager.GetSingleAdditionsData(HarmonyAddType.AddLv) if temp.heroTid == 0 and temp.value > 0 then Util.GetGameObject(_go.transform, "card/lv/Text"):GetComponent("Text").text = ""..heroData.lv.."" else Util.GetGameObject(_go.transform, "card/lv/Text"):GetComponent("Text").text = heroData.lv end else Util.GetGameObject(_go.transform, "card/lv/Text"):GetComponent("Text").text = heroData.lv end Util.GetGameObject(_go.transform, "card/name"):GetComponent("Text").text = GetLanguageStrById(heroData.heroConfig.ReadingName) Util.GetGameObject(_go.transform, "card/icon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetResourcePath(heroData.heroConfig.ShowLive)) SetHEeroLiveToward(Util.GetGameObject(_go.transform, "card/icon"):GetComponent("Image"),heroData.heroConfig.Toward) Util.GetGameObject(_go.transform, "card/pos/icon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(heroData.professionIcon) local imageCom=Util.GetGameObject(_go.transform, "card/pro/Image"):GetComponent("RectTransform") if heroData.changeProId == 1 or heroData.changeProId == 2 or heroData.changeProId == 3 or heroData.changeProId == 4 then imageCom.sizeDelta=Vector2.New(30,30) else imageCom.sizeDelta=Vector2.New(60,30) end imageCom.gameObject:GetComponent("Image").sprite= this.spLoader:LoadSprite(GetProStrImageByProNum(heroData.changeProId)) Util.GetGameObject(_go.transform, "card/heroStage"):GetComponent("Image").sprite = this.spLoader:LoadSprite(HeroStageSprite[heroData.heroConfig.HeroStage]) local redPoint = Util.GetGameObject(_go.transform, "card/redAndLock/redPoint") Util.GetGameObject(_go.transform, "card/redAndLock/lockImage"):SetActive(heroData.lockState == 1) Util.GetGameObject(_go.transform, "card/core"):SetActive(heroData.heroConfig.Main == 1) Util.GetGameObject(_go.transform, "card/starnum"):GetComponent("Text").text=_heroData.star.."/".._heroData.maxStar _go.transform.localScale = Vector3.one * 0.95 local starGrid = Util.GetGameObject(_go.transform, "star") local starPre = Util.GetGameObject(_go.transform, "starPre") --Util.ClearChild(starGrid.transform) local star,starType = heroData.GetStar(1) local starSize = Vector2.New(32.5,32.5) local starScale = -10 if starType == 3 then starSize = Vector2.New(1,-16.12) starScale = -13.2 elseif starType == 2 then starSize = Vector2.New(60,57) end -- SetHeroStars(this.spLoader, starGrid, star,starType,starSize,starScale) Util.SetParticleSortLayer(starGrid, this.sortingOrder + 1) --local cardBtn = Util.GetGameObject(_go.transform, "card(Clone)") SoulPrintManager.UnLockSoulPrintPos(heroData) local soulPrintIsOpen = table.nums(SoulPrintManager.hasUnlockPos)>=1 if teamHero[heroData.dynamicId]~=nil then Util.GetGameObject(_go.transform, "card/choosed"):SetActive(true) local isCanShowSoulPrintPoint = RedPointManager.PlayerPrefsGetStr(PlayerManager.uid .. heroData.dynamicId) soulPrintData = SoulPrintManager.GetSoulPrintAndSort(SoulPrintManager.soulPrintData) redPoint:SetActive(HeroManager.GetCurHeroIsShowRedPoint(heroData)) else redPoint:SetActive(false) Util.GetGameObject(_go.transform, "card/choosed"):SetActive(false) end --Util.GetGameObject(_go.transform, "card/choosed"):SetActive(teamHero[heroData -- .dynamicId]~=nil) Util.AddOnceClick(Util.GetGameObject(_go.transform, "card"), function() this.OnClickEnterHeroInfo(heroData, HeroManager.heroSortedDatas,teamHero[heroData.dynamicId]~=nil) end) end function this:SetSelectBtn() this.selectBtn.transform:SetParent(tabs[proId].transform) this.selectBtn:GetComponent("RectTransform").localPosition = Vector3.zero Util.GetGameObject( this.selectBtn.transform, "Text"):GetComponent("Text").text=Util.GetGameObject( tabs[proId].transform, "Text"):GetComponent("Text").text end function this:SortHeroDatas(_heroDatas) table.sort(_heroDatas, function(a, b) --如果都在编队或都不在编队 if (teamHero[a.dynamicId] and teamHero[b.dynamicId]) or (not teamHero[a.dynamicId] and not teamHero[b.dynamicId]) then --根据等级排列 if sortType == SortTypeConst.Lv then --判断等级是否相同 if a.lv == b.lv then --判断战力是否相同 if a.warPower == b.warPower then local aGodLv = GodSoulManager.GetGodSoulLv(a.dynamicId) local bGodLv = GodSoulManager.GetGodSoulLv(b.dynamicId) if aGodLv == bGodLv then ---判断星级是否相同 if a.star == b.star then --返回图鉴排序 return a.heroConfig.Sort < b.heroConfig.Sort else return a.star > b.star end else return aGodLv >bGodLv end else return a.warPower > b.warPower end else return a.lv > b.lv end --根据品阶排列 elseif sortType==SortTypeConst.Natural then local aGodLv = GodSoulManager.GetGodSoulLv(a.dynamicId) local bGodLv = GodSoulManager.GetGodSoulLv(b.dynamicId) if aGodLv == bGodLv then --是否星级相同 if a.star == b.star then --判断战力是否相同 if a.warPower == b.warPower then --判断等级是否相同 if a.lv == b.lv then --返回图鉴排序 return a.heroConfig.Sort < b.heroConfig.Sort else return a.lv > b.lv end else return a.warPower > b.warPower end else return a.star > b.star end else return aGodLv >bGodLv end end else --一个在一个不在先返回在的+不在的 return teamHero[a.dynamicId] and not teamHero[b.dynamicId] end end) end function this.OnClickEnterHeroInfo(_curhero, _heros,isUpZhen) UIManager.OpenPanel(UIName.RoleInfoPanel, _curhero, _heros,isUpZhen) end function this.GetRoleItemByName(name) local targetItem this.ScrollView:ForeachItemGO(function (index, go) local itemName = Util.GetGameObject(go.transform, "card/name"):GetComponent("Text").text if Util.GetGameObject(go.transform, "card/choosed").activeInHierarchy then if not targetItem and name == itemName then targetItem = go return end end if not targetItem and name == itemName then targetItem = go end end) return targetItem end --界面关闭时调用(用于子类重写) function RoleListPanel:OnClose() proId=0--面板关闭时 重置筛选按钮为全部 if isFristOpenTime then isFristOpenTime:Stop() isFristOpenTime = nil end end --界面销毁时调用(用于子类重写) function RoleListPanel:OnDestroy() this.spLoader:Destroy() SubUIManager.Close(this.UpView) SubUIManager.Close(this.BtView) this.ScrollView = nil if this.playerInfoView then SubUIManager.Close(this.playerInfoView) this.playerInfoView = nil end ClearRedPointObject(RedPointType.LikeabilityRed,this.haoganduRed) end return RoleListPanel