/// <summary> /// Shows the achievement descriptions. /// </summary> void ShowAchievementDescriptions() { // This foldout hides the achievement descriptions until the user wishes to see them. achievementsDescriptionsFoldout = AmazonGUIHelpers.FoldoutWithLabel(achievementsDescriptionsFoldout, achievementDescriptionsLabel); if (!achievementsDescriptionsFoldout) { return; } switch (achievementDescriptionStatus) { // If the achievement descriptions have not been retrieved yet, // display a button that begins the retrieval process. case GameCircleSocialExample.AsyncOperationStatus.Inactive: if (GUILayout.Button(retrieveDataButtonLabel)) { achievementDescriptionStatus = GameCircleSocialExample.AsyncOperationStatus.Waiting; Social.LoadAchievementDescriptions(AchievementDescriptionsCallback); } break; // While waiting, display a simple message. case GameCircleSocialExample.AsyncOperationStatus.Waiting: AmazonGUIHelpers.CenteredLabel(waitingLabel); break; // If achievement descriptions were not retrieved, display a message that none are available. case GameCircleSocialExample.AsyncOperationStatus.Failed: AmazonGUIHelpers.CenteredLabel(noAchievementDescriptionsLabel); break; // If the achievement descriptions were retrieved (and are available), display them. case GameCircleSocialExample.AsyncOperationStatus.Success: // If the achievement description list is null or empty, display a message. if (null == achievementDescriptions || 0 == achievementDescriptions.Length) { AmazonGUIHelpers.CenteredLabel(noAchievementDescriptionsLabel); } else { // Display each achievement description, each in its own box. // Have the ID and title on one line, and the description on the next. foreach (IAchievementDescription description in achievementDescriptions) { GUILayout.BeginVertical(GUI.skin.box); GUILayout.BeginHorizontal(); AmazonGUIHelpers.CenteredLabel(description.id); AmazonGUIHelpers.CenteredLabel(description.title); GUILayout.EndHorizontal(); AmazonGUIHelpers.CenteredLabel(description.achievedDescription); GUILayout.EndVertical(); } } break; } }
/// <summary> /// Shows the achievements. /// </summary> void ShowAchievements() { // This foldout will hide the achievement list when the user does not want to see it. achievementsFoldout = AmazonGUIHelpers.FoldoutWithLabel(achievementsFoldout, achievementsLabel); if (!achievementsFoldout) { return; } switch (achievementStatus) { // If the achievements have not been retrieved yet, // display a button that begins the retrieval process. case GameCircleSocialExample.AsyncOperationStatus.Inactive: if (GUILayout.Button(retrieveDataButtonLabel)) { achievementStatus = GameCircleSocialExample.AsyncOperationStatus.Waiting; Social.LoadAchievements(AchievementsCallback); } break; // While waiting, display a simple message. case GameCircleSocialExample.AsyncOperationStatus.Waiting: AmazonGUIHelpers.CenteredLabel(waitingLabel); break; // If achievement descriptions were not retrieved, display a message that none are available. case GameCircleSocialExample.AsyncOperationStatus.Failed: AmazonGUIHelpers.CenteredLabel(noAchievementsLabel); break; // If the achievement descriptions were retrieved (and are available), display them. case GameCircleSocialExample.AsyncOperationStatus.Success: if (null == achievements || 0 == achievements.Length) { // If the list of achievements was null or empty, display a message that // no achievements are available. AmazonGUIHelpers.CenteredLabel(noAchievementDescriptionsLabel); } else { // display each achievement in a box, with the ID and percent complete on the same line. foreach (IAchievement achievement in achievements) { GUILayout.BeginVertical(GUI.skin.box); GUILayout.BeginHorizontal(); AmazonGUIHelpers.CenteredLabel(achievement.id); AmazonGUIHelpers.CenteredLabel(string.Format(achievementPercent, achievement.percentCompleted)); GUILayout.EndHorizontal(); GUILayout.EndVertical(); } } break; } }
/// <summary> /// Callback for retrieving achievement descriptions. /// </summary> /// <param name='descriptions'> /// Descriptions. /// </param> void AchievementDescriptionsCallback(IAchievementDescription [] descriptions) { // If the received list of descriptions was null, then // for the purposes of this sample code, retrieving descriptionss has failed. if (null == descriptions) { achievementDescriptionStatus = GameCircleSocialExample.AsyncOperationStatus.Failed; return; } achievementDescriptionStatus = GameCircleSocialExample.AsyncOperationStatus.Success; achievementDescriptions = descriptions; }
/// <summary> /// Callback for retrieving achievements. /// </summary> /// <param name='descriptions'> /// Descriptions. /// </param> void AchievementsCallback(IAchievement [] achievements) { // If the received list of achievements was null, then // for the purposes of this sample code, retrieving achievements has failed. if (null == achievements) { achievementStatus = GameCircleSocialExample.AsyncOperationStatus.Failed; return; } achievementStatus = GameCircleSocialExample.AsyncOperationStatus.Success; this.achievements = achievements; }
/// <summary> /// Shows the achievements. /// </summary> void ShowAchievements() { // This foldout will hide the achievement list when the user does not want to see it. achievementsFoldout = AmazonGUIHelpers.FoldoutWithLabel(achievementsFoldout,achievementsLabel); if(!achievementsFoldout) { return; } switch(achievementStatus) { // If the achievements have not been retrieved yet, // display a button that begins the retrieval process. case GameCircleSocialExample.AsyncOperationStatus.Inactive: if(GUILayout.Button(retrieveDataButtonLabel)) { achievementStatus = GameCircleSocialExample.AsyncOperationStatus.Waiting; Social.LoadAchievements(AchievementsCallback); } break; // While waiting, display a simple message. case GameCircleSocialExample.AsyncOperationStatus.Waiting: AmazonGUIHelpers.CenteredLabel(waitingLabel); break; // If achievement descriptions were not retrieved, display a message that none are available. case GameCircleSocialExample.AsyncOperationStatus.Failed: AmazonGUIHelpers.CenteredLabel(noAchievementsLabel); break; // If the achievement descriptions were retrieved (and are available), display them. case GameCircleSocialExample.AsyncOperationStatus.Success: if(null == achievements || 0 == achievements.Length) { // If the list of achievements was null or empty, display a message that // no achievements are available. AmazonGUIHelpers.CenteredLabel(noAchievementDescriptionsLabel); } else { // display each achievement in a box, with the ID and percent complete on the same line. foreach(IAchievement achievement in achievements) { GUILayout.BeginVertical(GUI.skin.box); GUILayout.BeginHorizontal(); AmazonGUIHelpers.CenteredLabel(achievement.id); AmazonGUIHelpers.CenteredLabel(string.Format(achievementPercent,achievement.percentCompleted)); GUILayout.EndHorizontal(); GUILayout.EndVertical(); } } break; } }
/// <summary> /// Shows the achievement descriptions. /// </summary> void ShowAchievementDescriptions() { // This foldout hides the achievement descriptions until the user wishes to see them. achievementsDescriptionsFoldout = AmazonGUIHelpers.FoldoutWithLabel( achievementsDescriptionsFoldout, achievementDescriptionsLabel); if(!achievementsDescriptionsFoldout) { return; } switch(achievementDescriptionStatus) { // If the achievement descriptions have not been retrieved yet, // display a button that begins the retrieval process. case GameCircleSocialExample.AsyncOperationStatus.Inactive: if(GUILayout.Button(retrieveDataButtonLabel)) { achievementDescriptionStatus = GameCircleSocialExample.AsyncOperationStatus.Waiting; Social.LoadAchievementDescriptions(AchievementDescriptionsCallback); } break; // While waiting, display a simple message. case GameCircleSocialExample.AsyncOperationStatus.Waiting: AmazonGUIHelpers.CenteredLabel(waitingLabel); break; // If achievement descriptions were not retrieved, display a message that none are available. case GameCircleSocialExample.AsyncOperationStatus.Failed: AmazonGUIHelpers.CenteredLabel(noAchievementDescriptionsLabel); break; // If the achievement descriptions were retrieved (and are available), display them. case GameCircleSocialExample.AsyncOperationStatus.Success: // If the achievement description list is null or empty, display a message. if(null == achievementDescriptions || 0 == achievementDescriptions.Length) { AmazonGUIHelpers.CenteredLabel(noAchievementDescriptionsLabel); } else { // Display each achievement description, each in its own box. // Have the ID and title on one line, and the description on the next. foreach(IAchievementDescription description in achievementDescriptions) { GUILayout.BeginVertical(GUI.skin.box); GUILayout.BeginHorizontal(); AmazonGUIHelpers.CenteredLabel(description.id); AmazonGUIHelpers.CenteredLabel(description.title); GUILayout.EndHorizontal(); AmazonGUIHelpers.CenteredLabel(description.achievedDescription); GUILayout.EndVertical(); } } break; } }
/// <summary> /// Callback for retrieving achievements. /// </summary> /// <param name='descriptions'> /// Descriptions. /// </param> void AchievementsCallback(IAchievement [] achievements) { // If the received list of achievements was null, then // for the purposes of this sample code, retrieving achievements has failed. if(null == achievements) { achievementStatus = GameCircleSocialExample.AsyncOperationStatus.Failed; return; } achievementStatus = GameCircleSocialExample.AsyncOperationStatus.Success; this.achievements = achievements; }
/// <summary> /// Callback for retrieving achievement descriptions. /// </summary> /// <param name='descriptions'> /// Descriptions. /// </param> void AchievementDescriptionsCallback(IAchievementDescription [] descriptions) { // If the received list of descriptions was null, then // for the purposes of this sample code, retrieving descriptionss has failed. if(null == descriptions) { achievementDescriptionStatus = GameCircleSocialExample.AsyncOperationStatus.Failed; return; } achievementDescriptionStatus = GameCircleSocialExample.AsyncOperationStatus.Success; achievementDescriptions = descriptions; }