37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using Fusion;
|
|
using TMPro;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class GameManager : NetworkBehaviour
|
|
{
|
|
public Text gameOverText; // Reference to the Game Over text UI element
|
|
|
|
private bool isGameOver = false; // Flag to check if the game is over
|
|
|
|
private void Start() {
|
|
if (gameOverText != null) {
|
|
// Ensure the Game Over text is hidden at the start of the game
|
|
gameOverText.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
[SerializeField] private Hallucinate.Network.MatchEloManager eloManager;
|
|
|
|
public void TriggerGameOver(PlayerRef winner, PlayerRef loser, bool isDraw = false) {
|
|
if (!isGameOver) {
|
|
isGameOver = true;
|
|
|
|
if (gameOverText != null) {
|
|
gameOverText.gameObject.SetActive(true);
|
|
}
|
|
|
|
// Only Host processes Elo
|
|
if (Runner.IsServer && eloManager != null) {
|
|
eloManager.ProcessMatchResult(winner, loser, isDraw);
|
|
}
|
|
}
|
|
}
|
|
} |