Wraps up common room properties needed when you create rooms.
This directly maps to what the fields in the Room class.
	private void ConnectToRoom()
	{		
		//		if(PhotonNetwork.playerList.Length % 2 != 0)
		//		{
		//			RoomOptions roomOptions = new RoomOptions() { isVisible = true, maxPlayers = 2 };
		//			PhotonNetwork.JoinOrCreateRoom("roomName", roomOptions, TypedLobby.Default);
		
		RoomOptions newRoomOptions = new RoomOptions();
		newRoomOptions.isOpen = true;
		newRoomOptions.isVisible = true;
		newRoomOptions.maxPlayers = 2;
		
		if(ps.type == PlayerType.PC)
		newRoomOptions.customRoomProperties = new ExitGames.Client.Photon.Hashtable() { { "PC", false } };
		else
		newRoomOptions.customRoomProperties = new ExitGames.Client.Photon.Hashtable() { { "VR", false } };
		
		//			newRoomOptions.customRoomPropertiesForLobby = new string[] { "C0" }; // this makes "C0" available in the lobby
		
		// let's create this room in SqlLobby "myLobby" explicitly
		//			TypedLobby sqlLobby = new TypedLobby("myLobby", LobbyType.SqlLobby);
		//			PhotonNetwork.CreateRoom(roomName, newRoomOptions, sqlLobby);
		//			PhotonNetwork.JoinRandomRoom(newRoomOptions.customRoomProperties, newRoomOptions.maxPlayers = 2);
		//		}	
		PhotonNetwork.JoinOrCreateRoom("room" + PhotonNetwork.countOfRooms, newRoomOptions, TypedLobby.Default);
	}
Exemplo n.º 2
0
    void OnGUI()
    {
        GUILayout.Label(PhotonNetwork.connectionStateDetailed.ToString());

        if (PhotonNetwork.room == null)
        {
            //Create room
            if (GUI.Button(new Rect(50, 50, 200, 50), "Start Server"))
            {
                PhotonNetwork.CreateRoom(roomName + System.Guid.NewGuid().ToString("N"));
            }

            //Join room
            if (roomsList != null)
            {
                for (int i = 0; i < roomsList.Length; i++)
                {
                    if(GUI.Button(new Rect(50, 110 + (10 * i), 200, 50), "Join" + roomsList[i].name))
                    {
                        RoomOptions ro = new RoomOptions() { isVisible = true, maxPlayers = 4 };
                        PhotonNetwork.JoinOrCreateRoom(roomsList[i].name, ro, TypedLobby.Default);
                    }
                }
            }
        }
    }
Exemplo n.º 3
0
	/// <summary>
	/// When we joined the lobby after connecting to Photon, we want to immediately join the demo room, or create it if it doesn't exist
	/// </summary>
	void OnJoinedLobby()
	{
		RoomOptions roomOptions = new RoomOptions (){};
		PhotonNetwork.JoinOrCreateRoom (_room, roomOptions, TypedLobby.Default);
		Debug.Log ("Starting Server");
//		if( isHost == true )
//			return;
//		
//		if( QuitOnLogout == true )
//		{
//			Application.Quit();
//			return;
//		}
//		
//		if( Application.loadedLevelName == _levelName )
//		{
//			RoomOptions roomOptions = new RoomOptions();
//			roomOptions.maxPlayers = 20;
//			
//			PhotonNetwork.JoinOrCreateRoom( _room, roomOptions, TypedLobby.Default );
//			Debug.Log( "Joined Lobby" );
//		}
//		else
//		{
//			//If we join the lobby while not being in the MainMenu scene, something went wrong and we disconnect from Photon
//			PhotonNetwork.Disconnect();
//		}
	}
Exemplo n.º 4
0
	void OnJoinedLobby(){

		//Don't use these 2 lines if you wan't offline mode to work
		RoomOptions roomOptions = new RoomOptions () { isVisible = false, maxPlayers = 4};
		PhotonNetwork.JoinOrCreateRoom (roomName, roomOptions, TypedLobby.Default);

	}
Exemplo n.º 5
0
 public void OnPhotonRandomJoinFailed()
 {
     hostFlag = true;
     RoomOptions roomOptions = new RoomOptions() { isVisible = true, maxPlayers = 2 };
     PhotonNetwork.CreateRoom(null, roomOptions, TypedLobby.Default);
     //PhotonNetwork.CreateRoom(null);
 }
 public void CreateRoom(string roomname)
 {
     Debug.Log("Creating room " + roomname);
     this.Host = true;
     RoomOptions ro = new RoomOptions() { isVisible = true, maxPlayers = 5 };
     PhotonNetwork.CreateRoom(roomname, ro, TypedLobby.Default);
 }
Exemplo n.º 7
0
 // below, we implement some callbacks of PUN
 // you can find PUN's callbacks in the class PunBehaviour or in enum PhotonNetworkingMessage
 public virtual void OnConnectedToMaster()
 {
     Debug.Log("OnConnectedToMaster() was called by PUN. Now this client is connected and could join a room. Calling: PhotonNetwork.JoinOrCreateRoom();");
     RoomOptions roomOptions = new RoomOptions() { isVisible = false, maxPlayers = 8 };
     PhotonNetwork.JoinOrCreateRoom(roomName, roomOptions, TypedLobby.Default);
     GameObject.Find("Canvas/Room Label").GetComponent<Text>().text = "Room: " + roomName;
 }
Exemplo n.º 8
0
 void OnConnectedToMaster()
 {
     RoomOptions roomOptions = new RoomOptions();
     roomOptions.isVisible = true;
     roomOptions.maxPlayers = 2;
     PhotonNetwork.JoinOrCreateRoom("testRoom", roomOptions, TypedLobby.Default);
 }
Exemplo n.º 9
0
    //Called if Auto-Join Lobby is true in PhotonServerSettings asset
    void OnJoinedLobby()
    {
        Debug.Log("Joined Lobby");

        RoomOptions roomOptions = new RoomOptions() { isVisible = false, maxPlayers = 2 };
        PhotonNetwork.JoinOrCreateRoom("Game", roomOptions, TypedLobby.Default);
    }
Exemplo n.º 10
0
	void OnJoinedLobby() {
		RoomOptions roomOptions = new RoomOptions() {
			isVisible = false,
			maxPlayers = 4
		};
		PhotonNetwork.JoinOrCreateRoom(roomName, roomOptions, TypedLobby.Default);
	}
 void OnPhotonJoinRoomFailed()
 {
     Debug.Log("No such room with name : " + roomName + ", creating!");
     RoomOptions roomOptions = new RoomOptions();
         roomOptions.maxPlayers = 2;
     PhotonNetwork.JoinOrCreateRoom(roomName, roomOptions, TypedLobby.Default);
 }
Exemplo n.º 12
0
    void OnPhotonRandomJoinFailed()
    {
        RoomOptions roomOptions = new RoomOptions() { isVisible = true, maxPlayers = 2 };
        PhotonNetwork.CreateRoom(null,roomOptions,TypedLobby.Default);
        Gameplay.instance.maxPoints = 5;

    }
