2026-01-30 21:51:33 +05:30
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
2026-01-31 20:33:50 +05:30
|
|
|
using System.Linq;
|
2026-01-30 21:51:33 +05:30
|
|
|
using TMPro;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
public class GameOverPopup : PopupBase
|
|
|
|
|
{
|
|
|
|
|
[SerializeField] private Button playAgainBtn;
|
|
|
|
|
[SerializeField] private Button mainMenuBtn;
|
|
|
|
|
|
|
|
|
|
[SerializeField] private TextMeshProUGUI[] texts;
|
|
|
|
|
|
|
|
|
|
private GameModeHandler gameModeHandler;
|
2026-01-31 20:33:50 +05:30
|
|
|
|
|
|
|
|
public void InitData(List<PlayerData> playerData)
|
|
|
|
|
{
|
|
|
|
|
for (int idx = 0; idx < texts.Length; idx++)
|
|
|
|
|
{
|
|
|
|
|
if (idx >= playerData.Count)
|
|
|
|
|
{
|
|
|
|
|
texts[idx].gameObject.SetActive(false);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (playerData[idx].ranking == 1)
|
|
|
|
|
{
|
|
|
|
|
texts[playerData[idx].ranking - 1].text = $"{playerData[idx].playerName} Wins";
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
texts[playerData[idx].ranking - 1].text = $"{playerData[idx].ranking}. {playerData[idx].playerName}";
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-01-30 21:51:33 +05:30
|
|
|
|
|
|
|
|
private void OnEnable()
|
|
|
|
|
{
|
|
|
|
|
playAgainBtn.onClick.AddListener(OnPlayAgainClicked);
|
|
|
|
|
mainMenuBtn.onClick.AddListener(OnMainMenuClicked);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnDisable()
|
|
|
|
|
{
|
|
|
|
|
playAgainBtn.onClick.RemoveAllListeners();
|
|
|
|
|
mainMenuBtn.onClick.RemoveAllListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnPlayAgainClicked()
|
|
|
|
|
{
|
|
|
|
|
HidePopup();
|
|
|
|
|
|
|
|
|
|
gameModeHandler = gameModeHandler == null ? InterfaceManager.Instance.GetInterfaceInstance<GameModeHandler>() : gameModeHandler;
|
|
|
|
|
gameModeHandler.OnGameRestarted();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HidePopup()
|
|
|
|
|
{
|
|
|
|
|
popupManager.HidePopup(popupType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnMainMenuClicked()
|
|
|
|
|
{
|
|
|
|
|
HidePopup();
|
|
|
|
|
}
|
|
|
|
|
}
|