@@ -14,33 +14,34 @@ public class PostGameUI : MonoBehaviour
1414 {
1515 [ SerializeField ]
1616 UIDocument m_PostGameUIDocument ;
17-
18- [ SerializeField ]
19- UIDocument m_MessageFeedDocument ;
2017
2118 ServerPostGameState m_PostGameState ;
22-
19+
2320 Label m_WinEndMessage ;
2421 Label m_LoseGameMessage ;
2522 Button m_ReplayButton ;
26- Button m_WaitOnHostMsg ;
23+ Button m_WaitOnHostButton ;
24+ Button m_MainMenuButton ;
25+
2726 VisualElement m_MessageFeed ;
2827 ListView m_MessageList ;
29- /*VisualElement m_SceneLight;
30- Color m_WinLightColor;
31- Color m_LoseLightColor;*/
3228
3329 void Awake ( )
3430 {
3531 var root = m_PostGameUIDocument . rootVisualElement ;
36-
32+
3733 m_WinEndMessage = root . Q < Label > ( "gameWinText" ) ;
3834 m_LoseGameMessage = root . Q < Label > ( "gameLostText" ) ;
3935 m_ReplayButton = root . Q < Button > ( "playAgainBtn" ) ;
40- m_WaitOnHostMsg = root . Q < Button > ( "waitOnHostBtn" ) ;
41-
42- m_WinEndMessage . style . display = DisplayStyle . None ;
43- m_LoseGameMessage . style . display = DisplayStyle . None ;
36+ m_WaitOnHostButton = root . Q < Button > ( "waitOnHostBtn" ) ;
37+ m_MainMenuButton = root . Q < Button > ( "menuBtn" ) ;
38+
39+ m_WaitOnHostButton . SetEnabled ( false ) ;
40+ m_ReplayButton . SetEnabled ( true ) ;
41+ m_MainMenuButton . SetEnabled ( true ) ;
42+
43+ m_ReplayButton . clicked += OnPlayAgainClicked ;
44+ m_MainMenuButton . clicked += OnMainMenuClicked ;
4445 }
4546
4647 [ Inject ]
@@ -54,14 +55,16 @@ public void Initialize(bool isHost)
5455 // only hosts can restart the game, other players see a wait message
5556 if ( isHost )
5657 {
57- m_ReplayButton . SetEnabled ( true ) ;
58- m_WaitOnHostMsg . SetEnabled ( false ) ;
58+ m_ReplayButton . style . display = DisplayStyle . Flex ;
59+ m_WaitOnHostButton . style . display = DisplayStyle . None ;
60+ m_MainMenuButton . style . display = DisplayStyle . Flex ;
5961 }
60-
62+
6163 else
6264 {
63- m_ReplayButton . SetEnabled ( false ) ;
64- m_WaitOnHostMsg . SetEnabled ( true ) ;
65+ m_ReplayButton . style . display = DisplayStyle . None ;
66+ m_WaitOnHostButton . style . display = DisplayStyle . Flex ;
67+ m_MainMenuButton . style . display = DisplayStyle . Flex ;
6568 }
6669 }
6770
@@ -88,14 +91,11 @@ void SetPostGameUI(WinState winState)
8891 {
8992 switch ( winState )
9093 {
91- // Set end message and background color based last game outcome
9294 case WinState . Win :
93- // m_SceneLight.color = m_WinLightColor;
9495 m_WinEndMessage . SetEnabled ( true ) ;
9596 m_LoseGameMessage . SetEnabled ( false ) ;
9697 break ;
9798 case WinState . Loss :
98- //m_SceneLight.color = m_LoseLightColor;
9999 m_WinEndMessage . SetEnabled ( false ) ;
100100 m_LoseGameMessage . SetEnabled ( true ) ;
101101 break ;
@@ -115,4 +115,4 @@ public void OnMainMenuClicked()
115115 m_PostGameState . GoToMainMenu ( ) ;
116116 }
117117 }
118- }
118+ }
0 commit comments