Exemplo n.º 13
0
 void OnPhotonRandomJoinFailed()
 {
     Debug.Log("Can't join random room!");
     RoomOptions roomOptions = new RoomOptions();
     roomOptions.MaxPlayers = 0;
     PhotonNetwork.CreateRoom(null, roomOptions, null);
 }
Exemplo n.º 14
0
 void OnJoinedLobby()
 {
     Debug.Log("OnJoinedLobby");
     RoomOptions roomOptions = new RoomOptions() { isVisible = false, maxPlayers = 4 };
     PhotonNetwork.JoinOrCreateRoom("FillerRoom-", roomOptions, TypedLobby.Default);
     // + Random.Range(1, 100000)
 }
Exemplo n.º 15
0
	void OnJoinedLobby()
	{
		Debug.Log("joined lobby");
		
		RoomOptions roomOptions = new RoomOptions() { };
		PhotonNetwork.JoinOrCreateRoom(_room, roomOptions, TypedLobby.Default);
	}
Exemplo n.º 16
0
 public void CreateRoom()
 {
     string RoomName = createRoomInput.text;
     byte roomPlayersMax = byte.Parse (createRoomInputPlayers.text);
     //Validation for name and playerMAX
     if (RoomName.Length > 5)
     {
         if (roomPlayersMax > 0)
         {
             RoomOptions newroomoptions = new RoomOptions()
             {
                 maxPlayers = roomPlayersMax,
                 isOpen =true,
                 isVisible = true
             };
             PhotonNetwork.JoinOrCreateRoom(RoomName,newroomoptions,TypedLobby.Default);
         }
         else
         {
             Debug.Log("Room Max Player fails");
         }
     }
     else
     {
         Debug.Log("Roomname fails");
     }
 }
Exemplo n.º 17
0
	/// <summary>
	/// When we joined the lobby after connecting to Photon, we want to immediately join the demo room, or create it if it doesn't exist
	/// </summary>
	void OnJoinedLobby()
	{
		if( isHost == true )
			return;
		
		if( QuitOnLogout == true )
		{
			Application.Quit();
			return;
		}
		
		if( Application.loadedLevelName == _levelName )
		{
			RoomOptions roomOptions = new RoomOptions();
			roomOptions.maxPlayers = 20;
			
			PhotonNetwork.JoinOrCreateRoom( "Wizard", roomOptions, TypedLobby.Default );
			Debug.Log( "Joined Lobby" );
		}
		else
		{
			//If we join the lobby while not being in the MainMenu scene, something went wrong and we disconnect from Photon
			PhotonNetwork.Disconnect();
		}
	}
    void OnJoinedLobby()
    {
        Debug.Log("joined lobby");

        RoomOptions roomOptions = new RoomOptions() {isVisible = true, maxPlayers = 4};
        PhotonNetwork.JoinOrCreateRoom(Room, roomOptions, TypedLobby.Default);
    }
Exemplo n.º 19
0
        void OnConnectedToMaster()
        {
            if (ApplicationModel.NetState == NetSate.Default)
            {
                Debug.Log("JoinRandomRoom");
                PhotonNetwork.JoinRandomRoom(); // création de la room
                return;
            }
            Debug.Log("JoinNanRandomRoom : " + ApplicationModel.NetState);
            string RoomID = ApplicationModel.RoomID;
            if (RoomID != null)
                this.room_name = RoomID;
            else
            {
                Notification.Create(NotificationType.Box, "Erreur lors de l'invitation", content: "Une erreur est survenue lors de la création de la room.");
                return;
            }

            if (ApplicationModel.NetState == NetSate.InviteFriend)
            {
                RoomOptions roomOptions = new RoomOptions() { IsVisible = false /*isVisible = false*/ , MaxPlayers = 2 /*maxPlayers = 2*/}; // isVisible Random can join or not (ici non)
                PhotonNetwork.JoinOrCreateRoom(this.room_name, roomOptions, TypedLobby.Default);
            }
            else if (ApplicationModel.NetState == NetSate.InviteByFriend)
            {
                PhotonNetwork.JoinRoom(this.room_name);
            }
            PlayerPrefs.DeleteAll();

        }
Exemplo n.º 20
0
    public override void OnJoinedLobby()
    {
        base.OnJoinedLobby();
        Debug.Log("Joined a lobby");
        RoomOptions roomOptions = new RoomOptions();

        PhotonNetwork.JoinOrCreateRoom("test", roomOptions, TypedLobby.Default);
    }
Exemplo n.º 21
0
        public override void Execute() {
			Debug.Log ("JoinRoomFailed.Execute()");
			roomOptions = new RoomOptions ();
			roomOptions.maxPlayers = (byte)MaxPlayers;
			roomOptions.customRoomProperties = new ExitGames.Client.Photon.Hashtable ();
			roomOptions.customRoomProperties.Add ("map", RoomId);
			PhotonNetwork.CreateRoom (null, roomOptions, TypedLobby.Default);
        }
    //public void OnConnectedToMaster()
    //{
    //    Debug.Log("OnConnectedToMaster");
    //    PhotonNetwork.CreateRoom("Sala1");
    //    //PhotonNetwork.JoinRandomRoom();
    //}
    public void OnJoinedLobby()
    {
        Debug.Log("OnJoinedLobby");
            RoomOptions roomOp = new RoomOptions() { isVisible = true, maxPlayers = (byte)(playersMax) };
            PhotonNetwork.JoinOrCreateRoom("Sala1", roomOp, TypedLobby.Default);

        //PhotonNetwork.JoinRandomRoom();
    }
Exemplo n.º 23
0
		public override void Execute() {
			Debug.Log ("Trying to join room:"+RoomId);
			roomOptions = new RoomOptions ();
			roomOptions.maxPlayers = (byte)MaxPlayers;
			roomOptions.customRoomProperties = new ExitGames.Client.Photon.Hashtable ();
			roomOptions.customRoomProperties.Add ("map", RoomId);
			PhotonNetwork.JoinOrCreateRoom (RoomId, roomOptions, TypedLobby.Default);
		}
Exemplo n.º 24
0
 public void AutoCreateRoom()
 {
         RoomOptions options = new RoomOptions();
         options.isVisible = roomVisible.isOn;
         options.isOpen = roomOpen.isOn;
         options.maxPlayers = 20;
         PhotonNetwork.JoinOrCreateRoom("Server", options, TypedLobby.Default);
 }
Exemplo n.º 25
0
 void OnTouchDown()
 {
     RoomOptions option = new RoomOptions ();
     option.isOpen = true;
     option.isVisible = true;
     option.maxPlayers = 10;
     PhotonNetwork.CreateRoom (roomName, option, null);
 }
 void OnPhotonRandomJoinFailed()
 {
     RoomOptions ro = new RoomOptions();
     ro.isVisible = true;
     ro.isOpen = true;
     ro.maxPlayers = 8;
     ro.customRoomProperties = new ExitGames.Client.Photon.Hashtable() { { "", 0 } };
     PhotonNetwork.CreateRoom("", ro, TypedLobby.Default);
 }
