local UIHeroMatch1v1MatchPanel = UIViewClass() local AUTO_CLOSED_COUNTDOWN = DataSheetManager.ConstData:GetDataByID("HeroMatch1v1Interface1").IntValue function UIHeroMatch1v1MatchPanel:OnOpened(context) self:RefreshBothHeroInfo(context.lineUpHeroIds1, context.lineUpHeroAwakens1, context.lineUpHeroIds2, context.lineUpHeroAwakens2) self:RefreshBothPlayerInfo(context.showInfo1, context.showInfo2) self:StartRepeatFunc(self.RefreshCountDown, 1, -1) UIUtils.SetLabel(self.txt_CountDown, string.FormatByIdsId(Const_IDS["IDS_HeroMatch1v1_MatchSuccess"], AUTO_CLOSED_COUNTDOWN)) end function UIHeroMatch1v1MatchPanel:RefreshCountDown(deltaTime, timeSinceUpdate) local remainCountDown = math.ceil(AUTO_CLOSED_COUNTDOWN - timeSinceUpdate) if timeSinceUpdate >= AUTO_CLOSED_COUNTDOWN then return end CTL.Sound.PlayCountDown(remainCountDown) UIUtils.SetLabel(self.txt_CountDown, string.FormatByIdsId(Const_IDS["IDS_HeroMatch1v1_MatchSuccess"], remainCountDown)) end function UIHeroMatch1v1MatchPanel:RefreshBothHeroInfo(lineup1, lineUpHeroAwakens1, lineup2, lineUpHeroAwakens2) self:SetHeroInfo(self.my_HeadCollection, lineup1, lineUpHeroAwakens1) self:SetHeroInfo(self.enemy_HeadCollection, lineup2, lineUpHeroAwakens2) end function UIHeroMatch1v1MatchPanel:RefreshBothPlayerInfo(player1Info, player2Info) self:SetPlayerInfo(self.group_PlayerInfo1, player1Info) self:SetPlayerInfo(self.group_PlayerInfo2, player2Info) end function UIHeroMatch1v1MatchPanel:SetPlayerInfo(playerComp, headInfo) -- 设置头像 CTL.Character.SetPortraitAndFrame(playerComp.PlayerHead, headInfo.PortraitId, headInfo.FrameId) -- 名字 UIUtils.SetLabel(playerComp.txt_PlayerName, headInfo.name .. " " .. CTL.CrossServer.GetServerShowStr(headInfo.ShowServerId)) if headInfo.OfficialId < 0 and string.isNilOrEmpty(headInfo.EmblemContent) then UIUtils.SetActive(playerComp.group_GuildName, false) else UIUtils.SetActive(playerComp.group_GuildName, true) -- 设置军团标记 if string.isNilOrEmpty(headInfo.EmblemContent) then UIUtils.SetActive(playerComp.group_GuildNameIcon.gameObject, false) else UIUtils.SetActive(playerComp.group_GuildNameIcon.gameObject, true) UIUtils.SetLabel(playerComp.txt_GuildNameInitiate, headInfo.EmblemContent) UIUtils.SetLabel(playerComp.txt_GuildName, headInfo.guildName) local guildEmblemCfg = DataSheetManager.GuildEmblem:GetDataByID(headInfo.EmblemFrame) if guildEmblemCfg then UTL.Item.SetAtlasSprite(playerComp.img_GuildIcon, "UI_Guild", guildEmblemCfg.Image) end end -- 设置官职 UIUtils.SetLabel(playerComp.txt_Position, headInfo.OfficialId > 0 and CTL.OfficialPosition.GetModelNameShow(headInfo.OfficialId) or "") end end function UIHeroMatch1v1MatchPanel:SetHeroInfo(compCollection, heroInfos, isAwakens) for i, heroID in ipairs(heroInfos) do UIUtils.SetActive(compCollection[i].group_Shard, false) if heroID > 0 then UIUtils.SetActive(compCollection[i].group_HeroEmpty.gameObject, false) UTL.Item.ItemSquareItemIconByHeroId(heroID, compCollection[i].img_Item, compCollection[i].sprite_Rank, nil, isAwakens[i]) UTL.Item.SetItemCount(compCollection[i]) else UIUtils.SetActive(compCollection[i].group_HeroEmpty.gameObject, true) end end end return UIHeroMatch1v1MatchPanel