/*
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using TMPro;

using PhotonPlayer = Photon.Realtime.Player;

public class RoundOverDisplay : MonoBehaviour {
    bool roundOver;

    public CanvasHandler canvasHandler;
    public DefeatedCounterDisplay defeatedCounterDisplay;

    public TMP_Text resultText;

    public bool IsRoundOver() {
        return roundOver;
    }

    public void ShowWinner() {
        if (roundOver) {
            return;
        }
        roundOver = true;
        PhotonPlayer photonPlayer = GetWinningPhotonPlayer();
        if (photonPlayer == null) {
            Debug.LogError("no photonView found");
        }
        PlayerBase player = GetWinningPlayerBase(photonPlayer);
        StartCoroutine(DisplayResults(player));
    }

    IEnumerator DisplayResults(PlayerBase player) {
        yield return new WaitForSecondsRealtime(3f);

        Cursor.visible = true;
        Cursor.lockState = CursorLockMode.None;
        canvasHandler.SetCanvasAsActive(CanvasHandler.CanvasType.GameOver);
        if(player)
            player.SetSpectating(true);

        string resultsString = "";
        if(StartMatch.matchStarted) {
            if (player && player.photonView && player.photonView.IsMine) {
                PlayfabCloudScriptAPI.SetWins(1);
                resultsString += "#1\nCongratulations!";
            }
            else {
                // check if spectator
                bool spectator = false;
                object prop;
                if (PhotonNetwork.IsConnected && PhotonNetwork.LocalPlayer.CustomProperties.TryGetValue("IsSpectator", out prop)) {
                    spectator = (bool)prop;
                }

                // if so then find winner's name and display them as the winner
                if (spectator) {
                    if (player.photonView.Owner.CustomProperties.TryGetValue("DisplayName", out prop)) {
                        resultsString += (string)prop + " wins!";
                    }
                }
                else {
                    resultsString += "Better luck next time!";
                }
            }
            PlayfabCloudScriptAPI.SetCompletedMatch(1);
            PlayfabCloudScriptAPI.SetDefeats(defeatedCounterDisplay.defeatedPlayersCount);
        }
        else {
            resultsString = "You can't start a match without any players!";
        }

        if (resultText) {
            resultText.SetText(resultsString);
        }

        yield return new WaitForSecondsRealtime(30f);

        GameObject.FindGameObjectWithTag("Game Manager").GetComponent<GameLogicManager>().ReturnToLobby();
    }

    PhotonPlayer GetWinningPhotonPlayer() {
        if (PhotonNetwork.IsConnected && PhotonNetwork.CurrentRoom != null) {
            Dictionary<int, Photon.Realtime.Player> players = PhotonNetwork.CurrentRoom.Players;
            foreach (KeyValuePair<int, Photon.Realtime.Player> player in players) {
                object prop;
                if (player.Value.CustomProperties.TryGetValue("remaining", out prop)) {
                    if ((bool)prop) {
                        return player.Value;
                    }
                }
            }
        }
        return null;
    }

    PlayerBase GetWinningPlayerBase(PhotonPlayer photonPlayer) {
        if(photonPlayer == null) {
            Debug.LogError("not supplied a photonPlayer!");
            return null;
        }
        GameObject[] objs = GameObject.FindGameObjectsWithTag("Player");
        for(int i = 0; i < objs.Length; i++) {
            PlayerBase player = objs[i].GetComponent<PlayerBase>();
            if (player.photonView && player.photonView.OwnerActorNr == photonPlayer.ActorNumber) {
                return player;
            }
        }
        Debug.LogError("could not find winning player!");
        return null;
    }
}
*/