Exemplo n.º 27
0
		public override void OnEnter ()
		{
			RoomOptions roomOptions = new RoomOptions();
			roomOptions.isVisible = isVisible.Value;
			roomOptions.isOpen = mIsOpen.Value;
			roomOptions.maxPlayers = maxPlayers.Value;
			PhotonNetwork.JoinOrCreateRoom (roomName.Value, roomOptions, TypedLobby.Default);
			Finish ();
		}
Exemplo n.º 28
0
    public void onCreateGameClick()
    {
        Application.LoadLevel ("level_01");

        RoomOptions roomOptions = new RoomOptions();
        roomOptions.maxPlayers = 4;

        PhotonNetwork.JoinOrCreateRoom(roomName, roomOptions, TypedLobby.Default);
    }
Exemplo n.º 29
0
	public void CreateGame(){
		CreateMenu.SetActive(true);
		MainMenu.SetActive(false);
        Debug.Log(PhotonNetwork.countOfPlayersOnMaster);
        debugtext.GetComponent<Text>().text += PhotonNetwork.countOfPlayersOnMaster;
        
        RoomOptions roomOptions = new RoomOptions() { isVisible = true, maxPlayers = 4 };
		PhotonNetwork.CreateRoom("FillerRoom-", roomOptions, null);
	}
Exemplo n.º 30
0
 /// <summary>
 /// For "PhotonNetwork.JoinOrCreateRoom()" secound parameter.
 /// </summary>
 /// <param name="isVisibled">Other players are able to show flag.</param>
 /// <param name="isOpen">Ohter players are able to into this room flag.</param>
 /// <param name="maxPlayer">This room can into players number.</param>
 /// <returns></returns>
 public static RoomOptions createRoomOptions(bool isVisibled = true, bool isOpen = true, byte maxPlayer = 10)
 {
     RoomOptions roomOptions = new RoomOptions();
     roomOptions.isVisible = isVisibled;
     roomOptions.isOpen = isOpen;
     roomOptions.maxPlayers = maxPlayer;
     roomOptions.customRoomProperties = new ExitGames.Client.Photon.Hashtable() { { "CustomProperties", "カスタムプロパティ" } };
     roomOptions.customRoomPropertiesForLobby = new string[] { "CustomProperties" };
     return roomOptions;
 }
 

 public void CreateRoom() 

 {
     
 RoomOptions roomOptions = new RoomOptions()
     {
         isVisible = true, isOpen = true, maxPlayers = 4
     }; 
 PhotonNetwork.CreateRoom(inputRoomName.text, roomOptions, TypedLobby.Default); 
 roomNameText2.text = "RoomName;" + inputRoomName.text; 
 playerCount.text = "PlayerCount; 1"; 

 }
Exemplo n.º 32
0
        public void CreateCustomRoom(string roomName, RoomOptions roomOptions, LobbyType lobbyType, string[] expectedUsers)
        {
            Debug.LogError("PhotonController.CreateCustomRoom Called.");

            PhotonNetwork.CreateRoom(roomName, roomOptions, TypedLobby.Default, expectedUsers);
        }
Exemplo n.º 33
0
    public void RoomsApi()
    {
        // This will register a room to the master server, so that
        // master server would know about it's existance
        // This is a minimal example
        Msf.Server.Rooms.RegisterRoom((controller, error) =>
        {
            if (controller == null)
            {
                Logs.Error(error);
            }
        });

        var roomOptions = new RoomOptions()
        {
            IsPublic   = false,
            MaxPlayers = 5,
            Name       = "My super room",
            Password   = "******",
            Properties = new Dictionary <string, string>()
            {
                { "CustomProperty", "Some extra stuff" }
            },
            RoomIp   = "127.0.0.1",
            RoomPort = 777
        };

        // More customization options
        Msf.Server.Rooms.RegisterRoom(roomOptions, (controller, error) =>
        {
            // Edit the options, to make the room public
            controller.Options.IsPublic = true;

            // Save the options
            controller.SaveOptions(controller.Options);

            // When player sends us an access token, we can confirm if the token is valid
            controller.ValidateAccess("token..", (playerPeerId, confirmationError) =>
            {
                if (playerPeerId == null)
                {
                    Logs.Error("Player provided an invalid token");
                    return;
                }

                // Player provided a valid token
                // TODO Get account info by peer id
                // TODO Spawn a player to the game
            });

            // If we want to handle who gets access, and who doesn't
            controller.SetAccessProvider((requester, giveAccess) =>
            {
                // TODO use the peerId to retrieve account data
                // TODO check if, for example, the username is banned in this room

                // If user is allowed, create a new room access
                giveAccess(new RoomAccessPacket()
                {
                    RoomIp     = controller.Options.RoomIp,
                    RoomPort   = controller.Options.RoomPort,
                    Properties = new Dictionary <string, string>()
                    {
                        // Custom properties
                        { "Color", "#ffffff" }
                    },
                    RoomId    = controller.RoomId,
                    SceneName = SceneManager.GetActiveScene().name,
                    Token     = Guid.NewGuid().ToString()
                }, null);

                // If user is not allowed
                giveAccess(null, "You're not allowed to play!");
            });
        });


        var roomId = 5;

        // Getting access from client
        Msf.Client.Rooms.GetAccess(roomId, (access, error) =>
        {
            if (access == null)
            {
                Debug.LogError(error);
                return;
            }

            // We've received the access
            Debug.Log(access);

            // TODO use ip and port from access to connect to game server
            // TODO send the token to game server  (this will depend on game server technologies used)
        });
    }
 public CreateGameResponse CreateRoom(string roomName, RoomOptions roomOptions, TypedLobby lobby, Hashtable playerProperties, bool onGameServer, short expectedResult = ErrorCode.Ok)
 {
     return(this.CreateRoom(roomName, roomOptions, lobby, playerProperties, onGameServer, null, expectedResult));
 }
 /// <summary>
 /// Override of the factory method used by the LoadBalancing framework (which we extend here) to create a Room instance.
 /// </summary>
 /// <remarks>
 /// While CreateParticleDemoRoom will make the server create the room, this method creates a local object to represent that room.
 ///
 /// This method is used by a LoadBalancingClient automatically whenever this client joins or creates a room.
 /// We override it to produce a ParticleRoom which has more features like Map and GridSize.
 /// </remarks>
 protected internal override Room CreateRoom(string roomName, RoomOptions opt)
 {
     return(new ParticleRoom(roomName, opt));
 }
