예제 #1
0
        void Awake()
        {
            GameSparks.Api.Messages.MatchNotFoundMessage.Listener = (message) =>
            {
                Debug.Log("No Match Found");
            };

            GameSparks.Api.Messages.MatchFoundMessage.Listener += OnMatchFound;

            GameSparks.Core.GS.GameSparksAvailable += (isAvailable) =>
            {
                if (isAvailable && GameSparksManager.PeerId() == -1)
                {
                    if (useDeviceAuth)
                    {
                        GameSparksManager.Instance().DeviceAuthentication(OnAuthentication);
                    }
                    else
                    {
                        GameSparksManager.Instance().AuthenticateUser(userName, password, OnRegistration, OnAuthentication);
                    }
                }
            };
        }
예제 #2
0
        private void OnMatchFound(GameSparks.Api.Messages.MatchFoundMessage _message)
        {
            searchingPanel.SetActive(false);
            foundPanel.SetActive(true);

            Debug.Log("Match Found!...");
            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
            }
            matchDetails.text = sBuilder.ToString();                                                 // set the string to be the player-list field

            GameSparksManager.Instance().StartNewRTSession(new RTSessionInfo(_message));
        }
예제 #3
0
 void UpdateUserStatus()
 {
     userStatus.text =
         (GameSparks.Core.GS.Available ? "Connected" : "Disconnected") +
         ((GameSparks.Core.GS.Authenticated && GameSparksManager.Instance().user != null) ? " | Logged in as " + GameSparksManager.Instance().user.displayName : " | Not authenticated");
 }
예제 #4
0
 public static void SendPacket(NetworkObject networkObject, RTData data, GameSparksRT.DeliveryIntent intent)
 {
     data.SetString((int)DataIndex.NetworkId, networkObject.networkId);
     GameSparksManager.Instance().SendRTData(OpCodes.NetworkObject, intent, data);
 }
예제 #5
0
 private void OnAuthentication(AuthenticationResponse _resp)
 {
     GameSparksManager.Instance().FindPlayers(matchShortCode);
 }
예제 #6
0
 private void OnRegistration(RegistrationResponse _resp)
 {
     GameSparksManager.Instance().FindPlayers(matchShortCode);
 }
예제 #7
0
 void OnReadyButton()
 {
     GameSparksManager.Instance().SetPlayerReady(true);
     readyButton.interactable = false;
 }
예제 #8
0
 void UpdateUserStatus()
 {
     userStatus.text = (GameSparks.Core.GS.Available ? "Connected" : "Disconnected") + " | Logged in as " +
                       GameSparksManager.Instance().user.displayName;
 }