Exemplo n.º 1
0
    protected virtual void OnMatchCreated(MultiplayerAPI.CreatedMatchInformation match)
    {
        UFE.multiplayerAPI.OnMatchCreated           -= this.OnMatchCreated;
        UFE.multiplayerAPI.OnMatchCreationError     -= this.OnMatchCreationError;
        UFE.multiplayerAPI.OnPlayerConnectedToMatch += this.OnPlayerConnectedToMatch;

        this.StopSearchingMatchGames();
        this.current_match = new MultiplayerAPI.MatchInformation(match);
        this._triedMatches.Add(this.current_match);

        if (UFE.config.networkOptions.networkService == NetworkService.Unity)
        {
            if (UFE.config.debugOptions.connectionLog)
            {
                Debug.Log("Match Created: " + match.unityNetworkId);
            }
        }
        else
        {
            if (UFE.config.debugOptions.connectionLog)
            {
                Debug.Log("Match Created: " + match.matchName);
            }
        }
        if (UFE.config.debugOptions.connectionLog)
        {
            Debug.Log("Waiting for opponent...");
        }
    }
Exemplo n.º 2
0
    protected virtual void TryConnect()
    {
        // First, we check that we aren't already connected to a client or a server...
        if (!UFE.multiplayerAPI.IsConnected() && !this._connecting)
        {
            MultiplayerAPI.MatchInformation match = null;

            // After that, check if we have found one match with at least one player which isn't already full...
            while (match == null && this._foundServers.Count > 0)
            {
                match = this._foundServers[0];
                this._foundServers.RemoveAt(0);
            }


            if (match != null)
            {
                // In that case, try connecting to that match
                this._connecting = true;

                UFE.multiplayerAPI.OnJoined    += this.OnJoined;
                UFE.multiplayerAPI.OnJoinError += this.OnJoinError;
                UFE.JoinGame(match);
            }
            else
            {
                // Otherwise, return a net a new match
                this.OnLanGameNotFound();
            }
        }
    }
Exemplo n.º 3
0
    protected virtual void TryConnect()
    {
        // First, we check that we aren't already connected to a client or a server...
        if (!UFE.multiplayerAPI.IsConnected() && !this._connecting)
        {
            if (UFE.config.debugOptions.connectionLog)
            {
                Debug.Log("Connecting...");
            }
            MultiplayerAPI.MatchInformation match = null;

            // After that, check if we have found one match with at least one player which isn't already full...
            while (this._foundMatches.Count > 0)
            {
                match = this._foundMatches[0];
                this._foundMatches.RemoveAt(0);
                this._triedMatches.Add(match);

                if (match != null && match.currentPlayers > 0 && match.currentPlayers < match.maxPlayers)
                {
                    // In that case, try connecting to that match
                    this._connecting = true;

                    UFE.multiplayerAPI.OnJoined    += this.OnJoined;
                    UFE.multiplayerAPI.OnJoinError += this.OnJoinError;
                    if (UFE.config.debugOptions.connectionLog)
                    {
                        Debug.Log("Match Found! Joining Match...");
                    }
                    UFE.multiplayerAPI.JoinMatch(match);

                    return;
                }
            }

            // Otherwise, create a new match
            this._connecting = true;
            UFE.multiplayerAPI.OnMatchCreated       += this.OnMatchCreated;
            UFE.multiplayerAPI.OnMatchCreationError += this.OnMatchCreationError;
            UFE.multiplayerAPI.CreateMatch(new MultiplayerAPI.MatchCreationRequest());

            if (UFE.config.debugOptions.connectionLog)
            {
                Debug.Log("No Matches Found. Creating Match...");
            }
        }
    }
Exemplo n.º 4
0
    protected virtual void TryConnect()
    {
        // First, we check that we aren't already connected to a client or a server...
        if (!UFE.multiplayerAPI.IsConnected() && !this._connecting)
        {
            MultiplayerAPI.MatchInformation match = null;

            // After that, check if we have found one match with at least one player which isn't already full...
            while (
                this._foundMatches.Count > 0 &&
                (match == null || match.currentPlayers == 0 || match.currentPlayers >= match.maxPlayers)
                )
            {
                match = this._foundMatches[0];
                this._foundMatches.RemoveAt(0);

                if (match != null && match.currentPlayers > 0 && match.currentPlayers < match.maxPlayers)
                {
                    // In that case, try connecting to that match
                    this._connecting = true;

                    UFE.multiplayerAPI.OnJoined    += this.OnJoined;
                    UFE.multiplayerAPI.OnJoinError += this.OnJoinError;
                    UFE.multiplayerAPI.JoinMatch(match);

                    return;
                }
            }



            // Otherwise, create a new match
            this._connecting = true;
            UFE.multiplayerAPI.OnMatchCreated       += this.OnMatchCreated;
            UFE.multiplayerAPI.OnMatchCreationError += this.OnMatchCreationError;
            UFE.multiplayerAPI.CreateMatch(new MultiplayerAPI.MatchCreationRequest());
        }
    }