---@class WB_RoundFinish_C:UUserWidget ---@field Button_Collect UButton ---@field Button_Like UButton ---@field Image_1 UImage ---@field Image_Scene UImage ---@field ScrollBox_ItemsInfo UScrollBox ---@field TextBlock_LikeCount UTextBlock ---@field WidgetSwitcher_Collect UWidgetSwitcher ---@field WidgetSwitcher_IsWin UWidgetSwitcher ---@field WidgetSwitcher_Like UWidgetSwitcher --Edit Below-- local WB_RoundFinish = { bInitDoOnce = false; IsLiked = false; NowDefender = -1; }; function WB_RoundFinish:Construct() WidgetLibrary.BindButtonClicked(self.Button_Collect, self.Collect, self) WidgetLibrary.BindButtonClicked(self.Button_Like, self.Like, self) UGCEventSystem.AddListener(EventEnum.UpdateLastPlayMapInfo, self.UpdateLikeCount, self) UGCEventSystem.AddListener(ArchiveDataConfig.GetParamNotifyEvent(ArchiveDataConfig.EArchiveType.Like), self.UpdateLikeCount, self) for i, v in pairs(EPlaceItemType) do local Item = UserWidget.NewWidgetObjectBP(UGCSystemLibrary.GetLocalPlayerController(), self:GetPlaceItemCountInfoClass()); self.ScrollBox_ItemsInfo:AddChild(Item) Item:Init(v) end end function WB_RoundFinish:OnShowPanel(IsAttackerWin, InCode) self.bIsAttacker = (UGCGameSystem.GameState:GetNowDefender() ~= UGCSystemLibrary.GetLocalPlayerKey()) UGCLogSystem.Log("[WB_RoundFinish_OnShowPanel] IsAttackerWin:%s, bIsAttacker:%s", tostring(IsAttackerWin), tostring(self.bIsAttacker)) self.IsLiked = false self.WidgetSwitcher_Collect:SetActiveWidgetIndex(0) self.WidgetSwitcher_Like:SetActiveWidgetIndex(0) if self.bIsAttacker == IsAttackerWin then self.WidgetSwitcher_IsWin:SetActiveWidgetIndex(0) else self.WidgetSwitcher_IsWin:SetActiveWidgetIndex(1) end if not self.bIsAttacker then self.Button_Collect:SetVisibility(ESlateVisibility.Collapsed) self.Button_Like:SetVisibility(ESlateVisibility.Collapsed) else self.Button_Collect:SetVisibility(ESlateVisibility.Visible) self.Button_Like:SetVisibility(ESlateVisibility.Visible) end -- 获取场景捕获摄像机,此处为了防止切换场景而导致指针失效 local CaptureCamera = UGCSystemLibrary.GetUniqueInstanceFromPath(UGCGameSystem.GetUGCResourcesFullPath('Asset/Blueprint/SceneActor/Capture/BP_CaptureCamera.BP_CaptureCamera_C')) -- 刷新图片 if CaptureCamera then CaptureCamera:UpdateScenePic() end local DecodeResType, PlaceItemCount = PlacementModeConfig.GetPlaceCodeHaveItemCont(InCode) if DecodeResType == PlacementModeConfig.EPlaceDecodeCallback.Succeed then for i = 1, self.ScrollBox_ItemsInfo:GetChildrenCount() do local Item = self.ScrollBox_ItemsInfo:GetChildAt(i - 1) local Count = PlaceItemCount[Item:GetPlaceItemType()] if Count then Item:SetCount(Count) Item:SetVisibility(ESlateVisibility.HitTestInvisible) else Item:SetVisibility(ESlateVisibility.Collapsed) end end end end function WB_RoundFinish:GetPlaceItemCountInfoClass() if self.PlaceItemCountInfoClass == nil then self.PlaceItemCountInfoClass = UE.LoadClass(UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/StatusUI/Round/WB_PlaceItemCountInfo.WB_PlaceItemCountInfo_C')) end return self.PlaceItemCountInfoClass end function WB_RoundFinish:Like() if self.IsLiked then return end self.IsLiked = true self.WidgetSwitcher_Like:SetActiveWidgetIndex(1) UGCSendRPCSystem.ActorRPCNotify(nil, UGCGameSystem.GameState, "AddLike", UGCSystemLibrary.GetLocalPlayerKey()) end function WB_RoundFinish:Collect() self.WidgetSwitcher_Collect:SetActiveWidgetIndex(1) UGCSendRPCSystem.ActorRPCNotify(nil, UGCGameSystem.GameState, "SaveNowPlayMap", UGCSystemLibrary.GetLocalPlayerKey()) end function WB_RoundFinish:UpdateLikeCount() self.NowDefender = UGCGameSystem.GameState.LastPlayMapInfo.LastPlayerKey local LikeCount = ArchiveDataConfig.GetPlayerArchiveDataFromType(self.NowDefender, ArchiveDataConfig.EArchiveType.Like) if LikeCount == nil then LikeCount = 0 end self.TextBlock_LikeCount:SetText(LikeCount) end -- function WB_RoundFinish:Tick(MyGeometry, InDeltaTime) -- end -- function WB_RoundFinish:Destruct() -- end return WB_RoundFinish;