Files
Crash-Course/Assets/Scripts/Game/WinScreen.cs

53 lines
1.3 KiB
C#
Raw Normal View History

2025-03-08 13:33:19 -05:00
using System.Collections.Generic;
using TMPro;
2025-04-16 19:57:54 -04:00
using UnityEngine; using Game; using Music; using Player;
namespace Game
{
2025-03-08 13:33:19 -05:00
public class WinScreen : MonoBehaviour
{
public static WinScreen Instance;
public List<TextMeshProUGUI> playerTexts;
private void Awake() // Ensures only one instance of WinScreen exists
2025-03-08 13:33:19 -05:00
{
if (Instance == null)
{
Instance = this;
}
else
{
Destroy(this.gameObject);
}
}
public void ShowWinScreen(int player)
2025-03-08 13:33:19 -05:00
{
Debug.Log($"ShowWinScreen called for Player {player}");
if (player - 1 < 0 || player - 1 >= GameManager.playerColors.Count)
{
Debug.LogError("Invalid player index or playerColors not initialized.");
return;
}
2025-03-08 13:33:19 -05:00
foreach (TextMeshProUGUI playerText in playerTexts)
{
playerText.text = "Player " + player;
if (playerText.color != Color.black)
{
playerText.color = GameManager.playerColors[player - 1];
}
}
Animator animator = GetComponent<Animator>();
if (animator == null)
{
Debug.LogError("Animator component missing on WinScreen.");
return;
}
animator.SetTrigger("win");
2025-03-08 13:33:19 -05:00
}
2025-03-08 13:33:19 -05:00
}
2025-04-16 19:57:54 -04:00
}