Class ISN_GKAchievement
An object that communicates with Game Center about the local player’s progress toward completing an achievement.
Inheritance
Inherited Members
Namespace: SA.iOS.GameKit
Assembly: cs.temp.dll.dll
Syntax
public class ISN_GKAchievement
Constructors
ISN_GKAchievement(String)
Declaration
public ISN_GKAchievement(string identifier)
Parameters
Type | Name | Description |
---|---|---|
System.String | identifier |
Properties
Completed
A Boolean value that states whether the player has completed the achievement.
The value of this property is true
if the percentComplete property is equal to 100.0;
otherwise, it is false
.
Declaration
public bool Completed { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Identifier
A string used to uniquely identify the specific achievement the object refers to. The identifier property must match the identifier string for an achievement you created for your game on iTunes Connect.
Declaration
public string Identifier { get; set; }
Property Value
Type | Description |
---|---|
System.String |
LastReportedDate
The last time that progress on the achievement was successfully reported to Game Center. On a newly initialized achievement object, this property holds the current date.
Declaration
public DateTime LastReportedDate { get; }
Property Value
Type | Description |
---|---|
DateTime |
Name
The Achievement name, can only be set via the editor.
Declaration
public string Name { get; set; }
Property Value
Type | Description |
---|---|
System.String | The name. |
PercentComplete
A percentage value that states how far the player has progressed on this achievement.
The default value for a newly initialized achievement object is 0.0. The range of legal values is between 0.0 and 100.0, inclusive. You decide how that percentage is calculated and when it changes. For example, if the player earns an achievement simply for discovering a location in your game, then you would simply report the achievement as 100 percent complete the first time you report progress to Game Center. On the other hand, for an achievement like “Capture 10 pirates”, your reporting mechanism increments by 10 percent each time the player captures a pirate.
Declaration
public float PercentComplete { get; set; }
Property Value
Type | Description |
---|---|
System.Single |
Methods
GetGameAchievements()
Returns list of achievements metadata from an editor settings ui.
Declaration
public static List<ISN_GKAchievement> GetGameAchievements()
Returns
Type | Description |
---|---|
List<ISN_GKAchievement> |
LoadAchievements(Action<ISN_GKAchievementsResult>)
Loads previously submitted achievement progress for the local player from Game Center. When this method is called, it creates a new background task to handle the request. The method then returns control to your game. Later, when the task is complete, Game Kit calls your completion handler. The completion handler is always called on the main thread. Listing 1 shows an example of how to load the local player’s achievements.
Declaration
public static void LoadAchievements(Action<ISN_GKAchievementsResult> callback)
Parameters
Type | Name | Description |
---|---|---|
Action<ISN_GKAchievementsResult> | callback | A block to be called when the download is completed. An array of ISN_GKAchievement objects that represents all progress reported to Game Center for the local player. If an error occurred, this parameter may be non-nil, in which case the array holds whatever achievement information Game Kit was able to fetch. |
Report(Action<SA_Result>)
Reports progress of achievement. Consider using ReportAchievements(List<ISN_GKAchievement>, Action<SA_Result>) instead
Declaration
public void Report(Action<SA_Result> callback)
Parameters
Type | Name | Description |
---|---|---|
Action<SA_Result> | callback | A block to be called after the operation completes. |
ReportAchievements(List<ISN_GKAchievement>, Action<SA_Result>)
Reports progress on an array of achievements.
Use this class method whenever you need to submit one or more achievement updates at the same time. Calling this method reports each of the achievements in the array. Processing multiple achievements at once allows the entire operation to be processed more efficiently using this method as the callback handler is only called once.
Declaration
public static void ReportAchievements(List<ISN_GKAchievement> achievements, Action<SA_Result> callback)
Parameters
Type | Name | Description |
---|---|---|
List<ISN_GKAchievement> | achievements | An array of ISN_GKAchievement objects that contains the achievements whose progress is being updated. |
Action<SA_Result> | callback | A block to be called after the operation completes. |
ResetAchievements(Action<SA_Result>)
Resets all achievement progress for the local player.
Calling this class method deletes all progress towards achievements previously reported for the local player. Hidden achievements that were previously visible are now hidden again.
Declaration
public static void ResetAchievements(Action<SA_Result> callback)
Parameters
Type | Name | Description |
---|---|---|
Action<SA_Result> | callback | A block to be called when the reset action is completed. |