Exemplo n.º 36
0
    public void CreateRoom()
    {
        roomName = name_input_field_text_obj.GetComponent <Text>().text;

        string password = password_input_field_obj.GetComponent <InputField>().text;

        //Globals.room_password = password;
        if (PhotonNetwork.LocalPlayer.CustomProperties.ContainsKey("password"))
        {
            PhotonNetwork.LocalPlayer.CustomProperties["password"] = password;
        }
        else
        {
            PhotonNetwork.LocalPlayer.CustomProperties.Add("password", password);
        }

        /* WORLD_SIZE: is broken
         * string raw_worldSize = size_input_field_text_obj.GetComponent<Text>().text;
         * int worldSize;
         * if (raw_worldSize.Length > 0)
         * {
         *  try { worldSize = int.Parse(raw_worldSize); }
         *  catch (Exception e)
         *  { size_input_field_text_obj.GetComponent<Text>().text = "Invalid size (need 1-100)"; return; }
         * }
         * else
         * {
         *  worldSize = 10;
         * }
         *
         * Globals.world_size = worldSize;
         */

        bool already_exists = false;

        foreach (RoomInfo RI in Globals.photon_rooms)
        {
            if (RI.Name.Equals(roomName))
            {
                already_exists = true;
                break;
            }
        }

        if (already_exists)
        {
            name_input_obj.GetComponent <InputField>().text = "NAME EXISTS";
            return;
        }

        Debug.Log("Attempting to create room \"" + roomName + "\"");
        transform.GetChild(0).GetComponent <Text>().text = "Creating...";
        roomOps = new RoomOptions()
        {
            IsVisible  = true,
            IsOpen     = true,
            MaxPlayers = 4
        };

        StartCoroutine("SafeCreateRoom");
    }
Exemplo n.º 37
0
 public bool CriaSala(string nomeSala, RoomOptions options)
 {
     return(PhotonNetwork.CreateRoom(nomeSala, options));
 }
Exemplo n.º 38
0
    public void hideDialog(string a)
    {
        if (type.Equals("invited"))
        {
            if (a.Equals("accepted"))
            {
                if (PoolGameManager.Instance.coinsCount >= PoolGameManager.Instance.payoutCoins)
                {
                    PoolGameManager.Instance.chatClient.SendPrivateMessage(senderID, "INVITE_ACCEPT;" + roomName + ";" + PoolGameManager.Instance.nameMy);
                    RoomOptions roomOptions = new RoomOptions()
                    {
                        isVisible = false, maxPlayers = 2
                    };


                    PhotonNetwork.JoinOrCreateRoom(roomName, roomOptions, TypedLobby.Default);
                    //				menuCanvas.SetActive (false);
                    //				gameTitle.SetActive (false);


                    matchPlayersCanvas.GetComponent <SetMyData>().MatchPlayer();
                    matchPlayersCanvas.GetComponent <SetMyData>().setBackButton(false);
                    //				friendsCanvas.SetActive (false);
                    //				menuCanvas.SetActive (false);
                    //				gameTitle.SetActive (false);
                }
                else
                {
                    PoolGameManager.Instance.chatClient.SendPrivateMessage(senderID, "INVITE_REJECT;" + roomName + ";" + PoolGameManager.Instance.nameMy);
                    PoolGameManager.Instance.dialog.SetActive(true);
                }
            }
            else if (a.Equals("rejected"))
            {
                PoolGameManager.Instance.chatClient.SendPrivateMessage(senderID, "INVITE_REJECT;" + roomName + ";" + PoolGameManager.Instance.nameMy);
            }
        }
        else if (type.Equals("accepted"))
        {
            if (a.Equals("accepted"))
            {
                if (PoolGameManager.Instance.coinsCount >= PoolGameManager.Instance.payoutCoins)
                {
                    PoolGameManager.Instance.chatClient.SendPrivateMessage(senderID, "INVITE_START;" + roomName + ";" + PoolGameManager.Instance.nameMy);
                    matchPlayersCanvas.GetComponent <SetMyData>().MatchPlayer();
                    matchPlayersCanvas.GetComponent <SetMyData>().setBackButton(false);
                    //				friendsCanvas.SetActive (false);
                    //				menuCanvas.SetActive (false);
                    //				gameTitle.SetActive (false);
                    PhotonNetwork.JoinRoom(roomName);
                }
                else
                {
                    PoolGameManager.Instance.chatClient.SendPrivateMessage(senderID, "INVITE_STOP;" + roomName + ";" + PoolGameManager.Instance.nameMy);
                    PoolGameManager.Instance.dialog.SetActive(true);
                }
            }
            else if (a.Equals("rejected"))
            {
                PoolGameManager.Instance.chatClient.SendPrivateMessage(senderID, "INVITE_STOP;" + roomName + ";" + PoolGameManager.Instance.nameMy);
            }
        }
        //Debug.Log ("Dialog: " + a);
        animator.Play("InvitationDialogHide");
    }
Exemplo n.º 39
0
 // Token: 0x0600549D RID: 21661 RVA: 0x001D3148 File Offset: 0x001D1548
 public static bool EnterWorld(ApiWorld world, string instanceId = "")
 {
     Debug.Log("Entering Room: " + world.name);
     if (VRCFlowNetworkManager.Instance == null || !VRCFlowNetworkManager.Instance.isConnected || !RoomManager.enterRoomReady)
     {
         string message = "Cannot join room. Connection not ready for join operations";
         UserMessage.SetMessage(message);
         Debug.LogError(message);
         return(false);
     }
     try
     {
         RoomManager.LockdownOverride = false;
         Analytics.Send(ApiAnalyticEvent.EventType.joinsWorld, world.id, null, null);
         ExitGames.Client.Photon.Hashtable hashtable = new ExitGames.Client.Photon.Hashtable();
         hashtable["scene"]     = "Custom";
         hashtable["url"]       = world.assetUrl;
         hashtable["name"]      = world.name;
         hashtable["blueprint"] = world;
         string[] customRoomPropertiesForLobby = new string[]
         {
             "scene",
             "url",
             "name"
         };
         RoomOptions roomOptions = new RoomOptions();
         roomOptions.IsOpen                       = true;
         roomOptions.IsVisible                    = true;
         roomOptions.MaxPlayers                   = (byte)((world.capacity * 2 >= 255) ? 255 : (world.capacity * 2));
         roomOptions.CustomRoomProperties         = hashtable;
         roomOptions.CustomRoomPropertiesForLobby = customRoomPropertiesForLobby;
         List <string> list = (from m in ModerationManager.Instance.GetModerationsOfType(ApiModeration.ModerationType.Kick)
                               where m.worldId == world.id
                               select m.instanceId).ToList <string>();
         if (world.capacity == 1)
         {
             instanceId = User.CurrentUser.id + ((!ModerationManager.Instance.IsBannedFromPublicOnly(APIUser.CurrentUser.id)) ? string.Empty : ApiWorld.WorldInstance.BuildAccessTags(ApiWorld.WorldInstance.AccessType.FriendsOnly, APIUser.CurrentUser.id));
         }
         else if (string.IsNullOrEmpty(instanceId) || list.Contains(instanceId))
         {
             instanceId = world.GetBestInstance(list, ModerationManager.Instance.IsBannedFromPublicOnly(APIUser.CurrentUser.id)).idWithTags;
         }
         string text = world.id + ":" + instanceId;
         Debug.Log("Joining " + text);
         Debug.Log("Joining or Creating Room: " + world.name);
         bool flag = PhotonNetwork.JoinOrCreateRoom(text, roomOptions, TypedLobby.Default);
         if (!flag)
         {
             RoomManager.currentRoom = null;
             RoomManager.ClearMetadata();
             throw new Exception("JoinOrCreateRoom failed!");
         }
         RoomManager.currentRoom = world;
         RoomManager.currentRoom.currentInstanceIdWithTags = instanceId;
         ApiWorld.WorldInstance worldInstance = new ApiWorld.WorldInstance(instanceId, 0);
         RoomManager.currentRoom.currentInstanceIdOnly = worldInstance.idOnly;
         RoomManager.currentRoom.currentInstanceAccess = worldInstance.GetAccessType();
         Debug.Log("Successfully joined room");
         RoomManager.lastMetadataFetchMinute = -1;
     }
     catch (Exception ex)
     {
         Debug.LogError("Something went entering room:\n" + ex.ToString() + "\n" + ex.StackTrace);
         return(false);
     }
     return(true);
 }
