Beispiel #1
0
    public void FindPlayers(GameSparksController.NoMatchCallback noMatchCallback, GameSparksController.MatchCallback matchCallback)
    {
        DebugTool.Instance().SetMessage(new DebugMessage("GSM| Attempting Matchmaking...", DebugMessageType.Message));

        new GameSparks.Api.Requests.MatchmakingRequest()
        .SetMatchShortCode("S_CHAT") // set the shortCode to be the same as the one we created in the first tutorial
        .SetSkill(0)                 // in this case we assume all players have skill level zero and we want anyone to be able to join so the skill level for the request is set to zero
        .Send((response) =>
        {
            if (response.HasErrors)
            {     // check for errors
                DebugTool.Instance().SetMessage(new DebugMessage("GSM| MatchMaking Error \n", DebugMessageType.Error));
            }
        });

        GameSparks.Api.Messages.MatchNotFoundMessage.Listener = (message) =>
        {
            noMatchCallback();
        };

        GameSparks.Api.Messages.MatchFoundMessage.Listener = (_message) =>
        {
            DebugTool.Instance().SetMessage(new DebugMessage("Match Found!", DebugMessageType.Message));

            StringBuilder sBuilder = new StringBuilder();
            sBuilder.AppendLine("Match Found...");
            sBuilder.AppendLine("Host URL:" + _message.Host);
            sBuilder.AppendLine("Port:" + _message.Port);
            sBuilder.AppendLine("Access Token:" + _message.AccessToken);
            sBuilder.AppendLine("MatchId:" + _message.MatchId);
            sBuilder.AppendLine("Opponents:" + _message.Participants.Count());
            sBuilder.AppendLine("_________________");
            sBuilder.AppendLine(); // we'll leave a space between the player-list and the match data
            foreach (GameSparks.Api.Messages.MatchFoundMessage._Participant player in _message.Participants)
            {
                sBuilder.AppendLine("Player:" + player.PeerId + " User Name:" + player.DisplayName); // add the player number and the display name to the list
            }

            DebugTool.Instance().SetMessage(new DebugMessage(sBuilder.ToString(), DebugMessageType.Message));

            matchCallback(_message, sBuilder.ToString());
        };
    }
Beispiel #2
0
    /*------------------------------------------------------------------------------------------------------------------------------------------------------
     * -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

    public void FindPlayers(GameSparksController.NoMatchCallback noMatchCallback,
                            GameSparksController.MatchCallback matchCallback)
    {
    }