This commit is contained in:
2023-11-28 11:38:59 +05:30
commit ce059d4bf6
2742 changed files with 618089 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
using Photon.Pun;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.SceneManagement;
public class MultiplayerManager : MonoBehaviourPunCallbacks
{
// Start is called before the first frame update
private static string _uid = "";
public static MultiplayerManager instance;
public bool isVR = false;
public static string uid { get {
if(_uid == "")
{
char[] chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".ToCharArray();
while(_uid.Length < 6)
{
_uid += chars[Random.Range(0, chars.Length)];
}
Debug.Log("New uid: " + _uid);
}
return _uid; } }
void Awake()
{
if(instance != null) { Destroy(gameObject); return; }
instance = this;
DontDestroyOnLoad(gameObject);
PhotonNetwork.ConnectUsingSettings();
}
public override void OnConnectedToMaster()
{
base.OnConnectedToMaster();
Debug.Log("Connected to photon");
}
// Update is called once per frame
public void ConnectToAdmin()
{
PhotonNetwork.CreateRoom(uid);
}
public override void OnCreatedRoom()
{
base.OnCreatedRoom();
Debug.Log("New room created : " + uid);
MPChat.isAdmin = false;
PhotonNetwork.LoadLevel(isVR ? "ADMIN_MP_VR" : "ADMIN_MP");
}
}