Class ISN_GKScore
An object containing information for a score that was earned by the player.
Your game creates GKScore objects to post scores to a leaderboard on Game Center. When your game retrieves score information from a leaderboard, those scores are returned as GKScore objects.
Inheritance
Inherited Members
Namespace: SA.iOS.GameKit
Assembly: cs.temp.dll.dll
Syntax
public class ISN_GKScore
Constructors
ISN_GKScore(String)
Declaration
public ISN_GKScore(string leaderboardIdentifier)
Parameters
Type | Name | Description |
---|---|---|
System.String | leaderboardIdentifier |
Properties
Context
An integer value used by your game.
The Context property is stored and returned to your game, but is otherwise ignored by Game Center. It allows your game to associate an arbitrary 32-bit unsigned integer value with the score data reported to Game Center. You decide how this integer value is interpreted by your game. For example, you might use the Context property to store flags that provide game-specific details about a player’s score, or you might use the context as a key to other data stored on the device or on your own server. The context is most useful when your game displays a custom leaderboard user interface.
Declaration
public ulong Context { get; set; }
Property Value
Type | Description |
---|---|
System.UInt64 |
Date
The date and time when the score was earned.
When you initialize the new score object, the date property is automatically set to the current date and time.
Declaration
public DateTime Date { get; }
Property Value
Type | Description |
---|---|
DateTime |
DateUnix
The Date field value as unix time stamp
Declaration
public long DateUnix { get; }
Property Value
Type | Description |
---|---|
System.Int64 |
FormattedValue
Returns the player’s score as a localized string
This property is invalid on a newly initialized score object. On a score returned from GameKit, it contains a formatted string based on the player’s score. You determine how a score is formatted when you define the leaderboard on iTunes Connect.
Never convert the value property into a string directly; always use this method to receive the formatted string.
Important
You may be tempted to write your own formatting code rather than using the formattedValue property.
Do not do this. Using the built-in support makes it easy to localize the score value into other languages,
and provides a string that is consistent with the presentation of your scores in the Game Center app.
Declaration
public string FormattedValue { get; }
Property Value
Type | Description |
---|---|
System.String |
LeaderboardIdentifier
The identifier for the leaderboard.
Declaration
public string LeaderboardIdentifier { get; }
Property Value
Type | Description |
---|---|
System.String |
Player
The player identifier for the player that earned the score.
When you initialize a new score object, the Player property is set to the identifier for the local player. If the score object was returned to your game by loading scores from Game Center, the Player property identifies the player who recorded that score.
Declaration
public ISN_GKPlayer Player { get; }
Property Value
Type | Description |
---|---|
ISN_GKPlayer |
Rank
The position of the score in the results of a leaderboard search.
The value of this property is only valid on score objects returned from Game Center. The rank property represents the position of the score in the returned results, with 1 being the best score, 2 being the second best, and so on.
Declaration
public long Rank { get; }
Property Value
Type | Description |
---|---|
System.Int64 |
Value
The score earned by the player.
You can use any algorithm you want to calculate scores in your game. Your game must set the value property before reporting a score, otherwise an error is returned.
The value provided by a score object is interpreted by Game Center only when formatted for display. You determine how your scores are formatted when you define the leaderboard on iTunes Connect.
Declaration
public long Value { get; set; }
Property Value
Type | Description |
---|---|
System.Int64 |
Methods
Report(Action<SA_Result>)
Reports score to Game Center Use this class method whenever you need to submit scores to Game Center.
If you nee to report multiple scores, consider using the ReportScores(List<ISN_GKScore>, Action<SA_Result>) method
Declaration
public void Report(Action<SA_Result> callback)
Parameters
Type | Name | Description |
---|---|---|
Action<SA_Result> | callback | A block to be called after the score is reported. |
ReportScores(List<ISN_GKScore>, Action<SA_Result>)
Reports a list of scores to Game Center
Use this class method whenever you need to submit scores to Game Center, whether you are reporting a single score or multiple scores. The method runs through the array of GKScore objects, submitting scores one at a time.
Method provides a sample method to report a score. The ISN_GKScore object is initialized with the leaderboard ID for the leaderboard it reports its score to and then the value and context for the score are assigned. The leaderboard ID must be the identifier for a leaderboard you configured in iTunes Connect. Scores are always reported for the current local player and never for friends.
Declaration
public static void ReportScores(List<ISN_GKScore> scores, Action<SA_Result> callback)
Parameters
Type | Name | Description |
---|---|---|
List<ISN_GKScore> | scores | An array of ISN_GKScore objects that contains the scores to report to Game Center. |
Action<SA_Result> | callback | A block to be called after the score is reported. |