File tree 1 file changed +51
-0
lines changed
1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change
1
+ using TMPro ;
2
+ using UnityEngine ;
3
+
4
+ public class PlayerKilledUI : MonoBehaviour
5
+ {
6
+ [ SerializeField ] private CameraLogic cameraLogic ;
7
+ [ SerializeField ] private TextMeshProUGUI playerKilledText ;
8
+ [ SerializeField ] private GameObject panel ;
9
+
10
+ void Start ( )
11
+ {
12
+ panel . SetActive ( false ) ;
13
+ }
14
+
15
+ void Update ( )
16
+ {
17
+ HandlePlayerKillUI ( ) ;
18
+ }
19
+
20
+ private void HandlePlayerKillUI ( )
21
+ {
22
+ if ( cameraLogic == null ) return ;
23
+
24
+ bool isPlayer1Assigned = cameraLogic . player1 != null ;
25
+ bool isPlayer2Assigned = cameraLogic . player2 != null ;
26
+
27
+ if ( ! isPlayer1Assigned && ! isPlayer2Assigned )
28
+ {
29
+ panel . SetActive ( false ) ;
30
+ }
31
+ else if ( ! isPlayer1Assigned )
32
+ {
33
+ panel . SetActive ( true ) ;
34
+ SetPlayerKilledText ( "Player 1 Killed!" ) ;
35
+ }
36
+ else if ( ! isPlayer2Assigned )
37
+ {
38
+ panel . SetActive ( true ) ;
39
+ SetPlayerKilledText ( "Player 2 Killed!" ) ;
40
+ }
41
+ else
42
+ {
43
+ panel . SetActive ( false ) ;
44
+ }
45
+ }
46
+
47
+ private void SetPlayerKilledText ( string text )
48
+ {
49
+ playerKilledText . text = text ;
50
+ }
51
+ }
You can’t perform that action at this time.
0 commit comments