public void Authenticate(ILocalUser user, Action <bool, string> callback) { authenticationCallback = b => { callback.Invoke(b, string.Empty); }; AGSClient.Init(/*Leaderboards*/ true, /*Achievements*/ true, /*Whispersync*/ false); }
/// <summary> /// Sets the syncable value of a GameCircle syncable number associated with this syncableNumberHelper. /// Also sets the metadata for that value. /// </summary> /// <param name='syncableNumber'> /// Syncable number. /// </param> void SetSyncableValueWithMetadata(AGSSyncableNumber syncableNumber) { if (null == syncableNumber) { return; } switch (type) { case AvailableSyncableNumberType.Int: syncableNumber.Set(intNumber, defaultMetadataDictionary); break; case AvailableSyncableNumberType.Double: syncableNumber.Set(doubleNumber, defaultMetadataDictionary); break; case AvailableSyncableNumberType.Long: syncableNumber.Set(longNumber, defaultMetadataDictionary); break; case AvailableSyncableNumberType.String: syncableNumber.Set(stringNumber, defaultMetadataDictionary); break; default: AGSClient.LogGameCircleWarning(unhandledSyncableNumberTypeError); break; } }
public void requestAchievementsSucceeded(string json) { AGSClient.Log("GameCircleManager - requestAchievementsSucceeded"); AGSAchievementsClient. RequestAchievementsSucceeded(json); }
public void serviceNotReady(string param) { Debug.Log("GameCircleManager - serviceNotReady"); AGSClient. ServiceNotReady(param); }
/// <summary> /// Gets a GameCircle syncable number out of the data map. /// The SyncableNumber retrieved is based on the behavior of this syncable number helper. /// </summary> /// <returns> /// The syncable number. /// </returns> /// <param name='dataMap'> /// GameCircle data map. /// </param> AGSSyncableNumber GetSyncableNumber(AGSGameDataMap dataMap) { if (null == dataMap) { return(null); } // using the behavior and type is a convenient way to create variable names. string variableName = BehaviorAndTypeAsString(); switch (behavior) { case SyncableNumberBehavior.Highest: return(dataMap.GetHighestNumber(variableName)); case SyncableNumberBehavior.Lowest: return(dataMap.GetLowestNumber(variableName)); case SyncableNumberBehavior.Latest: return(dataMap.GetLatestNumber(variableName)); default: AGSClient.LogGameCircleWarning(unhandledSyncableNumberTypeError); return(null); } }
/// <summary> /// Loads any available cloud data (if signed in and cloud saving is enabled). /// </summary> public void Load() { if (!AmazonCloudProvider.Instance.CloudSaveInitialized || !Cloud.CloudSaveEnabled) { #if CO_DEBUG Debug.LogWarning(!AmazonCloudProvider.Instance.CloudSaveInitialized ? "Cloud Save has not been initialized, aborting cloud load." : "Cloud Save is currently disabled, aborting cloud load."); #endif cloudOnceEvents.RaiseOnCloudLoadComplete(false); return; } if (AGSClient.IsServiceReady()) { #if CO_DEBUG Debug.Log("Loading cloud data"); #endif AGSWhispersyncClient.Synchronize(); cloudOnceEvents.RaiseOnCloudLoadComplete(true); } else { Debug.LogWarning("Attempted to load cloud data, but the AGS service is not ready."); cloudOnceEvents.RaiseOnCloudLoadComplete(false); } }
public void serviceReady(string empty) { Debug.Log("GameCircleManager - serviceReady"); AGSClient. ServiceReady(empty); }
/// <summary> /// Gets the syncable value of a GameCircle syncable number associated with this syncableNumberHelper. /// Stores it in the local variable that matches this syncable number helper's type. /// </summary> /// <param name='syncableNumber'> /// Syncable number. /// </param> void GetSyncableValue(AGSSyncableNumber syncableNumber) { if (null == syncableNumber) { return; } switch (type) { case AvailableSyncableNumberType.Int: intNumber = syncableNumber.AsInt(); break; case AvailableSyncableNumberType.Double: doubleNumber = syncableNumber.AsDouble(); break; case AvailableSyncableNumberType.Long: longNumber = syncableNumber.AsLong(); break; case AvailableSyncableNumberType.String: stringNumber = syncableNumber.AsString(); break; default: AGSClient.LogGameCircleWarning(unhandledSyncableNumberTypeError); break; } }
public void submitScoreFailed(string json) { AGSClient.Log("GameCircleManager - submitScoreFailed"); AGSLeaderboardsClient. SubmitScoreFailed(json); }
public static AGSRequestScoresResponse FromJSON(string json) { try { AGSRequestScoresResponse response = new AGSRequestScoresResponse(); Hashtable hashtable = json.hashtableFromJson(); response.error = hashtable.ContainsKey("error") ? hashtable ["error"].ToString() : ""; response.userData = hashtable.ContainsKey("userData") ? int.Parse(hashtable ["userData"].ToString()) : 0; response.leaderboardId = hashtable.ContainsKey("leaderboardId") ? hashtable ["leaderboardId"].ToString() : ""; if (hashtable.ContainsKey("leaderboard")) { response.leaderboard = AGSLeaderboard.fromHashtable(hashtable ["leaderboard"] as Hashtable); } else { response.leaderboard = AGSLeaderboard.GetBlankLeaderboard(); } response.scores = new List <AGSScore> (); if (hashtable.Contains("scores")) { foreach (Hashtable scoreHashtable in hashtable["scores"] as ArrayList) { response.scores.Add(AGSScore.fromHashtable(scoreHashtable)); } } response.scope = (LeaderboardScope)Enum.Parse(typeof(LeaderboardScope), hashtable["scope"].ToString()); return(response); } catch (Exception e) { AGSClient.LogGameCircleError(e.ToString()); return(GetBlankResponseWithError(JSON_PARSE_ERROR)); } }
public void playerReceived(string json) { AGSClient.Log("GameCircleManager - playerReceived"); AGSPlayerClient. PlayerReceived(json); }
/// <summary> /// Syncables the method to list behavior. /// </summary> /// <returns> /// The method to list behavior. /// </returns> /// <param name='syncableMethod'> /// Syncable method. /// </param> SyncableListBehavior SyncableMethodToListBehavior(SyncableMethod syncableMethod) { switch (syncableMethod) { case SyncableMethod.getHighestNumber: case SyncableMethod.getHighNumberList: return(SyncableListBehavior.HighNumber); case SyncableMethod.getLatestNumber: case SyncableMethod.getLatestNumberList: return(SyncableListBehavior.LatestNumber); case SyncableMethod.getLowestNumber: case SyncableMethod.getLowNumberList: return(SyncableListBehavior.LowNumber); case SyncableMethod.getLatestString: case SyncableMethod.getLatestStringList: return(SyncableListBehavior.LatestString); default: AGSClient.LogGameCircleError(string.Format("Unhandled AGSSyncableNumberList type {0}", syncableMethod.ToString())); // still need to return something if error logging is set to a level less than exception. return(SyncableListBehavior.HighNumber); } }
/// <summary> /// callback method for native code to communicate events back to unity /// </summary> public static void RequestLocalPlayerScoreSucceeded(string json) { if (RequestLocalPlayerScoreSucceededEvent != null) { var ht = json.hashtableFromJson(); int rank = 0; long score = 0; string leaderboardId = null; try{ if (ht.Contains("leaderboardId")) { leaderboardId = ht["leaderboardId"].ToString(); } if (ht.Contains("rank")) { rank = int.Parse(ht["rank"].ToString()); } if (ht.Contains("score")) { score = long.Parse(ht["score"].ToString()); } }catch (FormatException e) { AGSClient.Log("unable to parse score " + e.Message); } RequestLocalPlayerScoreSucceededEvent(leaderboardId, rank, score); } }
/// <summary> /// Initializes a new instance of the <see cref="AGSPlayer"/> class. /// This constructor is private because this class should only be /// instantiated through fromHashtable /// </summary> private AGSPlayer() { alias = null; playerId = null; avatarUrl = null; AGSClient.LogGameCircleError("AGSPlayer was instantiated without valid information."); }
/// <summary> /// Authenticate the specified user and callback. /// </summary> /// <param name='user'> /// User. /// </param> /// <param name='callback'> /// Callback. /// </param> public void Authenticate(ILocalUser user, System.Action <bool> callback) { // Forward the AGSClient callbacks to the passed in callback. authenticationCallback = callback; // If using GameCircle with the Unity Social API, // initialize it with leaderboards and achievements, but not whispersync. AGSClient.Init(/*Leaderboards*/ true, /*Achievements*/ true, /*Whispersync*/ false); }
public void OnAppplicationQuit() { AGSClient.Log("GameCircleManager - OnApplicationQuit"); if (AGSClient.IsServiceReady()) { AGSClient.Shutdown(); } }
//-------------------------------------- // PRIVATE API CALL METHODS //-------------------------------------- private void Init() { _isInitialized = true; #if AMAZON_CIRCLE_ENABLED AGSClient.Init(true, true, true); #endif }
private void ProcessCloudData() { if (processingCloudData) { return; } processingCloudData = true; if (AGSClient.IsServiceReady()) { using (var dataMap = AGSWhispersyncClient.GetGameData()) { using (var developerString = dataMap.getDeveloperString(DataManager.DevStringKey)) { var cloudValue = developerString.getCloudValue(); if (string.IsNullOrEmpty(cloudValue)) { #if CO_DEBUG Debug.Log("No data saved to the cloud yet."); #endif processingCloudData = false; return; } if (!cloudValue.IsJson()) { try { cloudValue = cloudValue.FromBase64StringToString(); } catch (FormatException) { Debug.LogWarning("Unable to deserialize cloud data!"); return; } } #if CO_DEBUG Debug.Log("Processing cloud data"); #endif var changedKeys = DataManager.MergeLocalDataWith(cloudValue); if (changedKeys.Length > 0) { cloudOnceEvents.RaiseOnNewCloudValues(changedKeys); } processingCloudData = false; } } } else { processingCloudData = false; #if CO_DEBUG Debug.LogWarning("Attempting to process cloud data, but the AGS service is not ready!"); #endif } }
/// <summary> /// Unity / MonoBehaviour function for GUI behaviour. /// </summary> void OnGUI() { // Some initialization behaviour can only be called from within the OnGUI function. // initialize UI early returns if it is already initialized InitializeUI(); // This menu has a local UI skin with buttons scaled up, and other touch enhancements. ApplyLocalUISkin(); AmazonGUIHelpers.BeginMenuLayout(); // Wrapping all of the menu in a scroll view allows the individual menu systems to not need to handle being off screen. scroll = GUILayout.BeginScrollView(scroll); // Display if the GameCircle plugin is ready.. AmazonGUIHelpers.CenteredLabel(string.Format(isServiceReadyLabel, AGSClient.IsServiceReady())); // If GameCircle is not initialized, display the initialization menu. if (initializationMenu.InitializationStatus != AmazonGameCircleExampleInitialization.EInitializationStatus.Ready) { initializationMenu.DrawMenu(); } else { // This button opens the generic GameCircle overlay. if (GUILayout.Button(gameCircleOverlayButtonLabel)) { AGSClient.ShowGameCircleOverlay(); } // This button opens the GameCircle sign in page. if (GUILayout.Button(gameCircleSignInButtonLabel)) { AGSClient.ShowSignInPage(); } // Once GameCircle is initialized, display all submenus, for achievements, leaderboards, and other GameCircle features. foreach (AmazonGameCircleExampleBase subMenu in gameCircleExampleMenus) { GUILayout.BeginVertical(GUI.skin.box); subMenu.foldoutOpen = AmazonGUIHelpers.FoldoutWithLabel(subMenu.foldoutOpen, subMenu.MenuTitle()); if (subMenu.foldoutOpen) { subMenu.DrawMenu(); } GUILayout.EndVertical(); } } GUILayout.EndScrollView(); AmazonGUIHelpers.EndMenuLayout(); // If the UI skin is not reverted at the end of the function, // any other OnGUI behavior might end up using the settings applied here. RevertLocalUISkin(); }
/// <summary> /// Loads this local user's friends list. /// </summary> /// <param name='callback'> /// Callback. /// </param> public void LoadFriends(System.Action <bool> callback) { AGSClient.LogGameCircleError("ILocalUser.LoadFriends is not available for GameCircle"); // Call the callback with a "false" to let it know the friends list was not loaded. if (null != callback) { callback(false); } }
/// <summary> /// Loads the friends. /// </summary> /// <param name='user'> /// User. /// </param> /// <param name='callback'> /// Callback. /// </param> public void LoadFriends(ILocalUser user, System.Action <bool> callback) { if (user == null) { AGSClient.LogGameCircleError("LoadFriends \"user\" argument should not be null"); return; } user.LoadFriends(callback); }
/// <summary> /// Loads the scores. /// </summary> /// <param name='board'> /// Board. /// </param> /// <param name='callback'> /// Callback. /// </param> public void LoadScores(ILeaderboard board, System.Action <bool> callback) { // This function doesn't do anything with a null leaderboard. if (null == board) { AGSClient.LogGameCircleError("LoadScores \"board\" argument should not be null"); return; } board.LoadScores(callback); }
/// <summary> /// Shuts down the GameCircle service. /// </summary> public override void SignOut() { if (!AGSClient.IsServiceReady()) { // Not signed in, ignoring call. return; } AGSClient.Shutdown(); }
/// <summary> /// Gets the loading status of the leaderboard. /// </summary> /// <returns> /// The loading. /// </returns> /// <param name='board'> /// If set to <c>true</c> board. /// </param> public bool GetLoading(ILeaderboard board) { // This function doesn't do anything with a null leaderboard. if (null == board) { AGSClient.LogGameCircleError("GetLoading \"board\" argument should not be null"); return(false); } return(board.loading); }
private void Start() { if (AGSClient.IsServiceReady() && AGSPlayerClient.IsSignedIn()) { if (Managers.GameCircleAmazon.achievementList == null) { Managers.GameCircleAmazon.RequestAchievements(); } } }
/// <summary> /// Initializes a new instance of the <see cref="AGSSocialAchievementDescription"/> class. /// </summary> /// <param name='achievement'> /// Achievement. /// </param> public AGSSocialAchievementDescription(AGSAchievement achievement) { if (null == achievement) { AGSClient.LogGameCircleError("AGSSocialAchievementDescription constructor \"achievement\" argument should not be null"); return; } this.achievement = achievement; id = achievement.id; }
/// <summary> /// Initializes a new instance of the <see cref="AGSSocialLeaderboard"/> class. /// </summary> /// <param name='leaderboard'> /// Leaderboard. /// </param> public AGSSocialLeaderboard(AGSLeaderboard leaderboard) { if (null == leaderboard) { AGSClient.LogGameCircleError("AGSSocialLeaderboard constructor \"leaderboard\" argument should not be null"); return; } this.leaderboard = leaderboard; id = leaderboard.id; }
/// <summary> /// Initializes the native function calls. /// </summary> void InitializeNativeFunctionCalls() { #if !UNITY_EDITOR switch (listBehavior) { case SyncableListBehavior.HighNumber: setListMaxSize = _AmazonGCWSSetHighNumberListMaxSize; getListMaxSize = _AmazonGCWSGetHighNumberListMaxSize; isListSet = _AmazonGCWSHighNumberListIsSet; addStringWithMetadataToList = _AmazonGCWSHighNumberListAddStringAndMetadataAsJSON; addStringToList = _AmazonGCWSHighNumberListAddString; getTimestampAtIndex = _AmazonGCWSGetHighNumberListTimestampAtIndex; getMetadataAtIndex = _AmazonGCWSGetHighNumberListMetadataAtIndex; getListCount = _AmazonGCWSGetHighNumberListCount; break; case SyncableListBehavior.LatestNumber: setListMaxSize = _AmazonGCWSSetLatestNumberListMaxSize; getListMaxSize = _AmazonGCWSGetLatestNumberListMaxSize; isListSet = _AmazonGCWSLatestNumberListIsSet; addStringWithMetadataToList = _AmazonGCWSLatestNumberListAddStringAndMetadataAsJSON; addStringToList = _AmazonGCWSLatestNumberListAddString; getTimestampAtIndex = _AmazonGCWSGetLatestNumberListTimestampAtIndex; getMetadataAtIndex = _AmazonGCWSGetLatestNumberListMetadataAtIndex; getListCount = _AmazonGCWSGetLatestNumberListCount; break; case SyncableListBehavior.LowNumber: setListMaxSize = _AmazonGCWSSetLowNumberListMaxSize; getListMaxSize = _AmazonGCWSGetLowNumberListMaxSize; isListSet = _AmazonGCWSLowNumberListIsSet; addStringWithMetadataToList = _AmazonGCWSLowNumberListAddStringAndMetadataAsJSON; addStringToList = _AmazonGCWSLowNumberListAddString; getTimestampAtIndex = _AmazonGCWSGetLowNumberListTimestampAtIndex; getMetadataAtIndex = _AmazonGCWSGetLowNumberListMetadataAtIndex; getListCount = _AmazonGCWSGetLowNumberListCount; break; case SyncableListBehavior.LatestString: setListMaxSize = _AmazonGCWSSetLatestStringListMaxSize; getListMaxSize = _AmazonGCWSGetLatestStringListMaxSize; isListSet = _AmazonGCWSLatestStringListIsSet; addStringWithMetadataToList = _AmazonGCWSLatestStringListAddStringAndMetadataAsJSON; addStringToList = _AmazonGCWSLatestStringListAddString; getTimestampAtIndex = _AmazonGCWSGetLatestStringListTimestampAtIndex; getMetadataAtIndex = _AmazonGCWSGetLatestStringListMetadataAtIndex; getListCount = _AmazonGCWSGetLatestStringListCount; break; default: AGSClient.LogGameCircleError(string.Format("Unhandled Whispersync list behavior {0}", listBehavior.ToString())); break; } #endif }
public void ShowAchievementsPage() { if (AGSClient.IsServiceReady()) { AGSAchievementsClient.ShowAchievementsOverlay(); } else { Debug.Log("Show sigin page Service NOOOOOOT Ready"); } }
public void ShowLeaderBoardPage() { if (AGSClient.IsServiceReady()) { AGSLeaderboardsClient.ShowLeaderboardsOverlay(); } else { Debug.Log("Show sigin page Service NOOOOOOT Ready"); } }
static async Task DoWork() { var ags = new AGSClient("https://philmbprowin.esri.com:6443/arcgis/admin/", "admin", "demopw"); await ags.Authenticate(); Console.Out.WriteLine("Authenticated against {0}: {1}", ags.ServerUrl, ags.IsAuthenticated); Console.Out.WriteLine("Session expires at {0}", ags.TokenExpiration.ToLocalTime()); Console.Out.WriteLine("------------------"); // get last 12 hours of log entries, do some statistics on them var logEntries = await ags.GetLogs(LogMessage.LogType.Info, DateTime.Now, DateTime.Now.AddHours(-12)); int severeCount = (from entry in logEntries where entry.type == LogMessage.LogType.Severe select entry).Count(); Console.Out.WriteLine(string.Format("The server had {0} severe events in the past hour!", severeCount)); Console.Out.WriteLine("------------------"); // get status of all services in all folders var folders = await ags.GetFolderNames(); Console.Out.WriteLine("The following folders are defined on the server:"); Console.Out.WriteLine("/"); foreach (string folder in folders) { Console.Out.WriteLine(folder); } Console.Out.WriteLine("------------------"); var serviceStatus = await ags.GetAllServiceReports(); foreach (string folder in serviceStatus.Keys) { Console.Out.WriteLine(folder); foreach (var report in serviceStatus[folder]) { Console.Out.WriteLine(string.Format(" - {0}: {1}", report.serviceName, report.status.realTimeState.ToString())); } } Console.Out.WriteLine("------------------"); // upload a pre-created .sd to create a new service //Console.Out.WriteLine(@"Uploading C:\Presentations\Demo.sd.."); //var publishResponse = await ags.PublishServiceDefinition(new System.IO.FileInfo(@"C:\Presentations\Demo.sd")); }