public override void OnReceivedRoomListUpdate ( )
    {
        roomsList = PhotonNetwork.GetRoomList ( );
        Debug.Log ( "Added Room" );

        if ( roomsList != null )
        {
            for ( int i = 0 ; i < roomsList.Length ; i++ )
            {
                Debug.Log ( roomsList [ i ].Name );

                if ( !PhotonNetwork.isMasterClient )
                {
                    GameObject roomObj = Instantiate ( roomPrefab, GameObject.Find ( "Content" ).transform );
                    RoomPrefabScript roomData = roomObj.GetComponent<RoomPrefabScript> ( );
                    roomData.SetRoomName ( roomsList [ i ].Name );
                    roomData.SetMaxPlayer ( roomsList [ i ].MaxPlayers );
                    roomPrefabs.Add ( roomObj );
                }
                else
                {
                    GameObject roomObj = PhotonNetwork.Instantiate ( "RoomInfo", GameObject.Find ( "Content" ).transform.position, Quaternion.identity, 0 );
                    RoomPrefabScript roomData = roomObj.GetComponent<RoomPrefabScript> ( );
                    roomData.SetRoomName ( roomsList [ i ].Name );
                    roomData.SetMaxPlayer ( roomsList [ i ].MaxPlayers );
                    roomPrefabs.Add ( roomObj );
                }
            }
        }       
    }
Beispiel #2
0
    public void CreateRoomListObject(string roomName, int players)
    {
        Debug.Log("Instantiated object to roomlist");

        GameObject roomObject = Instantiate(_roomObject, transform) as GameObject;

        _roomData = roomObject.GetComponent <RoomPrefabScript> ( );
        _roomData.SetRoomName(roomName);
        _roomData.SetMaxPlayer(players);

        RoomOptions roomOptions = new RoomOptions( );

        roomOptions.MaxPlayers = ( byte )players;

        PhotonNetwork.CreateRoom(roomName, roomOptions, TypedLobby.Default);
    }
    /// <summary>
    /// Refresh roomlist by clicking refresh button
    /// </summary>
    public void RefreshRoomList()
    {
        if (roomPrefabs.Count >0)
        {
            for ( int i = 0 ; i < roomPrefabs.Count ; i++ )
            {
                Destroy ( roomPrefabs [ i ] );
            }

            roomPrefabs.Clear ( );

        }
         
        if ( roomsList != null )
        {
            for ( int i = 0 ; i < roomsList.Length ; i++ )
            {
                Debug.Log ( roomsList [ i ].Name );
                
                if ( !PhotonNetwork.isMasterClient )
                {
                    GameObject roomObj = Instantiate ( roomPrefab, GameObject.Find ( "Content" ).transform );
                    RoomPrefabScript roomData = roomObj.GetComponent<RoomPrefabScript> ( );
                    roomData.SetRoomName ( roomsList [ i ].Name );
                    roomData.SetMaxPlayer ( roomsList [ i ].MaxPlayers );
                    roomPrefabs.Add ( roomObj );
                }
                else
                {
                    GameObject roomObj = PhotonNetwork.Instantiate ( "RoomInfo", GameObject.Find ( "Content" ).transform.position, Quaternion.identity, 0 );
                    RoomPrefabScript roomData = roomObj.GetComponent<RoomPrefabScript> ( );
                    roomData.SetRoomName ( roomsList [ i ].Name );
                    roomData.SetMaxPlayer ( roomsList [ i ].MaxPlayers );
                    roomPrefabs.Add ( roomObj );
                }
            }
        }
    }