Example #1
0
    // Requests uZone to start a new instance
    protected virtual void StartInstanceAsync()
    {
        // Add to list by map name
        if (!mapNameToInstances.ContainsKey(_mapName))
        {
            mapNameToInstances[_mapName] = new List <LobbyGameInstance <T> >();
        }

        mapNameToInstances[_mapName].Add(this);

        waitingForServer.Add(this);

        options = new uZone.InstanceOptions(LobbyInstanceManager.gameName, cmdLine);

        // Request uZone to start a new instance
        uZone.InstanceManager.StartInstance(
            options,
            LobbyInstanceManager.instance.nodeSelectionMode,
            (request) => {
            // Success
            instance = request.GetInstance();
            idToInstance[instance.id] = this;
            StartPlaying();
        }, (request) => {
            // Failure
            LogManager.General.LogError("Couldn't start instance: " + request);
        }
            );
    }
Example #2
0
    // Helper function
    private void ConnectToGameServer(uZone.InstanceProcess instance)
    {
        LogManager.General.Log("Connecting player '" + name + "' to " + gameInstance);

        var ip   = instance.node.publicAddress;
        var port = instance.port;

        // Connect player to server
        Lobby.RPC("ConnectToGameServer", peer, ip, port);

        // Update location
        location.ip   = ip;
        location.port = port;
        LocationsDB.SetLocation(accountId, location, null);
    }