Exemplo n.º 40
0
 public void CreateRoom(string roomName, RoomOptions roomOptions, TypedLobby typedLobby)
 {
     objLobby.SetActive(false);
     PhotonNetwork.CreateRoom(roomName, roomOptions, typedLobby);
 }
Exemplo n.º 41
0
    public void createRoom()
    {
        if (!PhotonNetwork.IsConnected)
        {
            return;
        }
        string      roomName    = _roomName.text;
        RoomOptions roomOptions = new RoomOptions();

        roomOptions.MaxPlayers = 6;
        List <int>  wallIndices = new List <int>();
        List <int>  wallRot     = new List <int>();
        List <bool> wallorslit  = new List <bool>();

        for (int i = 0; i < (int)lengthSlider.value * 800; i++)
        {
            if (i % 15 == 0 && Random.Range(0, 100) > 60f)
            {
                wallIndices.Add(i % 799);
                wallRot.Add(Random.Range(0, 360));
                wallorslit.Add(Random.Range(0, 100) > 40);
            }
            else
            {
                wallIndices.Add(-1);
                wallRot.Add(-1);
                wallorslit.Add(false);
            }
        }

        if (customRoomProps["LENGTH"] == null)
        {
            customRoomProps.Add("LENGTH", (int)lengthSlider.value);
            customRoomProps.Add("WALL", wallToggle.isOn);
            customRoomProps.Add("UPGRADE", upgradesToggle.isOn);
            customRoomProps.Add("WALLINDICES", wallIndices.ToArray());
            customRoomProps.Add("WALLROT", wallRot.ToArray());
            customRoomProps.Add("WALLORSLIT", wallorslit.ToArray());
        }
        else
        {
            customRoomProps["LENGTH"]      = (int)lengthSlider.value;
            customRoomProps["WALL"]        = wallToggle.isOn;
            customRoomProps["UPGRADE"]     = upgradesToggle.isOn;
            customRoomProps["WALLINDICES"] = wallIndices.ToArray();
            customRoomProps["WALLROT"]     = wallRot.ToArray();
            customRoomProps["WALLORSLIT"]  = wallorslit.ToArray();
        }

        int[] offsets = new int[3];
        offsets[0] = Random.Range(0, 100);
        offsets[1] = Random.Range(0, 100);
        offsets[2] = Random.Range(0, 100);
        if (customRoomProps["OFFSETS"] == null)
        {
            customRoomProps.Add("OFFSETS", offsets);
        }
        else
        {
            customRoomProps["OFFSETS"] = offsets;
        }
        roomOptions.CustomRoomProperties = customRoomProps;
        PhotonNetwork.JoinOrCreateRoom(roomName, roomOptions, TypedLobby.Default);
    }
Exemplo n.º 42
0
        public static RoomOptions ConvertPhotonRoomOption(RoomOption sdkRO)
        {
            if (sdkRO == null)
            {
                return(new RoomOptions());
            }

            RoomOptions photonRO = new RoomOptions();

            photonRO.IsOpen     = sdkRO.IsOpen;
            photonRO.MaxPlayers = (byte)sdkRO.MaxPlayerCount;

            if (sdkRO.RoomPropertiesForLobby != null)
            {
                photonRO.CustomRoomPropertiesForLobby = sdkRO.RoomPropertiesForLobby.ToArray();
            }

            if (sdkRO.RoomProperties != null)
            {
                photonRO.CustomRoomProperties = (Hashtable)sdkRO.RoomProperties;
            }
            else
            {
                photonRO.CustomRoomProperties = new Hashtable();
            }


            if (photonRO.CustomRoomProperties != null)
            {
                if (photonRO.CustomRoomProperties.ContainsKey(RoomOptionKey.IsVisible) == true)
                {
                    photonRO.CustomRoomProperties[RoomOptionKey.IsVisible] = sdkRO.IsVisible;
                }
                else
                {
                    photonRO.CustomRoomProperties.Add(RoomOptionKey.IsVisible, sdkRO.IsVisible);
                }

                if (string.IsNullOrEmpty(sdkRO.Password) == false)
                {
                    if (photonRO.CustomRoomProperties.ContainsKey(RoomOptionKey.Password) == true)
                    {
                        photonRO.CustomRoomProperties[RoomOptionKey.Password] = sdkRO.Password;
                    }
                    else
                    {
                        photonRO.CustomRoomProperties.Add(RoomOptionKey.Password, sdkRO.Password);
                    }
                }

                if (sdkRO.BlockedPlayerIdList != null)
                {
                    if (photonRO.CustomRoomProperties.ContainsKey(RoomOptionKey.BlockedPlayerIdList) == true)
                    {
                        photonRO.CustomRoomProperties[RoomOptionKey.BlockedPlayerIdList] = sdkRO.BlockedPlayerIdList;
                    }
                    else
                    {
                        photonRO.CustomRoomProperties.Add(RoomOptionKey.BlockedPlayerIdList, sdkRO.BlockedPlayerIdList);
                    }
                }
            }

            return(photonRO);
        }
Exemplo n.º 43
0
 public void CreateRoom(string roomName, RoomOptions options)
 {
     PhotonNetwork.CreateRoom(roomName, options, TypedLobby.Default);
 }
Exemplo n.º 44
0
 void Awake()
 {
     //Options init
     options            = new RoomOptions();
     options.MaxPlayers = 6;
 }
 private bool CanClientSpawn(IClient client, RoomOptions data)
 {
     return(EnableClientSpawnRequests);
 }
Exemplo n.º 46
0
 public void CreateRoom(string roomName, RoomOptions options)
 {
     Debug.Log("Creating Room...");
     PhotonNetwork.CreateRoom(roomName, options);
     MenuManager.Instance.OpenMenu("Loading");
 }
 protected override Room CreateRoom(string roomName, RoomOptions opt)
 => new PrismRoom(roomName, opt);
