Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit 56e1c0606d47126b3f0fa50b9a94011dc3631948 @micahflee micahflee committed Feb 24, 2012
Showing 548 changed files with 92,154 additions and 0 deletions.
@@ -0,0 +1 @@
+build/
@@ -0,0 +1,79 @@
+//
+// Achievements.h
+// Skeleton Key
+//
+// Created by micah on 12/30/10.
+// Copyright 2010 __MyCompanyName__. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+// the achievements
+typedef enum {
+ AchievementBeginTheHunt = 0,
+ AchievementKnockKnock = 1,
+ AchievementTheDoorman = 2,
+ AchievementTheDoorToKnowhere = 3,
+ AchievementPerfectionist = 4,
+ AchievementProfessionalPerfectionist = 5,
+ AchievementEnterTheDarkness = 6,
+ AchievementEnjoyTheSun = 7,
+ AchievementArrrgh = 8,
+ AchievementTreasureHunter = 9,
+ AchievementAnAdventurerIsYou = 10,
+ AchievementIntrepidExplorer = 11,
+ AchievementMastermind = 12
+} AchievementNames;
+
+#define ACHIEVEMENT0_NAME @"Begin the Hunt"
+#define ACHIEVEMENT0_DESC @"Beat the first 10 levels"
+#define ACHIEVEMENT1_NAME @"Knock Knock"
+#define ACHIEVEMENT1_DESC @"Open a door"
+#define ACHIEVEMENT2_NAME @"The Doorman"
+#define ACHIEVEMENT2_DESC @"Open 50 doors"
+#define ACHIEVEMENT3_NAME @"The Door to Nowhere"
+#define ACHIEVEMENT3_DESC @"Can you find it?"
+#define ACHIEVEMENT4_NAME @"Perfectionist"
+#define ACHIEVEMENT4_DESC @"Play any 10 levels perfectly"
+#define ACHIEVEMENT5_NAME @"Professional Perfectionist"
+#define ACHIEVEMENT5_DESC @"Play any 30 levels perfectly"
+#define ACHIEVEMENT6_NAME @"Enter the Darkness"
+#define ACHIEVEMENT6_DESC @"Make it to the Caves"
+#define ACHIEVEMENT7_NAME @"Enjoy the Sun"
+#define ACHIEVEMENT7_DESC @"Make it to the Beach"
+#define ACHIEVEMENT8_NAME @"Arrrgh!"
+#define ACHIEVEMENT8_DESC @"Make it to the Pirate Ship"
+#define ACHIEVEMENT9_NAME @"Treasure Hunter"
+#define ACHIEVEMENT9_DESC @"Beat all level on Easy"
+#define ACHIEVEMENT10_NAME @"An Adventurer is You"
+#define ACHIEVEMENT10_DESC @"Beat all levels on Medium"
+#define ACHIEVEMENT11_NAME @"Intrepid Explorer"
+#define ACHIEVEMENT11_DESC @"Beat all levels on Hard"
+#define ACHIEVEMENT12_NAME @"Mastermind"
+#define ACHIEVEMENT12_DESC @"Beat all levels perfectly"
+
+#define ACHIEVEMENT_NUM 13
+
+@interface Achievements : NSObject {
+ NSMutableArray* achievements;
+ NSUInteger doorsOpened;
+ NSMutableArray* achieved;
+
+ NSUInteger numAchievements;
+}
+
+@property (nonatomic,retain) NSMutableArray* achievements;
+@property (readwrite) NSUInteger doorsOpened;
+@property (nonatomic,retain) NSMutableArray* achieved;
+@property (readwrite) NSUInteger numAchievements;
+
+- (NSString*)getFilePath;
+- (void) load;
+- (void) save;
+- (void) reset;
+- (bool) unlock:(int)achievementId;
+
+- (NSString*) getName:(int)i;
+- (NSString*) getDescription:(int)i;
+
+@end
@@ -0,0 +1,118 @@
+//
+// Achievements.m
+// Skeleton Key
+//
+// Created by micah on 12/30/10.
+// Copyright 2010 __MyCompanyName__. All rights reserved.
+//
+
+#import "Achievements.h"
+
+
+@implementation Achievements
+
+@synthesize achievements;
+@synthesize doorsOpened;
+@synthesize achieved;
+@synthesize numAchievements;
+
+- (id) init {
+ if((self = [super init])) {
+ NSLog(@"Achievements init");
+ numAchievements = 13;
+ achieved = [[NSMutableArray alloc] initWithCapacity:numAchievements];
+ [self load];
+ }
+ return self;
+}
+
+- (void) dealloc {
+ NSLog(@"Achievements dealloc");
+ [achieved dealloc];
+ [super dealloc];
+}
+
+- (NSString*)getFilePath {
+ NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ NSString* documentsDirectory = [paths objectAtIndex:0];
+ return [documentsDirectory stringByAppendingPathComponent:@"Achievements.plist"];
+}
+
+- (void) load {
+ if([[NSFileManager defaultManager] fileExistsAtPath:[self getFilePath]]) {
+ NSLog(@"Achievements load");
+ achievements = [NSArray arrayWithContentsOfFile:[self getFilePath]];
+ doorsOpened = [[achievements objectAtIndex:0] intValue];
+ for(NSUInteger i=1; i<=numAchievements; i++)
+ [achieved addObject:[achievements objectAtIndex:i]];
+ } else {
+ NSLog(@"Achievements create new file");
+ doorsOpened = 0;
+ for(NSUInteger i=1; i<=numAchievements; i++)
+ [achieved addObject:[NSNumber numberWithInt:0]];
+ [self save];
+ }
+}
+
+- (void) save {
+ NSLog(@"Achievements save");
+ achievements = [NSMutableArray arrayWithObject:[NSNumber numberWithInt:doorsOpened]];
+ for(NSUInteger i=0; i<numAchievements; i++)
+ [achievements addObject:[achieved objectAtIndex:i]];
+ [achievements writeToFile:[self getFilePath] atomically:YES];
+}
+
+- (void) reset {
+ [achieved dealloc];
+ achieved = [[NSMutableArray alloc] initWithCapacity:numAchievements];
+ for(NSUInteger i=1; i<=numAchievements; i++)
+ [achieved addObject:[NSNumber numberWithInt:0]];
+ [self save];
+}
+
+- (bool) unlock:(int)achievementId {
+ if([(NSNumber*)[achieved objectAtIndex:achievementId] intValue] == 1) return false;
+ [achieved replaceObjectAtIndex:achievementId withObject:[NSNumber numberWithInt:1]];
+ [self save];
+ return true;
+}
+
+- (NSString*) getName:(int)i {
+ switch(i) {
+ case 0: return ACHIEVEMENT0_NAME;
+ case 1: return ACHIEVEMENT1_NAME;
+ case 2: return ACHIEVEMENT2_NAME;
+ case 3: return ACHIEVEMENT3_NAME;
+ case 4: return ACHIEVEMENT4_NAME;
+ case 5: return ACHIEVEMENT5_NAME;
+ case 6: return ACHIEVEMENT6_NAME;
+ case 7: return ACHIEVEMENT7_NAME;
+ case 8: return ACHIEVEMENT8_NAME;
+ case 9: return ACHIEVEMENT9_NAME;
+ case 10: return ACHIEVEMENT10_NAME;
+ case 11: return ACHIEVEMENT11_NAME;
+ case 12: return ACHIEVEMENT12_NAME;
+ }
+ return @"";
+}
+
+- (NSString*) getDescription:(int)i {
+ switch(i) {
+ case 0: return ACHIEVEMENT0_DESC;
+ case 1: return ACHIEVEMENT1_DESC;
+ case 2: return ACHIEVEMENT2_DESC;
+ case 3: return ACHIEVEMENT3_DESC;
+ case 4: return ACHIEVEMENT4_DESC;
+ case 5: return ACHIEVEMENT5_DESC;
+ case 6: return ACHIEVEMENT6_DESC;
+ case 7: return ACHIEVEMENT7_DESC;
+ case 8: return ACHIEVEMENT8_DESC;
+ case 9: return ACHIEVEMENT9_DESC;
+ case 10: return ACHIEVEMENT10_DESC;
+ case 11: return ACHIEVEMENT11_DESC;
+ case 12: return ACHIEVEMENT12_DESC;
+ }
+ return @"";
+}
+
+@end
@@ -0,0 +1,37 @@
+//
+// AchievementsScene.h
+// Skeleton Key
+//
+// Created by micah on 12/30/10.
+// Copyright 2010 __MyCompanyName__. All rights reserved.
+//
+
+#import "cocos2d.h"
+#import "Achievements.h"
+#import "Helpers.h"
+#import "Sound.h"
+
+@interface AchievementsScene : CCLayer {
+ Achievements* achievements;
+
+ NSInteger numPages;
+ NSInteger pageNumber;
+ CCMenuItemImage* back;
+ CCMenuItemImage* next;
+ CCLayer* pageLayer;
+
+ CGPoint touchStart;
+
+ Sound* sound;
+}
+
++ (id) scene;
+
+- (void) onBack:(id)sender;
+- (void) onNext:(id)sender;
+- (void) onMenu:(id)sender;
+- (void) moveBack;
+- (void) moveNext;
+- (void) scroll;
+
+@end
Oops, something went wrong.

0 comments on commit 56e1c06

Please sign in to comment.