Skip to content
75 changes: 44 additions & 31 deletions DDGameKitHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,57 +6,70 @@

#import <GameKit/GameKit.h>

// -----------------------------------------------------------------
#define DDGAMEKIT_LOGGING 0
// -----------------------------------------------------------------

@protocol DDGameKitHelperProtocol
-(bool) compare:(int64_t)score1 to:(int64_t)score2;
-(void) onSubmitScore:(int64_t)score;
-(void) onReportAchievement:(GKAchievement*)achievement;
- (BOOL) compareScore:(int64_t)score1 toScore:(int64_t)score2;
- (void) onSubmitScore:(int64_t)score;
- (void) onReportAchievement:(GKAchievement*)achievement;
@end

// -----------------------------------------------------------------

@interface DDGameKitHelper : NSObject <GKLeaderboardViewControllerDelegate, GKAchievementViewControllerDelegate, GKGameCenterControllerDelegate>
{
id<DDGameKitHelperProtocol> delegate;
bool isGameCenterAvailable;
NSMutableDictionary* achievements;
NSMutableDictionary* scores;
NSMutableDictionary* achievementDescriptions;
NSString* currentPlayerID;
id <DDGameKitHelperProtocol> _delegate;
BOOL _isGameCenterAvailable;
NSMutableDictionary* _achievements;
NSMutableDictionary* _scores;
NSMutableDictionary* _achievementDescriptions;
NSString* _currentPlayerID;
}

@property (nonatomic, retain) id<DDGameKitHelperProtocol> delegate;
@property (nonatomic, readonly) bool isGameCenterAvailable;
// -----------------------------------------------------------------

@property (nonatomic, strong) id <DDGameKitHelperProtocol> delegate;
@property (nonatomic, readonly) BOOL isGameCenterAvailable;
@property (nonatomic, readonly) NSMutableDictionary* achievements;
@property (nonatomic, readonly) NSMutableDictionary* scores;
@property (nonatomic, readonly) NSMutableDictionary* achievementDescriptions;
@property (nonatomic, retain) NSString* currentPlayerID;

+(DDGameKitHelper*) sharedGameKitHelper;

-(void) setNotAvailable;
@property (nonatomic, strong) NSString* currentPlayerID;

-(bool) isAvailable;
// -----------------------------------------------------------------

-(void) authenticateLocalPlayer;
// Singleton instance
+ (DDGameKitHelper*) sharedGameKitHelper;

-(bool) isLocalPlayerAuthenticated;
// -----------------------------------------------------------------

-(void) submitScore:(int64_t)value category:(NSString*)category;
// Check and set availability
- (void) setNotAvailable;
- (BOOL) isAvailable;

-(void) reportAchievement:(NSString*)identifier percentComplete:(float)percent;
// Authenticate and check authentication
- (void) authenticateLocalPlayer;
- (BOOL) isLocalPlayerAuthenticated;

-(void) resetAchievements;
// Submitting score and achievements
- (void) submitScore:(int64_t)value category:(NSString*)category;
- (void) reportAchievement:(NSString*)identifier percentComplete:(float)percent;

-(void) showGameCenter;
// Resetting achievements
- (void) resetAchievements;

-(void) showLeaderboard;

-(void) showLeaderboardwithCategory:(NSString*)category timeScope:(int)tscope;

-(void) showAchievements;

-(GKAchievementDescription*) getAchievementDescription:(NSString*)identifier;
// Showing GameCenter
- (void) showGameCenter;
- (void) showLeaderboard;
- (void) showLeaderboardWithCategory:(NSString*)category timeScope:(int)tscope;
- (void) showAchievements;

// Achievement info
- (int) numberOfTotalAchievements;

- (int) numberOfCompletedAchievements;
- (GKAchievementDescription*) getAchievementDescription:(NSString*)identifier;

// -----------------------------------------------------------------
@end
// -----------------------------------------------------------------
Loading