Exemplo n.º 48
0
    void LobbyWindow(int index)
    {
        //Connection Status and Room creation Button
        GUILayout.BeginHorizontal();

        GUILayout.Label("Status: " + PhotonNetwork.NetworkClientState);

        if (joiningRoom || !PhotonNetwork.IsConnected || PhotonNetwork.NetworkClientState != ClientState.JoinedLobby)
        {
            GUI.enabled = false;
        }

        GUILayout.FlexibleSpace();

        //Room name text field
        roomName = GUILayout.TextField(roomName, GUILayout.Width(250));

        if (GUILayout.Button("Create Room", GUILayout.Width(125)))
        {
            if (roomName != "")
            {
                joiningRoom = true;

                RoomOptions roomOptions = new RoomOptions();
                roomOptions.IsOpen     = true;
                roomOptions.IsVisible  = true;
                roomOptions.MaxPlayers = (byte)10; //Set any number

                PhotonNetwork.JoinOrCreateRoom(roomName, roomOptions, TypedLobby.Default);
            }
        }

        GUILayout.EndHorizontal();

        //Scroll through available rooms
        roomListScroll = GUILayout.BeginScrollView(roomListScroll, true, true);

        if (createdRooms.Count == 0)
        {
            GUILayout.Label("No Rooms were created yet...");
        }
        else
        {
            for (int i = 0; i < createdRooms.Count; i++)
            {
                GUILayout.BeginHorizontal("box");
                GUILayout.Label(createdRooms[i].Name, GUILayout.Width(400));
                GUILayout.Label(createdRooms[i].PlayerCount + "/" + createdRooms[i].MaxPlayers);

                GUILayout.FlexibleSpace();

                if (GUILayout.Button("Join Room"))
                {
                    joiningRoom = true;

                    //Set our Player name
                    PhotonNetwork.NickName = playerName;

                    //Join the Room
                    PhotonNetwork.JoinRoom(createdRooms[i].Name);
                }
                GUILayout.EndHorizontal();
            }
        }

        GUILayout.EndScrollView();

        //Set player name and Refresh Room button
        GUILayout.BeginHorizontal();

        GUILayout.Label("Player Name: ", GUILayout.Width(85));
        //Player name text field
        playerName = GUILayout.TextField(playerName, GUILayout.Width(250));

        GUILayout.FlexibleSpace();

        GUI.enabled = (PhotonNetwork.NetworkClientState == ClientState.JoinedLobby || PhotonNetwork.NetworkClientState == ClientState.Disconnected) && !joiningRoom;
        if (GUILayout.Button("Refresh", GUILayout.Width(100)))
        {
            if (PhotonNetwork.IsConnected)
            {
                //Re-join Lobby to get the latest Room list
                PhotonNetwork.JoinLobby(TypedLobby.Default);
            }
            else
            {
                //We are not connected, estabilish a new connection
                PhotonNetwork.ConnectUsingSettings();
            }
        }

        GUILayout.EndHorizontal();

        if (joiningRoom)
        {
            GUI.enabled = true;
            GUI.Label(new Rect(900 / 2 - 50, 400 / 2 - 10, 100, 20), "Connecting...");
        }
    }
    public void ButtonEvents(string EVENT)
    {
        switch (EVENT)
        {
        case "CreateRoom":
            if (PhotonNetwork.JoinLobby())
            {
                PlayerNetwork.Instance.isNewGame = true;
                RoomOptions RO = new RoomOptions();
                RO.CustomRoomProperties = new ExitGames.Client.Photon.Hashtable()
                {
                    { "Challenge", Challenge.Nochallenge.ToString() }, { "seed", (int)System.DateTime.Now.Ticks }
                };
                RO.MaxPlayers = 5;
                PhotonNetwork.CreateRoom(roomName.text + " #" + Random.Range(100000, 999999), RO, TypedLobby.Default);

                SceneManager.LoadScene("Room");
            }
            break;

        case "Refresh":
            if (PhotonNetwork.JoinLobby())
            {
                RefreshRoomList();
            }
            break;
            //debug purpose

            //case "Load":
            //GameData data = SaveAndLoadManager.LoadGameData (roomName.text);

            /*
             * Debug.Log ("when loaded, we have ");
             * foreach (PlayerCardList pcl in data.playerCardList) {
             *      foreach (string pc in pcl.playerHand) {
             *              Debug.Log ("Player card " + pc);
             *      }
             * }
             *
             * foreach (RoleKind rk in data.roleKindList) {
             *      Debug.Log ("RoleKind is " + rk.ToString());
             * }*/
            /*
             * PlayerNetwork.Instance.isNewGame = false;
             * PlayerNetwork.Instance.savedGameJson =  JsonUtility.ToJson(data);
             * //Debug.Log ("Saved GameJson is : " + PlayerNetwork.Instance.savedGameJson);
             * GameData savedGame = JsonUtility.FromJson<GameData>(PlayerNetwork.Instance.savedGameJson);
             * /*
             * Debug.Log ("After loaded, we have ");
             * foreach (string s in savedGame.infectionCardDeck) {
             *      Debug.Log ("Infection card: "+ s);
             * }
             *
             * foreach (RoleKind rk in savedGame.roleKindList) {
             *      Debug.Log ("RoleKind is " + rk.ToString());
             * }*/
            /*
             * RoomOptions testRo = new RoomOptions ();
             * testRo.MaxPlayers = 5;
             * PhotonNetwork.CreateRoom (roomName.text, testRo, TypedLobby.Default);
             * SceneManager.LoadScene ("Room");
             * break;*/
        }
    }
Exemplo n.º 50
0
 public void ChangeOptions(RoomOptions options)
 {
     Options = options;
 }
Exemplo n.º 51
0
 /// <summary>
 /// Event raised when we want to connect to a room
 /// </summary>
 /// <param name="roomName">The name of the room we wanna join</param>
 /// <param name="needCreation">Contains th eparameters for the room we want to join</param>
 /// <param name="roomOptions">Is the user joining a room or do we need to create it ?</param>
 public OnConnectionToRoomRequested(string roomName, bool needCreation = true, RoomOptions roomOptions = null) : base("Event raised when we want to connect to a room")
 {
     RoomName     = roomName;
     NeedCreation = needCreation;
     Options      = roomOptions ?? new RoomOptions {
         MaxPlayers = (byte)5
     };
     FireEvent(this);
 }
