Esempio n. 1
0
    public void HostGame()
    {
        if (lobby.Equals(CSteamID.Nil) == false)
        {
            Debug.LogError("Lobby already created. Probably already hosting. Must shut down hosting before doing it again.");
            return;
        }

        //Construct the network database. Very important!
        MeshNetworkIdentity databaseID = new MeshNetworkIdentity((ushort)ReservedObjectIDs.DatabaseObject,
                                                                 (ushort)ReservedPrefabIDs.Database,
                                                                 (ulong)GetLocalPlayerID(), true);

        database = game.SpawnDatabase(databaseID).GetComponent <NetworkDatabase>(); //Spawns the database prefab.
        Debug.Log("Registering database.");
        database.AddObject(databaseID, true);                                       //Tells the database that it itself exists (funny)

        //First, we get our own player object, and we make ourselves the provider.
        Player me = ConstructPlayer(SteamUser.GetSteamID());

        Debug.Log("Registering provider.");
        database.AddPlayer(me, true);

        //Actually create the lobby. Password info, etc, will be set after this.
        Debug.Log("Creating Lobby");
        m_LobbyCreated.Set(SteamMatchmaking.CreateLobby(ELobbyType.k_ELobbyTypePrivate, 4));
    }
Esempio n. 2
0
    public void WarmupHosting()
    {
        MeshNetworkIdentity databaseID = new MeshNetworkIdentity((ushort)ReservedObjectIDs.DatabaseObject,
                                                                 (ushort)ReservedPrefabIDs.Database,
                                                                 (ulong)GetLocalPlayerID(), true);

        NetworkDatabase database2 = game.SpawnDatabase(databaseID).GetComponent <NetworkDatabase>(); //Spawns the database prefab.

        Debug.Log("Registering database.");
        database2.AddObject(databaseID, true); //Tells the database that it itself exists (funny)

        //First, we get our own player object, and we make ourselves the provider.
        Player me = ConstructPlayer(SteamUser.GetSteamID());

        Debug.Log("Registering provider.");
        database.AddPlayer(me, true);
    }