/// <summary> /// callback method for native code to communicate events back to unity /// </summary> public static void PlayerReceived(string json) { if (PlayerReceivedEvent != null) { var ht = json.hashtableFromJson(); PlayerReceivedEvent(AGSPlayer.fromHashtable(ht)); } }
public static AGSRequestPlayerResponse GetBlankResponseWithError(string error, int userData = 0) { AGSRequestPlayerResponse response = new AGSRequestPlayerResponse(); response.error = error; response.userData = userData; response.player = AGSPlayer.GetBlankPlayer(); return(response); }
/// <summary> /// Callback for handling errors attempting to retrieve the local player. /// </summary> /// <param name='errorMessage'> /// Error message. /// </param> private void PlayerFailed(string errorMessage) { playerStatus = playerFailedLabel; playerStatusMessage = errorMessage; this.player = null; // no longer need to subscribe after a callback has occured. UnsubscribeFromPlayerEvents(); }
/// <summary> /// Callback for receiving player information. /// </summary> /// <param name='player'> /// GameCircle player information /// </param> private void PlayerReceived(AGSPlayer player) { // Update the menu information to show the received player. playerStatus = playerReceivedLabel; playerStatusMessage = null; this.player = player; // no longer need to subscribe after a callback has occured. UnsubscribeFromPlayerEvents(); }
/// <summary> /// Callback for receiving player information. /// </summary> /// <param name='player'> /// GameCircle player information /// </param> private void PlayerReceived(AGSPlayer player) { // Update the menu information to show the received player. playerStatus = playerReceivedLabel; playerStatusMessage = null; this.player = player; RequestAchievements(); // Get achievements of current player UnsubscribeFromPlayerEvents(); }
public static AGSScore fromHashtable(Hashtable scoreHashTable) { var score = new AGSScore(); score.player = AGSPlayer.fromHashtable(scoreHashTable["player"] as Hashtable); score.rank = int.Parse(scoreHashTable["rank"].ToString()); score.scoreString = scoreHashTable["scoreString"].ToString(); score.scoreValue = long.Parse(scoreHashTable["score"].ToString()); return(score); }
public static AGSLeaderboardPercentile fromHashTable(Hashtable percentilesHashtable) { AGSLeaderboardPercentile leaderboardPercentile = new AGSLeaderboardPercentile(); try { leaderboardPercentile.percentile = int.Parse(percentilesHashtable[percentileKey].ToString()); leaderboardPercentile.score = long.Parse(percentilesHashtable[scoreKey].ToString()); } catch (FormatException e) { AGSClient.Log("Unable to parse percentile item " + e.Message); } leaderboardPercentile.player = AGSPlayer.fromHashtable(percentilesHashtable[playerKey] as Hashtable); return(leaderboardPercentile); }
public static AGSRequestPlayerResponse FromJSON(string json) { try { AGSRequestPlayerResponse response = new AGSRequestPlayerResponse(); Hashtable hashtable = json.hashtableFromJson(); response.error = hashtable.ContainsKey("error") ? hashtable ["error"].ToString() : ""; response.userData = hashtable.ContainsKey("userData") ? int.Parse(hashtable ["userData"].ToString()) : 0; response.player = hashtable.ContainsKey("player") ? AGSPlayer.fromHashtable(hashtable ["player"] as Hashtable) : AGSPlayer.GetBlankPlayer(); return(response); } catch (Exception e) { AGSClient.LogGameCircleError(e.ToString()); return(GetBlankResponseWithError(JSON_PARSE_ERROR)); } }
/// <summary> /// Raises the signed in state changed event. /// </summary> /// <param name="isSignedIn">If set to <c>true</c>, the local player is signed in.</param> private void OnSignedInStateChanged(Boolean isSignedIn) { if (isSignedIn) { Debug.Log("Signedin"); WhisperPlayerScores.Instance.SynchronizeScores(); RequestLocalPlayerData(); } else { Debug.Log("NotSignedin"); achievementList.Clear(); achievementList = null; player = null; } }
public static AGSRequestBatchFriendsResponse GetBlankResponseWithError(string error, List <String> friendIdsRequested = null, int userData = 0) { AGSRequestBatchFriendsResponse response = new AGSRequestBatchFriendsResponse(); response.error = error; response.friends = new List <AGSPlayer> (); if (friendIdsRequested != null) { foreach (string friendId in friendIdsRequested) { response.friends.Add(AGSPlayer.BlankPlayerWithID(friendId)); } } response.userData = userData; return(response); }
public static AGSRequestBatchFriendsResponse FromJSON(string json) { try { AGSRequestBatchFriendsResponse response = new AGSRequestBatchFriendsResponse(); Hashtable hashtable = json.hashtableFromJson(); response.error = hashtable.ContainsKey("error") ? hashtable ["error"].ToString() : ""; response.userData = hashtable.ContainsKey("userData") ? int.Parse(hashtable ["userData"].ToString()) : 0; response.friends = new List <AGSPlayer>(); if (hashtable.ContainsKey("friends")) { foreach (Hashtable playerHashtable in hashtable["friends"] as ArrayList) { response.friends.Add(AGSPlayer.fromHashtable(playerHashtable)); } } return(response); } catch (Exception e) { AGSClient.LogGameCircleError(e.ToString()); return(GetBlankResponseWithError(JSON_PARSE_ERROR)); } }
/// <summary> /// Authenticate the local user with the active Social plugin. /// </summary> /// <param name='callback'> /// Callback. /// </param> public void Authenticate(System.Action <bool> callback) { // The Unity Social API implies a heavy connection between // initialization of the Social API and the local user. // http://docs.unity3d.com/Documentation/Components/net-SocialAPI.html // This means that the local player should be available as early as possible. callback += (successStatus) => { if (successStatus) { // On a successful initialization of the GameCircle through // the Unity Social API, immediately begin the process // of retrieving the local player. AGSPlayerClient.PlayerReceivedEvent += (player) => { this.player = player; }; AGSPlayerClient.RequestLocalPlayer(); } else { player = null; } }; Social.Active.Authenticate(this, callback); }
private void OnPlayerRequestCompleted(AGSRequestPlayerResponse response) { if (response.IsError ()) { playerStatus = playerFailedLabel; playerStatusMessage = response.error; this.player = null; } else { playerStatus = playerReceivedLabel; playerStatusMessage = null; this.player = response.player; } }
public AGSSocialUser() { player = AGSPlayer.GetBlankPlayer(); }
public AGSSocialUser(AGSPlayer player) { this.player = player == null?AGSPlayer.GetBlankPlayer() : player; }
/// <summary> /// Authenticate the local user with the active Social plugin. /// </summary> /// <param name='callback'> /// Callback. /// </param> public void Authenticate(System.Action<bool> callback) { // The Unity Social API implies a heavy connection between // initialization of the Social API and the local user. // http://docs.unity3d.com/Documentation/Components/net-SocialAPI.html // This means that the local player should be available as early as possible. callback += (successStatus) => { if(successStatus) { // On a successful initialization of the GameCircle through // the Unity Social API, immediately begin the process // of retrieving the local player. AGSPlayerClient.PlayerReceivedEvent += (player) => { this.player = player; }; AGSPlayerClient.RequestLocalPlayer(); } else { player = null; } }; Social.Active.Authenticate(this,callback); }
//-------------------------------------- // INITIALIZE //-------------------------------------- #if AMAZON_CIRCLE_ENABLED public GC_Player(AGSPlayer player) { this._name = player.alias; this._playerId = player.playerId; this._avatarUrl = player.avatarUrl; }