Exemplo n.º 52
0
    public IEnumerator CreatePool()
    {
        //string otherUserId = WhotOpponent.instance.userId;
        //Debug.Log("other User Id: " + otherUserId);
        string url = UserDetailsManager.serverUrl + "createpool";
        string uId = SystemInfo.deviceUniqueIdentifier;

        betAmount = int.Parse(betAmountText.text);
#if UNITY_ANDROID && !UNITY_EDITOR
        uId = UserDetailsManager.androidUnique();
#elif UNITY_IOS && !UNITY_EDITOR
        uId = Device.advertisingIdentifier;
#endif
        Debug.Log("Whot pool url: " + url);
        Debug.Log("bet Amount: " + betAmount);
        Debug.Log("device_id: " + uId);
        Debug.Log("Receiver: " + receiverName);
        if (PhotonNetwork.connected && PhotonNetwork.room == null)
        {
            WWWForm form = new WWWForm();
            form.AddField("bet", betAmount);
            //form.AddField("otheruser", otherUserId);
            form.AddField("device_id", uId);
            Debug.Log("Time1: " + Time.timeScale);

            UnityWebRequest www = UnityWebRequest.Post(url, form);
            www.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            www.SetRequestHeader("Authorization", "Bearer " + UserDetailsManager.accessToken);
            www.timeout = 15;
            Debug.Log("Time2: " + Time.timeScale);
            yield return(www.SendWebRequest());

            Debug.Log("Time3: " + Time.timeScale);
            Debug.Log("Pool Creation Response: " + www.downloadHandler.text);

            if (www.isNetworkError)
            {
                Debug.Log("Network Error!! " + www.error);
            }
            else
            {
                var roomList = MiniJSON.Json.Deserialize(www.downloadHandler.text) as IDictionary;
                if (www.downloadHandler.text.Contains("error"))
                {
                    Debug.Log("Error Occured: " + www.downloadHandler.text);
                }
                else
                {
                    //WHOTMultiplayerManager.instance.gameStarted = false;
                    isOpponentReady = false;
                    isPlayerReady   = false;
                    var poolDetails = (IDictionary)roomList["result"];
                    poolId = poolDetails["poolid"].ToString();
                    RoomOptions roomOptions = new RoomOptions();
                    roomOptions.PublishUserId = true;
                    winAmt = int.Parse(poolDetails["winning_amount"].ToString());
                    roomOptions.CustomRoomPropertiesForLobby = new string[] { "ownername", "ownerid", "bet", "isAvailable", "appVer", "poolId", "isChallenge", "winAmt", "game" };
                    roomOptions.CustomRoomProperties         = new ExitGames.Client.Photon.Hashtable()
                    {
                        { "ownername", UserDetailsManager.userName }, { "ownerid", UserDetailsManager.userId }, { "bet", betAmount }, { "isAvailable", true }, { "appVer", Application.version }, { "poolId", poolId }, { "isChallenge", isChallenge }, { "winAmt", winAmt }, { "game", "Whot" }
                    };
                    //ExitGames.Client.Photon.Hashtable expectedCustomRoomProperties = new ExitGames.Client.Photon.Hashtable() { { "bet", MAtchMakeString }, { "isAvailable", true }, { "appVer", Application.version } };
                    roomOptions.MaxPlayers = 2;
                    roomOptions.IsVisible  = true;
                    roomOptions.IsOpen     = true;
                    PhotonNetwork.CreateRoom(poolId, roomOptions, TypedLobby.Default);

                    if (isChallenge)
                    {
                        ChatGui.instance.sendPhotonNotification(receiverName, UserDetailsManager.userName, "sendChallenge;" + poolId + ";" + betAmount + ";" + winAmt + ";" + "Whot");
                    }
                }
            }
        }
        else if (PhotonNetwork.room != null)
        {
            DisconnectFromPhoton();
        }
        else
        {
            GetPhotonToken();
        }
    }
Exemplo n.º 53
0
    IEnumerator Connect()
    {
        bool request;

        while (!NetworkManager.onNameServer)
        {
            yield return(null);
        }

        request = NetworkManager.net.OpGetRegions();
        if (request)
        {
            Debug.Log("Region request sent");
        }
        else
        {
            Debug.Log("Failed request regions");
            buttons.SetActive(true);
            yield break;
        }

        while (NetworkManager.net.AvailableRegions == null)
        {
            yield return(null);
        }
        Debug.Log("Regions list recieved");

        request = NetworkManager.net.ConnectToRegionMaster(NetworkManager.net.AvailableRegions[0]);
        if (request)
        {
            Debug.Log("Connected to region master.");
        }
        else
        {
            Debug.Log("Couldn't connect to region master.");
            buttons.SetActive(true);
            yield break;
        }

        while (!NetworkManager.onMasterLobby)
        {
            yield return(null);
        }

        var ro = new RoomOptions();

        ro.EmptyRoomTtl        = 1000;
        ro.CleanupCacheOnLeave = true;
        ro.PlayerTtl           = 500;
        ro.PublishUserId       = false;
        ro.MaxPlayers          = 20; // TODO: Expose this better

        request = NetworkManager.net.OpJoinOrCreateRoom("gamespawn", ro, ExitGames.Client.Photon.LoadBalancing.TypedLobby.Default);
        if (request)
        {
            Debug.Log("Room created");
        }
        else
        {
            Debug.Log("Couldn't create/join room");
            buttons.SetActive(true);
            yield break;
        }

        while (!NetworkManager.inRoom)
        {
            yield return(null);
        }

        gameObject.SetActive(false);
        Mode = 2;
    }
Exemplo n.º 54
0
 /// <summary>
 /// Uses the base constructor to initialize this ParticleRoom.
 /// </summary>
 protected internal CustomRoom(string roomName, RoomOptions opt)
     : base(roomName, opt)
 {
 }
Exemplo n.º 55
0
 /// <summary>
 /// Uses the base constructor to initialize this ParticleRoom.
 /// </summary>
 protected internal ParticleRoom(string roomName, RoomOptions opt)
     : base(roomName, opt)
 {
 }
Exemplo n.º 56
0
    IEnumerator JoinPool()
    {
        WHOTMultiplayerManager.Instance.isOpponentReady = false;
        WHOTMultiplayerManager.Instance.isPlayerReady   = false;

        WHOTMultiplayerManager.Instance.GetPhotonToken();
        Debug.Log("Join Pool");
        WWWForm form = new WWWForm();

        form.AddField("poolid", poolId);
        UnityWebRequest www = UnityWebRequest.Post(UserDetailsManager.serverUrl + "joinpool", form);

        www.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        www.SetRequestHeader("Authorization", "Bearer " + UserDetailsManager.accessToken);

        www.timeout = 15;
        yield return(www.SendWebRequest());

        Debug.Log("Join Pool Response: " + www.downloadHandler.text);
        var joinPoolDetails = MiniJSON.Json.Deserialize(www.downloadHandler.text) as IDictionary;

        if (www.error != null || www.isNetworkError)
        {
            Debug.Log("Error while trying o join pool: " + www.error);
            WhotUiManager.instance.errorPopup.GetComponent <PopUP>().title.text = "ERROR";
            WhotUiManager.instance.errorPopup.GetComponent <PopUP>().msg.text   = www.error;
            WhotUiManager.instance.errorPopup.SetActive(true);
        }
        else
        {
            if (www.downloadHandler.text.Contains("error"))
            {
                var errorDetails = (IDictionary)joinPoolDetails["result"];
                WhotUiManager.instance.errorPopup.GetComponent <PopUP>().title.text = "ERROR";
                WhotUiManager.instance.errorPopup.GetComponent <PopUP>().msg.text   = errorDetails["error"].ToString();
                WhotUiManager.instance.errorPopup.SetActive(true);
            }
            else
            {
                WHOTMultiplayerManager.Instance.startGameButton.gameObject.SetActive(false);
                WHOTMultiplayerManager.Instance.poolId       = poolId;
                WHOTMultiplayerManager.Instance.canLeavePool = false;
                WHOTMultiplayerManager.Instance.winAmt       = int.Parse(winningAmount);
                WHOTMultiplayerManager.Instance.betAmount    = int.Parse(betAmount);


                if (senderName != UserDetailsManager.userName)
                {
                    Debug.Log("playerNameText.text: " + senderName + " " + UserDetailsManager.userName);
                    ChatGui.instance.sendPhotonNotification(senderName, UserDetailsManager.userName, " has accept your challenge");
                }

                RoomOptions roomOptions = new RoomOptions();
                roomOptions.PublishUserId = true;
                roomOptions.CustomRoomPropertiesForLobby = new string[] { "ownername", "ownerid", "bet", "isAvailable", "appVer", "poolId", "isChallenge", "game" };
                roomOptions.CustomRoomProperties         = new ExitGames.Client.Photon.Hashtable()
                {
                    { "ownername", UserDetailsManager.userName }, { "ownerid", UserDetailsManager.userId }, { "bet", betAmount }, { "isAvailable", true }, { "appVer", Application.version }, { "poolId", poolId }, { "isChallenge", true }, { "game", "Whot" }
                };
                //ExitGames.Client.Photon.Hashtable expectedCustomRoomProperties = new ExitGames.Client.Photon.Hashtable() { { "bet", MAtchMakeString }, { "isAvailable", true }, { "appVer", Application.version } };
                roomOptions.MaxPlayers = 2;
                roomOptions.IsVisible  = true;
                roomOptions.IsOpen     = true;
                PhotonNetwork.JoinOrCreateRoom(poolId, roomOptions, TypedLobby.Default);
            }
        }
    }
