require("Base/BasePanel") local PlayerInfoPopup = Inherit(BasePanel) local this = PlayerInfoPopup local netserverName = nil local XiuXianSkillConfig = ConfigManager.GetConfig(ConfigName.XiuXianSkillConfig) local isNpc = false--是否是机器人 local _ViewConfig = { [PLAYER_INFO_VIEW_TYPE.NORMAL] = { formationType = FormationTypeDef.FORMATION_NORMAL, tip = Language[10933], isAddFriend = true, btnType = { --{name = "举 报", func = 1}, {name = Language[11496], func = 2}, {name = Language[11497], func = 3}, } }, [PLAYER_INFO_VIEW_TYPE.BLACK_REMOVE] = { formationType = FormationTypeDef.FORMATION_NORMAL, tip = Language[10933], isAddFriend = true, btnType = { {name = Language[11498], func = 4}, } }, [PLAYER_INFO_VIEW_TYPE.GO_TO_BLACK] = { formationType = FormationTypeDef.FORMATION_NORMAL, tip = Language[10933], isAddFriend = true, btnType = { {name = Language[11499], func = 5}, } }, [PLAYER_INFO_VIEW_TYPE.ARENA] = { formationType = FormationTypeDef.FORMATION_ARENA_DEFEND, tip = Language[11500], isAddFriend = true, }, [PLAYER_INFO_VIEW_TYPE.TOP_MATCH] = { formationType = FormationTypeDef.ARENA_TOM_MATCH, tip = "巅峰赛阵容", isAddFriend = false, }, [PLAYER_INFO_VIEW_TYPE.MIND_DEMON] = { formationType = FormationTypeDef.MONSTER_CAMP_ATTACK, tip = Language[12306], isAddFriend = true, btnType = {} }, [PLAYER_INFO_VIEW_TYPE.TSLX] = { formationType = FormationTypeDef.FORMATION_TSLX, tip = "挑战阵容", isAddFriend = true, btnType = {} }, [PLAYER_INFO_VIEW_TYPE.JUPMSERVER] = { formationType = FormationTypeDef.JUMPSERVER_HIGHTLADDER, tip = "罗浮争锋阵容:", isAddFriend = false, btnType = { -- {name = "挑战", func = 6}, {name = "切磋", func = 6}, } }, [PLAYER_INFO_VIEW_TYPE.JUPMSERVER_NORMAL] = { formationType = FormationTypeDef.FORMATION_NORMAL, tip = Language[10933], isAddFriend = false, btnType = { {name = "切磋", func = 7}, } }, [PLAYER_INFO_VIEW_TYPE.QIJIESHILIAN] = { formationType = FormationTypeDef.FORMATION_QIJIESHILIAN, tip = "七界试炼阵容:", isAddFriend = false, btnType = { -- {name = "切磋", func = 7}, } }, [PLAYER_INFO_VIEW_TYPE.LINGMAIMIJING] = { formationType = FormationTypeDef.FORMATION_LINGMAIMIJING, tip = "灵脉秘境阵容:", isAddFriend = false, btnType = { {name = "切磋", func = 3}, {name = "挑战", func = 8}, {name = "调整编队", func = 8}, } }, } local curPlayerName = "" local _PlayerHead = nil --初始化组件(用于子类重写) function PlayerInfoPopup:InitComponent() this.spLoader = SpriteLoader.New() this.extraInfo = require("Modules/Popup/PlayerInfoPopup_extra") this.btnBack = Util.GetGameObject(self.transform, "btnClose") this.BgMask = Util.GetGameObject(self.transform, "BgMask") this.memHead = Util.GetGameObject(self.transform, "tipImage/panel/info/head") this.memName = Util.GetGameObject(self.transform, "tipImage/panel/info/name"):GetComponent("Text") this.memProfess = Util.GetGameObject(self.transform, "tipImage/panel/info/profess"):GetComponent("Text") this.addFriendBtn = Util.GetGameObject(self.transform, "tipImage/panel/info/btnAdd") this.addFriendBtnText = Util.GetGameObject(this.addFriendBtn, "text"):GetComponent("Text") this.starBox = Util.GetGameObject(self.transform, "tipImage/panel/info/starBox") this.star = Util.GetGameObject(self.transform, "tipImage/panel/info/starBox/star") this.titlePar = Util.GetGameObject(self.transform, "tipImage/panel/info/titlePar") this.memPower = Util.GetGameObject(self.transform, "tipImage/panel/defendbox/power"):GetComponent("Text") this.formationTip = Util.GetGameObject(self.transform, "tipImage/panel/defendbox/tip"):GetComponent("Text") this.attackCount = Util.GetGameObject(self.transform, "tipImage/attackCount"):GetComponent("Text") this.demonsHeroList=Util.GetGameObject(self.gameObject, "tipImage/panel/defendbox/demons") this.diffDemonsHeroList=Util.GetGameObject(self.gameObject, "tipImage/panel/defendbox/diffdemons") this.Demons = {} for i = 1, 6 do this.Demons[i] = {} this.Demons[i].go = Util.GetGameObject(self.gameObject, "tipImage/panel/defendbox/Demons/heroPro (" .. i .. ")") this.Demons[i].frameBtn =Util.GetGameObject(this.Demons[i].go, "frame") this.Demons[i].frame =this.Demons[i].frameBtn:GetComponent("Image") this.Demons[i].hero = Util.GetGameObject(this.Demons[i].go, "hero") this.Demons[i].starGrid = Util.GetGameObject(this.Demons[i].hero, "starGrid") this.Demons[i].proIcon = Util.GetGameObject(this.Demons[i].hero, "proIcon"):GetComponent("Image") this.Demons[i].levelText = Util.GetGameObject(this.Demons[i].hero, "lvbg/levelText"):GetComponent("Text") this.Demons[i].icon = Util.GetGameObject(this.Demons[i].hero, "icon"):GetComponent("Image") end this.Pokemons={} Util.GetGameObject(self.transform, "tipImage/panel/pokemonInfo/tip"):GetComponent("Text").text=Language[11501] this.Pokemons = {} for i = 1, 6 do table.insert(this.Pokemons, Util.GetGameObject(self.gameObject, "tipImage/panel/pokemonInfo/Demons/heroPro (" .. i .. ")")) end this.pokemonObj=Util.GetGameObject(self.transform, "tipImage/panel/pokemonInfo").gameObject this.boxLine = Util.GetGameObject(self.transform, "tipImage/panel/defendbox/line") this.btnBox = Util.GetGameObject(self.transform, "tipImage/panel/box") -- this.bgImg= Util.GetGameObject(self.transform, "tipImage/tipImage"):GetComponent("RectTransform") this.btnList = {} this.btnList[1] = Util.GetGameObject(this.btnBox, "btn1") this.btnList[2] = Util.GetGameObject(this.btnBox, "btn2") this.btnList[3] = Util.GetGameObject(this.btnBox, "btn3") --神印信息 this.imprintObj = Util.GetGameObject(self.transform, "tipImage/panel/imprintInfo") this.imprintGrid = Util.GetGameObject(this.imprintObj, "Imprints") this.imprintPre = Util.GetGameObject(self.transform, "imprintPre") this.imprintItemList = {} end --绑定事件(用于子类重写) function PlayerInfoPopup:BindEvent() Util.AddClick(this.btnBack, function() PlaySoundWithoutClick(SoundConfig.Sound_UICancel) this:ClosePanel() end) Util.AddClick(this.BgMask, function() PlaySoundWithoutClick(SoundConfig.Sound_UICancel) this:ClosePanel() end) Util.AddClick(this.addFriendBtn, function() if not ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.GOODFRIEND) then PopupTipPanel.ShowTip(ActTimeCtrlManager.GetFuncTip(FUNCTION_OPEN_TYPE.GOODFRIEND)) return end if GoodFriendManager.IsInBlackList(this._PlayerId) then PopupTipPanel.ShowTip(Language[10814]) return end if this._PlayerId == PlayerManager.uid then PopupTipPanel.ShowTip(Language[10931]) return end if GoodFriendManager.IsMyFriend(this._PlayerId) then PopupTipPanel.ShowTip(Language[10932]) return end if this._PlayerData.isApplyed == 1 then PopupTipPanel.ShowTip(Language[10819]) return end GoodFriendManager.InviteFriendRequest(this._PlayerId, function() PopupTipPanel.ShowTip(Language[11502]) this._PlayerData.isApplyed = 1 this.RefreshFunction() end) end) end --添加事件监听(用于子类重写) function PlayerInfoPopup:AddListener() end --移除事件监听(用于子类重写) function PlayerInfoPopup:RemoveListener() end --界面打开时调用(用于子类重写) function PlayerInfoPopup:OnOpen(playerId, viewType,serverName,_otherdata) this._PlayerId = playerId this._ViewType = viewType or PLAYER_INFO_VIEW_TYPE.NORMAL this.serverName = serverName--跨服加的服务器数据 this.data = _otherdata isNpc = this._PlayerId <= 1000000 -- 界面类型修正 if this._ViewType == PLAYER_INFO_VIEW_TYPE.NORMAL and GoodFriendManager.IsInBlackList(this._PlayerId) then this._ViewType = PLAYER_INFO_VIEW_TYPE.GO_TO_BLACK end this._Config = _ViewConfig[this._ViewType] -- 注册按钮事件 this.btnFunc = { [1] = this.Report, [2] = this.AddToBlackList, [3] = this.BeatHim, [4] = this.RemoveFromBlackList, [5] = this.GoToBlack, [6] = this.JumpServerBattle, [7] = this.JumpServerBattle_NORMAL, [8] = this.LingMaiFormaion, } end -- 设置界面类型 function PlayerInfoPopup:SetViewType(viewType) this._ViewType = viewType or PLAYER_INFO_VIEW_TYPE.NORMAL this._Config = _ViewConfig[this._ViewType] this:OnShow() end --界面打开或者重新打开后,界面刷新时调用(用于子类重写) function PlayerInfoPopup:OnShow() -- this.RefreshBtnShow() -- 请求数据 LogGreen("角色Id:"..tostring(this._PlayerId).." 编队Id:"..tostring(this._Config.formationType)) if this._PlayerId > 0 then--如果PlayerId > 0 说明是真人或者机器人,为0暂时为灵脉使用,直接是怪物组,数据需要自己拼接 netserverName = nil if this.serverName and this.serverName ~= "" then--and this.serverName ~= PlayerManager.serverInfo.name netserverName = 1 end NetManager.RequestPlayerInfo(this._PlayerId, this._Config.formationType,netserverName,0, function(msg) -- 如果是好友更新好友数据 curPlayerName = msg.teamInfo.name GoodFriendManager.UpdateFriendData(this._PlayerId, msg.teamInfo.level, JingJiShouWeiToEn(msg.teamInfo.name) , msg.teamInfo.head, msg.teamInfo.headFrame) this._PlayerData = msg.teamInfo this.RefreshPlayerInfo(msg.teamInfo) local teamInfo = msg.teamInfo.team this.FormationAdapter(teamInfo) -- this.RefreshFunction() this.RefreshBtnShow() end) else --目前只给灵脉,如果还有其他请写明备注 this.extraInfo.Init(this,this.data,_ViewConfig[this._ViewType]) end end -- 刷新基础信息显示 local titleLiveStr local titleLive function this.RefreshPlayerInfo(data) local curname = "" if this.serverName then curname = this.serverName .. " " ..data.name else curname = data.name end this.memName.text = PracticeManager.SetNameColor(curname,data.practiceLevel)--data.name if(data.guildName~="") then this.memProfess.text =Language[10633]..data.guildName--GUILD_GRANT_STR[data.position] else this.memProfess.text =Language[10633]..Language[10086] end -- 头像 if not _PlayerHead then _PlayerHead = SubUIManager.Open(SubUIConfig.PlayerHeadView, this.memHead.transform) end _PlayerHead:Reset() _PlayerHead:SetScale(Vector3.one * 0.85) _PlayerHead:SetHead(data.head) _PlayerHead:SetFrame(data.headFrame) _PlayerHead:SetLevel(data.level) _PlayerHead:SetLayer(this.sortingOrder) _PlayerHead:SetEffectScale(0.9) local title=data.userTitle if title and title>0 then this.titlePar:SetActive(true) LogError("title=="..title) if titleLive then SubUIManager.Close(titleLive) titleLive = nil end if not titleLive then titleLive = SubUIManager.Open(SubUIConfig.PlayerTitle, this.titlePar.transform) titleLive:SetShow(title, Vector3.New(0,0,0), 0.5, 0.03*20, this.sortingOrder) end else this.titlePar:SetActive(false) end end function this:OnSortingOrderChange() if _PlayerHead then _PlayerHead:SetLayer(self.sortingOrder) end for i, demon in ipairs(this.Demons) do Util.SetParticleSortLayer(demon.starGrid,self.sortingOrder + 1) end end -- 刷新功能区 function this.RefreshFunction() this.addFriendBtn:SetActive(false) this.starBox:SetActive(false) if this._ViewType == PLAYER_INFO_VIEW_TYPE.NORMAL or this._ViewType == PLAYER_INFO_VIEW_TYPE.MIND_DEMON then this.addFriendBtn:SetActive(true) local isSelf = this._PlayerId == PlayerManager.uid local isMyFriend = isSelf and true or GoodFriendManager.IsMyFriend(this._PlayerId) local isApplyed = this._PlayerData.isApplyed == 1 Util.SetGray(this.addFriendBtn, isMyFriend or isApplyed) this.addFriendBtnText.text = isApplyed and Language[10816] or Language[10937] end end -- 编队数据匹配 function this.FormationAdapter(teamInfo) this.formationTip.text = _ViewConfig[this._ViewType].tip -- 战斗力 this.memPower.text = teamInfo.totalForce for i, demon in ipairs(this.Demons) do demon.frame.sprite = this.spLoader:LoadSprite(GetQuantityImageByquality(1)) demon.hero:SetActive(false) end --队伍阵容 for i, hero in ipairs(teamInfo.team) do local demonId = teamInfo.team[i].heroTid if demonId then this.Demons[hero.position].hero:SetActive(true) local star,starType = GetStarOrGodSoulLv(1,hero) local starSize = Vector2.New(35,35) local starScale = -8 if starType == 3 then starSize = Vector2.New(1,-15.65) starScale = -13 elseif starType == 2 then starSize = Vector2.New(60,57) end SetHeroStars(this.spLoader, this.Demons[hero.position].starGrid, star,starType,starSize,starScale) Util.SetParticleSortLayer(this.Demons[hero.position].starGrid,this.sortingOrder + 1) local heroConfig = ConfigManager.GetConfigData(ConfigName.HeroConfig, demonId) this.Demons[hero.position].proIcon.sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(heroConfig.PropertyName)) this.Demons[hero.position].levelText.text = hero.level this.Demons[hero.position].frame.sprite = this.spLoader:LoadSprite(GetQuantityImageByquality(heroConfig.Quality, hero.star)) SetHeroIcon(this.spLoader, hero,this.Demons[hero.position].icon,heroConfig) local heroData = {} if this._Config.formationType == FormationTypeDef.FORMATION_TSLX then Util.AddOnceClick(this.Demons[hero.position].frameBtn, function() UIManager.OpenPanel(UIName.RoleGetInfoPopup,false,demonId,hero.star) end) else Util.AddOnceClick(this.Demons[hero.position].frameBtn, function() NetManager.ViewHeroInfoRequest(this._PlayerId,hero.heroid,netserverName,this._Config.formationType,function(msg) if not hero.heroid then return end heroData= GoodFriendManager.GetHeroDatas(msg.hero,msg.force,msg.SpecialEffects,msg.guildSkill) GoodFriendManager.InitEquipData(msg.equip,heroData)--HeroManager.GetSingleHeroData(heroData.dynamicId) UIManager.OpenPanel(UIName.RoleInfoPopup, heroData,true) end) end) end end end local len=#teamInfo.PokemonInfos -- LogError("长度:"..len) if len>0 then this.pokemonObj:SetActive(true) for i, demon in ipairs(this.Pokemons) do demon.gameObject:SetActive(false) Util.GetGameObject(demon, "frame"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetQuantityImageByquality(1)) Util.GetGameObject(demon, "hero"):SetActive(false) end else this.pokemonObj:SetActive(false) end --队伍灵兽 for i, hero in ipairs(teamInfo.PokemonInfos) do local demonId = teamInfo.PokemonInfos[i].heroTid this.Pokemons[i].gameObject:SetActive(true) if demonId then local heroGo = Util.GetGameObject(this.Pokemons[i], "hero") heroGo:SetActive(true) SetHeroStars(this.spLoader, Util.GetGameObject(heroGo, "starGrid"), hero.star) local heroConfig = ConfigManager.GetConfigData(ConfigName.SpiritAnimal, demonId) Util.GetGameObject(heroGo, "lvbg/levelText"):GetComponent("Text").text = hero.level Util.GetGameObject(this.Pokemons[i], "frame"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetQuantityImageByquality(heroConfig.Quality)) Util.GetGameObject(heroGo, "icon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetResourcePath(heroConfig.Icon)) local frameBtn = Util.GetGameObject(this.Pokemons[i], "frame") local heroData = {} Util.AddOnceClick(frameBtn, function() local pokemonData={tempId=demonId,id=demonId,star=hero.star,level=hero.level} UIManager.OpenPanel(UIName.PokemonGetInfoPopup,true,pokemonData) end) end end --神印信息 if teamInfo.sealShow and #teamInfo.sealShow > 0 then this.imprintObj:SetActive(true) if not this.imprintItemList then this.imprintItemList = {} end for i = 1, #this.imprintItemList do this.imprintItemList[i].gameObject:SetActive(false) end for i = 1, #teamInfo.sealShow do local item = this.imprintItemList[i] local value = teamInfo.sealShow[i] if not item then item = newObject(this.imprintPre) item.name = "imprintPre_"..i item.transform:SetParent(this.imprintGrid.transform) item.transform.localScale = Vector3.one item.transform.localPosition = Vector3.zero this.imprintItemList[i] = item end item.gameObject:SetActive(true) local icon = Util.GetGameObject(item,"icon"):GetComponent("Image") icon.sprite = this.spLoader:LoadSprite(GetResourcePath(XiuXianSkillConfig[value.id].Icon)) Util.AddOnceClick(item.gameObject,function () UIManager.OpenPanel(UIName.GeneralInfoPopup,GENERALINFO_TYPE.Imprint,value.id,value.heroTId) end) end else this.imprintObj:SetActive(false) end end -- 刷新按钮显示 function this.RefreshBtnShow() this.btnBox:SetActive(true) -- 按钮功能 local btnType = this._Config.btnType for index, btn in ipairs(this.btnList) do btn:SetActive(btnType[index] ~= nil) if btnType[index] then Util.GetGameObject(btn, "Text"):GetComponent("Text").text = btnType[index].name Util.AddOnceClick(btn, function() local funcType = btnType[index].func if not this.btnFunc[funcType] then Log("方法不存在") return end this.btnFunc[funcType](btnType[index].param) end) end end -- 自己 if this._PlayerId == PlayerManager.uid or curPlayerName == Language[12230] then this.boxLine:SetActive(false) this.btnBox:SetActive(false) this.addFriendBtn:SetActive(false) end -- 判断该界面类型是否有按钮显示 if not this._Config or not this._Config.btnType or isNpc then this.boxLine:SetActive(false) this.btnBox:SetActive(false) this.addFriendBtn:SetActive(false) end this.addFriendBtn:SetActive(this._Config.isAddFriend) --一些按钮需要特殊显示 this.SpecialBtnShow() end function this.SpecialBtnShow() if this._ViewType == PLAYER_INFO_VIEW_TYPE.LINGMAIMIJING then this.btnBox:SetActive(true) local bool = this._PlayerId == PlayerManager.uid if UIManager.IsOpen(UIName.RankingSingleListPanel) then this.btnList[1]:SetActive(not bool) this.btnList[2]:SetActive(false) this.btnList[3]:SetActive(false) else this.btnList[1]:SetActive(not bool) this.btnList[2]:SetActive(not bool) this.btnList[3]:SetActive(bool) end end end ----=============================== 按钮事件================================== -- 举报 function this.Report() Log("举报") end -- 拉黑 function this.AddToBlackList() if not ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.GOODFRIEND) then PopupTipPanel.ShowTip(Language[10828]) return end if table.nums(GoodFriendManager.blackFriendList) >= GoodFriendManager.blackFriendLimit then PopupTipPanel.ShowTip(Language[11503]) return end GoodFriendManager.RequestAddToBlackList(this._PlayerId, function() PopupTipPanel.ShowTip(Language[11504]) this:SetViewType(PLAYER_INFO_VIEW_TYPE.GO_TO_BLACK) end) end -- 移除黑名单 function this.RemoveFromBlackList() if not ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.GOODFRIEND) then PopupTipPanel.ShowTip(Language[10828]) return end GoodFriendManager.RequestDeleteFromBlackList(this._PlayerId, function() PopupTipPanel.ShowTip(Language[11505]) this:ClosePanel() end) end -- 移除黑名单 function this.GoToBlack() if not ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.GOODFRIEND) then PopupTipPanel.ShowTip(Language[10828]) return end this:ClosePanel() UIManager.OpenPanel(UIName.GoodFriendMainPanel, true, 4) end -- 打他 function this.BeatHim() this:ClosePanel() UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.PLAY, this._PlayerData) end -- 跨服天梯 function this.JumpServerBattle() this:ClosePanel() UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.JUMPSERVER_HIGHTLADDER,true, this._PlayerData) end -- 跨服天梯 function this.JumpServerBattle_NORMAL() this:ClosePanel() UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.PLAY, this._PlayerData,true) end --灵脉秘境 function this.LingMaiFormaion() this:ClosePanel() LogRed("data,Id:"..tostring(this.data)) UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.LINGMAIMIJING, this.data) end --界面关闭时调用(用于子类重写) function PlayerInfoPopup:OnClose() this.imprintObj:SetActive(false) JumpServerManager.SetCurPersonInfo(nil) if titleLive then SubUIManager.Close(titleLive) titleLive = nil end end --界面销毁时调用(用于子类重写) function PlayerInfoPopup:OnDestroy() this.spLoader:Destroy() -- 头像 if _PlayerHead then _PlayerHead:Recycle() _PlayerHead = nil end titleLive = nil titleLiveStr = nil this.imprintItemList = {} this.Demons = {} if this.extraInfo then this.extraInfo.OnDestroy() end end return PlayerInfoPopup