---@class WB_ShootingTarget_C:UUserWidget ---@field ShowAddScore UWidgetAnimation ---@field HorizontalBox_OtherPlayerScore UHorizontalBox ---@field TextBlock_AddScore UTextBlock ---@field TextBlock_HitScore UTextBlock --Edit Below-- local WB_ShootingTarget = { bInitDoOnce = false; NowScore = 0; TargetScore = -1; AllPlayerKey = {}; }; function WB_ShootingTarget:Construct() end function WB_ShootingTarget:OnShowPanel() -- self.TargetScore = MiniGameConfig.MiniGameInfo[MiniGameConfig.MiniGameType.ShootingTarget].GameParam.TargetHitScore self.TextBlock_HitScore:SetText("0") UGCEventSystem.AddListener(EventEnum.UpdateShootingTargetScore, self.UpdateShootingTargetScore, self) end function WB_ShootingTarget:OnClosePanel() UGCEventSystem.RemoveListener(EventEnum.UpdateShootingTargetScore, self.UpdateShootingTargetScore, self) end -- function WB_ShootingTarget:Tick(MyGeometry, InDeltaTime) -- end -- function WB_ShootingTarget:Destruct() -- end function WB_ShootingTarget:UpdateShootingTargetScore(PlayerScores) local LocalPlayerKey = UGCSystemLibrary.GetLocalPlayerKey() local LocalPlayerScore = PlayerScores[LocalPlayerKey] if LocalPlayerScore and self.NowScore ~= LocalPlayerScore then local AddScore = LocalPlayerScore - self.NowScore self.NowScore = LocalPlayerScore if AddScore > 0 then self.TextBlock_AddScore:SetText(string.format("+ %s", tostring(AddScore))) else self.TextBlock_AddScore:SetText(string.format("- %s", tostring(-AddScore))) end self:PlayAnimation(self.ShowAddScore, 0, 1, EUMGSequencePlayMode.Forward, 1.) self.TextBlock_HitScore:SetText(tostring(self.NowScore)) end if #self.AllPlayerKey ~= table.getCount(PlayerScores) - 1 then self:UpdatePlayerKeys(table.getKeys(PlayerScores)) end self:UpdateOtherPlayer(PlayerScores) end function WB_ShootingTarget:UpdatePlayerKeys(InAllPlayerKey) self.AllPlayerKey = InAllPlayerKey table.removeValue(self.AllPlayerKey, UGCSystemLibrary.GetLocalPlayerKey()) for i = 1, self.HorizontalBox_OtherPlayerScore:GetChildrenCount() do local Item = self.HorizontalBox_OtherPlayerScore:GetChildAt(i - 1) Item:SetPlayerKey(self.AllPlayerKey[i]) end end function WB_ShootingTarget:UpdateOtherPlayer(PlayerScores) for i = 1, self.HorizontalBox_OtherPlayerScore:GetChildrenCount() do local Item = self.HorizontalBox_OtherPlayerScore:GetChildAt(i - 1) Item:UpdatePlayerScore(PlayerScores[Item:GetPlayerKey()]) end end return WB_ShootingTarget;