require("Base/BasePanel") TopMatchPlayBattleAinSelectPopup = Inherit(BasePanel) local this = TopMatchPlayBattleAinSelectPopup local resultRes = { [0] = "UI_effect_JJC_JieSuan_ShiBai_png_zh", [1] = "UI_effect_JJC_JieSuan_ShengLi_png_zh", } --初始化组件(用于子类重写) function TopMatchPlayBattleAinSelectPopup:InitComponent() this.btnBack = Util.GetGameObject(self.transform, "btnBack") this.title = Util.GetGameObject(self.transform, "Title"):GetComponent("Text") this.battleRecord = {} for i = 1, 3 do this.battleRecord[i] = Util.GetGameObject(self.transform, "content/pre ("..i..")") end this.playerHead={}--玩家头像列表 end --绑定事件(用于子类重写) function TopMatchPlayBattleAinSelectPopup:BindEvent() Util.AddClick(this.btnBack, function () self:ClosePanel() end) end --添加事件监听(用于子类重写) function TopMatchPlayBattleAinSelectPopup:AddListener() end --移除事件监听(用于子类重写) function TopMatchPlayBattleAinSelectPopup:RemoveListener() end --界面打开时调用(用于子类重写) function TopMatchPlayBattleAinSelectPopup:OnOpen(v) this.title.text = Language[10139] for i = 1, 3 do local curPre = this.battleRecord[i] if curPre then if #v >= i then curPre:SetActive(true) this.SetPreShow(i,curPre,v[i]) else curPre:SetActive(false) end end end end function this.SetPreShow(index,curPre,v) Util.GetGameObject(curPre, "titleText"):GetComponent("Text").text = string.format(Language[10142], index) Util.AddOnceClick(Util.GetGameObject(curPre, "PlayBackBtn"), function () this.SetPlayBack(v.fightResult,v.id,v.defInfo,v.attackInfo) end) this.SetHead( Util.GetGameObject(curPre, "attackInfo"),v.attackInfo,v.fightResult == 1) this.SetHead(Util.GetGameObject(curPre, "defInfo"),v.defInfo,v.fightResult == 0) end function this.SetHead(curPre,data,isShowWinImage) local head= Util.GetGameObject(curPre,"head") local name= Util.GetGameObject(curPre,"nameBg/Text"):GetComponent("Text") local winOrFail= Util.GetGameObject(curPre,"winOrFail"):GetComponent("Image") if isShowWinImage then winOrFail.sprite = Util.LoadSprite(resultRes[1]) else winOrFail.sprite = Util.LoadSprite(resultRes[0]) end if data then if not this.playerHead[curPre] then this.playerHead[curPre] = CommonPool.CreateNode(POOL_ITEM_TYPE.PLAYER_HEAD,head) end this.playerHead[curPre]:Reset() this.playerHead[curPre]:SetScale(Vector3.one) this.playerHead[curPre]:SetHead(data.head) this.playerHead[curPre]:SetFrame(data.headFrame) this.playerHead[curPre]:SetLevel(data.level) this.playerHead[curPre]:SetLayer(this.sortingOrder) name.text=data.name Util.AddOnceClick(head,function() UIManager.OpenPanel(UIName.PlayerInfoPopup, data.uid) end) else if this.playerHead[curPre] then this.playerHead[curPre] = nil end name.text="" end end --设置战斗回放按钮 function this.SetPlayBack(fightResult, id, defInfo, attackInfo) if fightResult == -1 then return end -- playBackBtn:SetActive(_IsShowData and fightResult~=-1) -- Util.AddOnceClick(playBackBtn,function() ArenaTopMatchManager.RequestRecordFightData(fightResult,id, attackInfo.name.."|"..defInfo.name,function() --构建显示结果数据(我永远在蓝方) local arg = {} arg.panelType = 1 arg.result = fightResult arg.blue = {} arg.blue.uid = attackInfo.uid arg.blue.name = attackInfo.name arg.blue.head = attackInfo.head arg.blue.frame = attackInfo.headFrame arg.red = {} arg.red.uid = defInfo.uid arg.red.name = defInfo.name arg.red.head = defInfo.head arg.red.frame = defInfo.headFrame UIManager.OpenPanel(UIName.ArenaResultPopup, arg) end) -- end) end --界面关闭时调用(用于子类重写) function TopMatchPlayBattleAinSelectPopup:OnClose() end --界面销毁时调用(用于子类重写) function TopMatchPlayBattleAinSelectPopup:OnDestroy() end return TopMatchPlayBattleAinSelectPopup