Exemplo n.º 57
0
 /// <summary>
 /// Override this method, if you want to make some changes to registration options
 /// </summary>
 /// <param name="options"></param>
 protected virtual void BeforeSendingRegistrationOptions(RoomOptions options)
 {
 }
Exemplo n.º 58
0
 /// <summary>
 /// Refresh this instance fields based on the room options.
 /// </summary>
 /// <param name="options">The room options</param>
 internal void ReadOptions(RoomOptions options)
 {
     this.Name       = options.RoomName;
     this.MaxPlayers = options.MaxPlayers;
     this.PropertiesListedInLobby = options.PropertiesListedInLobby;
 }
Exemplo n.º 59
0
 /// <summary>
 /// Override of the factory method used by the LoadBalancing framework (which we extend here) to create a Room instance.
 /// </summary>
 /// <remarks>
 /// While CreateParticleDemoRoom will make the server create the room, this method creates a local object to represent that room.
 ///
 /// This method is used by a LoadBalancingClient automatically whenever this client joins or creates a room.
 /// We override it to produce a ParticleRoom which has more features like Map and GridSize.
 /// </remarks>
 protected internal override Room CreateRoom(string roomName, RoomOptions opt)
 {
     Debug.Log("Creating Room");
     return(new CustomRoom(roomName, opt));
 }
Exemplo n.º 60
0
    void OnGUI()
    {
        int sw = Screen.width;
        int sh = Screen.height;

        switch (sceneState)
        {
        case SceneState.Title:     //接続するまで

            if (GUI.Button(new Rect(sw / 2f, sh / 2f, 30f, 30f), "接続"))
            {
                PhotonNetwork.ConnectUsingSettings("v1.0");
                ConnectTime = 0.1f;
            }

            //if (ConnectTime >= 0.1f && PhotonNetwork.connectionStateDetailed != PeerState.JoinedLobby)
            //{
            //    GUILayout.Label("接続中");
            //}
            break;

        case SceneState.Loby:    //接続後.


            RoomName = GUI.TextField(new Rect(100, 100, 150, 20), RoomName, 16);

            GUI.Label(new Rect(100f, 170f, 50f, 50f), "Player数");
            playerMaxCount = GUI.SelectionGrid(new Rect(100, 200, 100, 20), playerMaxCount, playerCount, 4);


            if (GUILayout.Button("createroom"))
            {
                RoomOptions ro = new RoomOptions();
                //ro.MaxPlayers = playerMaxCount + 1;
                ro.IsOpen    = true;
                ro.IsVisible = true;
                string[] s = { "BS" };               //BS:BattleState.
                ro.CustomRoomPropertiesForLobby = s; //ロビーで表示される値.
                ro.CustomRoomProperties         = new ExitGames.Client.Photon.Hashtable()
                {
                    { "BS", "idle" }
                };
                PhotonNetwork.CreateRoom(RoomName, ro, TypedLobby.Default);
                sceneState = SceneState.Room;
            }

            if (PhotonNetwork.countOfRooms == 0)
            {
                return;
            }

            foreach (RoomInfo game in PhotonNetwork.GetRoomList())
            {
                GUI.Label(new Rect(sw / 2f, (sh * 2 / 3), 500, 30), game.Name + " " + game.PlayerCount + "/" + game.MaxPlayers + "/" + game.CustomProperties["BS"]);
                if (GUILayout.Button("JOIN"))
                {
                    PhotonNetwork.JoinRoom(game.Name);

                    sceneState = SceneState.Room;
                }
            }

            break;

        case SceneState.Room:    //ルームに入った後.

            if (PhotonNetwork.inRoom && PhotonNetwork.isMasterClient)
            {
                if (GUI.Button(new Rect(100, 100, 100, 100), "GameStart"))
                {
                    PhotonNetwork.room.IsOpen = false;     //エラーが起きたら困るので一回ここでルームを閉じる.

                    HashTable h = new HashTable()
                    {
                        { "BS", "Standing" }
                    };                                                          //ルームのステータスを変更.スタートアップ中.

                    PhotonNetwork.room.SetCustomProperties(h);

                    sceneState = SceneState.ChildsGamePlay;    //現在意味をなしていない.

                    //room情報をセットし終わったらリモートクライアントにシーンを呼ばせる.

                    PhotonNetwork.DestroyAll();

                    SendGameStart();
                }
            }

            if (GUILayout.Button("testInstance"))
            {
                PhotonNetwork.Instantiate("TestInstance", Vector3.zero, Quaternion.identity, 0);
            }

            break;

            /* case SceneState.ChildsGamePlay:
             *
             *   int cnt = 0;
             *   //マスタークライアント以外のローカルクライアントがしっかりシーンを読み終わったかを調べる.
             *   foreach (PhotonPlayer pp in PhotonNetwork.otherPlayers)
             *   {
             *       if ((int)pp.customProperties["GS"] == (int)GameState.Play)
             *       {
             *           cnt++;
             *
             *       }
             *   }
             *   if (cnt == PhotonNetwork.otherPlayers.Length)
             *       sceneState = SceneState.HostGamePlay;
             *
             *
             *   break;
             * case SceneState.HostGamePlay:
             *
             *   Debug.Log("MC以外の準備完了");
             *
             *   PhotonNetwork.isMessageQueueRunning = false;
             *
             *   Application.LoadLevel(1);
             *
             *
             *   break;*/
        }



        GUILayout.Label(PhotonNetwork.connectionStateDetailed.ToString());
        GUILayout.Label(ConnectTime.ToString());
        GUILayout.Label(PhotonNetwork.connectionState.ToString());
    }