local UIHeroMatch1v1Summary = UIViewClass() local AUTO_CLOSED_COUNTDOWN = DataSheetManager.ConstData:GetDataByID("HeroMatch1v1Interface4").IntValue function UIHeroMatch1v1Summary:OnOpened(context) self:RefreshPanelInfo(context) UIUtils.SetLabel(self.txt_CountDown, string.FormatByIdsId(Const_IDS["IDS_HeroMatch1v1_LeaveTimeOut"], AUTO_CLOSED_COUNTDOWN)) self:StartRepeatFunc(self.RefreshCountDown, 1, -1) end function UIHeroMatch1v1Summary:RefreshCountDown(deltaTime, timeSinceUpdate) if timeSinceUpdate >= AUTO_CLOSED_COUNTDOWN then self:OnButtonClicked(self.sprite_bg) return end UIUtils.SetLabel(self.txt_CountDown, string.FormatByIdsId(Const_IDS["IDS_HeroMatch1v1_LeaveTimeOut"], math.ceil(AUTO_CLOSED_COUNTDOWN - timeSinceUpdate))) end function UIHeroMatch1v1Summary:RefreshPanelInfo(result) -- 是否胜利 self.state:SetState(result.isWin and 0 or 1) -- 设置双方玩家头像 self:SetHeroMatchBattlePlayerInfo(self.group_PlayerInfo1, result.LeftInfo.PlayerInfo) self:SetHeroMatchBattlePlayerInfo(self.group_PlayerInfo2, result.RightInfo.PlayerInfo) -- 设置双方回合结果 self:SetMatchRoundResult(self.group_MyInfo, result.LeftInfo.BattleResult) self:SetMatchRoundResult(self.group_EnemyInfo, result.RightInfo.BattleResult) -- 设置每回合胜利失败 self:SetWinEachRound(self.group_Result, result.LeftInfo.BattleResult) UIUtils.SetLabel(self.txt_TotalScore, result.LeftInfo.score .. ":" .. result.RightInfo.score) end function UIHeroMatch1v1Summary:SetWinEachRound(collection, battleInfo) for i, v in ipairs(collection) do local info = battleInfo[i] if info then UIUtils.SetActive(v.gameObject, true) v.StateSwitch:SetState(info.isWin and 0 or 1) else UIUtils.SetActive(v.gameObject, false) end end end function UIHeroMatch1v1Summary:SetMatchRoundResult(collection, battleInfo) for i, v in ipairs(collection) do local info = battleInfo[i] if info then UIUtils.SetActive(v.gameObject, true) if info.heroId > 0 then UTL.Item.ItemSquareItemIconByHeroId(info.heroId, v.head1.img_Item, v.head1.sprite_Rank, nil, info.mainHeroAwaken) UIUtils.SetActive(v.head1.group_HeroEmpty.gameObject, false) else UIUtils.SetActive(v.head1.group_HeroEmpty.gameObject, true) end if info.viceHeroId > 0 then UTL.Item.ItemSquareItemIconByHeroId(info.viceHeroId, v.head2.img_Item, v.head2.sprite_Rank, nil, info.viceHeroAwaken) UIUtils.SetActive(v.head2.group_HeroEmpty.gameObject, false) else UIUtils.SetActive(v.head2.group_HeroEmpty.gameObject, true) end UIUtils.SetActive(v.head1.group_Shard, false) UIUtils.SetActive(v.head2.group_Shard, false) local _, percentStr = CTL.HeroMatch1v1.GetLeftHpPercentStr(info.leftHp, info.maxHp, nil) UIUtils.SetLabel(v.txt_Number, percentStr) else UIUtils.SetActive(v.gameObject, false) end end end function UIHeroMatch1v1Summary:OnBackButtonPressed() self:OnButtonClicked(self.sprite_bg) end function UIHeroMatch1v1Summary:OnButtonClicked(comp) if comp == self.sprite_bg then self:CloseView() MDL.Level.SendRoleLeaveFuben() end end function UIHeroMatch1v1Summary:SetHeroMatchBattlePlayerInfo(playerComp, headInfo) -- 设置头像 CTL.Character.SetPortraitAndFrame(playerComp.PlayerHead, headInfo.portraitId, headInfo.frameId) -- 名字 UIUtils.SetLabel(playerComp.txt_PlayerName, headInfo.name .. " " .. CTL.CrossServer.GetServerShowStr(headInfo.serId)) -- 设置军团标记 if string.isNilOrEmpty(headInfo.guildEmblemContent) then UIUtils.SetActive(playerComp.group_GuildNameIcon.gameObject, false) else UIUtils.SetActive(playerComp.group_GuildNameIcon.gameObject, true) if not string.isNilOrEmpty(headInfo.guildEmblemContent) then UIUtils.SetLabel(playerComp.txt_GuildNameInitiate, headInfo.guildEmblemContent) UIUtils.SetLabel(playerComp.txt_GuildName, headInfo.guildName) local guildEmblemCfg = DataSheetManager.GuildEmblem:GetDataByID(headInfo.guildEmblemFrame) if guildEmblemCfg then UTL.Item.SetAtlasSprite(playerComp.img_GuildIcon, "UI_Guild", guildEmblemCfg.Image) end end end -- 设置官职 UIUtils.SetLabel(playerComp.txt_Position, headInfo.officialPosition > 0 and CTL.OfficialPosition.GetModelNameShow(headInfo.officialPosition) or "") end return UIHeroMatch1v1Summary