You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.3 KiB

using ExitGames.Client.Photon;
using Photon.Pun;
using Photon.Realtime;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.SceneManagement;
public class PhotonManager : MonoBehaviourPunCallbacks {
public override void OnPlayerPropertiesUpdate(Player target, Hashtable changedProps) {
if (changedProps.ContainsKey("CurrentScene")) {
bool allLoadedSelection = true;
bool allLoadedGame = true;
foreach (Player player in PhotonNetwork.PlayerList) {
int playerScene = (int)player.CustomProperties["CurrentScene"];
if (playerScene != 1)
allLoadedSelection = false;
if (playerScene != 2)
allLoadedGame = false;
}
if (allLoadedSelection && !Selection.Instance.HasStarted)
Selection.Instance.StartSelection();
if (allLoadedGame && !Game.Instance.IsPlaying)
Game.Instance.StartGame();
}
}
public override void OnConnectedToMaster() {
Debug.Log("Connected to master server");
}
public override void OnMasterClientSwitched(Player newMasterClient) {
Debug.Log("Master Client switched. New Client: " + newMasterClient.NickName + " (" + newMasterClient.ActorNumber + ")");
}
public override void OnDisconnected(DisconnectCause cause) {
Debug.Log("Disconnected from master server. Cause: " + cause.ToString("g"));
}
}