require("Base/BasePanel") local PlayerInfoPopup = Inherit(BasePanel) local this = PlayerInfoPopup local _ViewConfig = { [PLAYER_INFO_VIEW_TYPE.NORMAL] = { formationType = FormationTypeDef.FORMATION_NORMAL, tip = Language[10952], btnType = { --{name = "举 报", func = 1}, {name = Language[11580], func = 2}, {name = Language[11581], func = 3}, } }, [PLAYER_INFO_VIEW_TYPE.BLACK_REMOVE] = { formationType = FormationTypeDef.FORMATION_NORMAL, tip = Language[10952], btnType = { {name = Language[11582], func = 4}, } }, [PLAYER_INFO_VIEW_TYPE.GO_TO_BLACK] = { formationType = FormationTypeDef.FORMATION_NORMAL, tip = Language[10952], btnType = { {name = Language[11583], func = 5}, } }, [PLAYER_INFO_VIEW_TYPE.ARENA] = { formationType = FormationTypeDef.FORMATION_ARENA_DEFEND, tip = Language[11584], }, } local _PlayerHead = nil --初始化组件(用于子类重写) function PlayerInfoPopup:InitComponent() this.btnBack = Util.GetGameObject(self.transform, "btnClose") this.memHead = Util.GetGameObject(self.transform, "tipImage/panel/info/head") this.memName = Util.GetGameObject(self.transform, "tipImage/panel/info/name"):GetComponent("Text") this.memProfessTip = Util.GetGameObject(self.transform, "tipImage/panel/info/professName"):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.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.DiffDemons = {} -- for i = 1, 3 do -- table.insert(this.DiffDemons, Util.GetGameObject(self.gameObject, "tipImage/panel/defendbox/diffdemons/icon_"..i)) -- end this.Demons = {} for i = 1, 6 do table.insert(this.Demons, Util.GetGameObject(self.gameObject, "tipImage/panel/defendbox/Demons/heroPro (" .. i .. ")")) end this.boxLine = Util.GetGameObject(self.transform, "tipImage/panel/defendbox/line") this.btnBox = Util.GetGameObject(self.transform, "tipImage/panel/box") 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") end --绑定事件(用于子类重写) function PlayerInfoPopup:BindEvent() Util.AddClick(this.btnBack, 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[10817]) return end if this._PlayerId == PlayerManager.uid then PopupTipPanel.ShowTip(Language[10950]) return end if GoodFriendManager.IsMyFriend(this._PlayerId) then PopupTipPanel.ShowTip(Language[10951]) return end if this._PlayerData.isApplyed == 1 then PopupTipPanel.ShowTip(Language[10822]) return end GoodFriendManager.InviteFriendRequest(this._PlayerId, function() PopupTipPanel.ShowTip(Language[11585]) this._PlayerData.isApplyed = 1 this.RefreshFunction() end) end) end --添加事件监听(用于子类重写) function PlayerInfoPopup:AddListener() end --移除事件监听(用于子类重写) function PlayerInfoPopup:RemoveListener() end --界面打开时调用(用于子类重写) function PlayerInfoPopup:OnOpen(playerId, viewType) this._PlayerId = playerId this._ViewType = viewType or PLAYER_INFO_VIEW_TYPE.NORMAL -- 界面类型修正 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, } 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(this._PlayerId.." "..this._Config.formationType) NetManager.RequestPlayerInfo(this._PlayerId, this._Config.formationType, function(msg) -- 如果是好友更新好友数据 GoodFriendManager.UpdateFriendData(this._PlayerId, msg.teamInfo.level, 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() end) end -- 刷新基础信息显示 function this.RefreshPlayerInfo(data) this.memName.text = data.name this.memProfessTip.text = Language[10629] if(data.guildName~="") then this.memProfess.text =data.guildName--GUILD_GRANT_STR[data.position] else this.memProfess.text =Language[10094] 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) end -- 刷新功能区 function this.RefreshFunction() this.addFriendBtn:SetActive(false) this.starBox:SetActive(false) if this._ViewType == PLAYER_INFO_VIEW_TYPE.NORMAL 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[10819] or Language[10956] 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 Util.GetGameObject(demon, "frame"):GetComponent("Image").sprite = Util.LoadSprite(GetQuantityImageByquality(1)) Util.GetGameObject(demon, "hero"):SetActive(false) end for i, hero in ipairs(teamInfo.team) do local demonId = teamInfo.team[i].heroTid if demonId then local heroGo = Util.GetGameObject(this.Demons[hero.position], "hero") heroGo:SetActive(true) SetHeroStars(Util.GetGameObject(heroGo, "starGrid"), hero.star) local heroConfig = ConfigManager.GetConfigData(ConfigName.HeroConfig, demonId) Util.GetGameObject(heroGo, "proIcon"):GetComponent("Image").sprite = Util.LoadSprite(GetProStrImageByProNum(heroConfig.PropertyName)) Util.GetGameObject(heroGo, "lvbg/levelText"):GetComponent("Text").text = hero.level Util.GetGameObject(this.Demons[hero.position], "frame"):GetComponent("Image").sprite = Util.LoadSprite(GetQuantityImageByquality(heroConfig.Quality)) Util.GetGameObject(heroGo, "icon"):GetComponent("Image").sprite = Util.LoadSprite(GetResourcePath(heroConfig.Icon)) local frameBtn = Util.GetGameObject(this.Demons[hero.position], "frame") local heroData = {} Util.AddOnceClick(frameBtn, function() NetManager.ViewHeroInfoRequest(this._PlayerId,hero.heroid,function(msg) 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 -- for i, demon in ipairs(this.Demons) do -- if(teamInfo.team[i]) then -- demon:SetActive(true) -- local roleLevel=Util.GetGameObject(demon, "lvbg/levelText"):GetComponent("Text") -- local frameBtn=Util.GetGameObject(demon, "frame") -- local hpSlider = Util.GetGameObject(demon, "Slider") -- hpSlider:SetActive(false) -- if demonId then -- demon:SetActive(true) -- local demonData = ConfigManager.GetConfigData(ConfigName.HeroConfig, demonId) -- Util.GetGameObject(demon, "icon"):GetComponent("Image").sprite = Util.LoadSprite(GetResourcePath(demonData.Icon)) -- Util.GetGameObject(demon, "frame"):GetComponent("Image").sprite = Util.LoadSprite(GetHeroQuantityImageByquality(ConfigManager.GetConfigData(ConfigName.HeroConfig,teamInfo.team[i].heroTid).Star)) -- SetHeroStars(starGrid, teamInfo.team[i].star) -- proImage.sprite = Util.LoadSprite(GetProStrImageByProNum(demonData.PropertyName)) -- -- posImage.sprite=Util.LoadSprite() -- -- LogRed(tostring(teamInfo.position)) -- -- posImage.sprite = Util.LoadSprite(GetJobSpriteStrByJobNum(demonData.Profession)) -- -- heroStage.sprite = Util.LoadSprite(HeroStageSprite[demonData.HeroStage]) -- roleLevel.text=teamInfo.team[i].level -- --if effectLayer > 0 then -- -- self.UI_Effect_Kuang_JinSe:SetActive(_itemData.configData.Star == 5 or _itemData.configData.Star == 7) -- -- self.UI_Effect_Kuang_HongSe:SetActive(_itemData.configData.Star == 6) -- --end -- local heroData = {} -- Util.AddOnceClick(frameBtn, function() -- NetManager.ViewHeroInfoRequest(this._PlayerId,teamInfo.team[i].heroid,function(msg) -- 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 -- else -- demon:SetActive(false) -- end -- end -- 异妖 -- for i, diffDemon in ipairs(this.DiffDemons) do -- local demonId = teamInfo.PokemonInfos[i] -- if demonId then -- diffDemon:SetActive(true) -- local resId = ConfigManager.GetConfigData(ConfigName.DifferDemonsConfig, demonId).LiveIcon -- diffDemon:GetComponent("Image").sprite = Util.LoadSprite(GetResourcePath(resId)) -- else -- diffDemon:SetActive(false) -- end -- end end -- 刷新按钮显示 function this.RefreshBtnShow() -- 自己 if this._PlayerId == PlayerManager.uid then this.boxLine:SetActive(false) this.btnBox:SetActive(false) return end -- 判断该界面类型是否有按钮显示 if not this._Config or not this._Config.btnType then this.boxLine:SetActive(false) this.btnBox:SetActive(false) return end -- 有按钮显示 local btnType = this._Config.btnType this.boxLine:SetActive(true) this.btnBox:SetActive(true) 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(Language[10957]) return end this.btnFunc[funcType](btnType[index].param) end) end end end ----=============================== 按钮事件================================== -- 举报 function this.Report() Log(Language[11586]) end -- 拉黑 function this.AddToBlackList() if not ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.GOODFRIEND) then PopupTipPanel.ShowTip(Language[10835]) return end if table.nums(GoodFriendManager.blackFriendList) >= GoodFriendManager.blackFriendLimit then PopupTipPanel.ShowTip(Language[11587]) return end GoodFriendManager.RequestAddToBlackList(this._PlayerId, function() PopupTipPanel.ShowTip(Language[11588]) 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[10835]) return end GoodFriendManager.RequestDeleteFromBlackList(this._PlayerId, function() PopupTipPanel.ShowTip(Language[11589]) this:ClosePanel() end) end -- 移除黑名单 function this.GoToBlack() if not ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.GOODFRIEND) then PopupTipPanel.ShowTip(Language[10835]) return end this:ClosePanel() UIManager.OpenPanel(UIName.GoodFriendMainPanel, true, 4) end -- 打他 function this.BeatHim() this:ClosePanel() UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.PLAY, this._PlayerId) end --界面关闭时调用(用于子类重写) function PlayerInfoPopup:OnClose() end --界面销毁时调用(用于子类重写) function PlayerInfoPopup:OnDestroy() -- 头像 if _PlayerHead then _PlayerHead:Recycle() _PlayerHead = nil end end return PlayerInfoPopup