summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorStarla Insigna <starla4444@gmail.com>2011-11-30 12:57:06 -0500
committerStarla Insigna <starla4444@gmail.com>2011-11-30 12:57:06 -0500
commit6e96fb2144718722208d22f892716b55548135e1 (patch)
tree4dd550de787dd370a13039c03969442f54a3a856
parentfd58a0cde1bb5473e39e6cb82d28113da84b9ae0 (diff)
downloadcartcollect-6e96fb2144718722208d22f892716b55548135e1.tar.gz
cartcollect-6e96fb2144718722208d22f892716b55548135e1.tar.bz2
cartcollect-6e96fb2144718722208d22f892716b55548135e1.zip
Created a game mode manager
There is now one location for information relating to each GameMode instead of several places, so that info can be easily updated and propagated to, for instance, GameModeSelectionLayer. GameModes can also be specified by an info instance each owns. There's also a way to get an ordered list of game modes.

The three star game mode unlocking system has also been added.

Closes #213
-rwxr-xr-xCartographic.xcodeproj/project.pbxproj24
-rwxr-xr-xClasses/ClassicGameMode.m42
-rw-r--r--Classes/GameMode.h3
-rw-r--r--Classes/GameMode.m20
-rw-r--r--Classes/GameModeInfo.h41
-rw-r--r--Classes/GameModeInfo.m128
-rw-r--r--Classes/GameModeManager.h20
-rw-r--r--Classes/GameModeManager.m74
-rw-r--r--Classes/GameModeSelection.h16
-rw-r--r--Classes/GameModeSelection.m49
-rw-r--r--Classes/GameModeSelectionLayer.m45
-rwxr-xr-xClasses/GameOverScene.h7
-rwxr-xr-xClasses/GameOverScene.m31
-rw-r--r--Classes/JumpGameMode.m22
-rw-r--r--Classes/TutorialMode.m24
-rwxr-xr-xResources/star_1.pngbin0 -> 733 bytes
-rwxr-xr-xResources/star_2.pngbin0 -> 714 bytes
-rwxr-xr-xResources/star_3.pngbin0 -> 753 bytes
18 files changed, 406 insertions, 140 deletions
diff --git a/Cartographic.xcodeproj/project.pbxproj b/Cartographic.xcodeproj/project.pbxproj index 5aed3f5..464cf44 100755 --- a/Cartographic.xcodeproj/project.pbxproj +++ b/Cartographic.xcodeproj/project.pbxproj
@@ -124,6 +124,11 @@
124 6CC89DD913F2F4E6003704F7 /* Entitlements.plist in Resources */ = {isa = PBXBuildFile; fileRef = 6CC89DD813F2F4E6003704F7 /* Entitlements.plist */; }; 124 6CC89DD913F2F4E6003704F7 /* Entitlements.plist in Resources */ = {isa = PBXBuildFile; fileRef = 6CC89DD813F2F4E6003704F7 /* Entitlements.plist */; };
125 6CC89DDF13F31413003704F7 /* TutorialMode.m in Sources */ = {isa = PBXBuildFile; fileRef = 6CC89DDE13F31413003704F7 /* TutorialMode.m */; }; 125 6CC89DDF13F31413003704F7 /* TutorialMode.m in Sources */ = {isa = PBXBuildFile; fileRef = 6CC89DDE13F31413003704F7 /* TutorialMode.m */; };
126 6CDBE80C14092DB00072F287 /* ledge.png in Resources */ = {isa = PBXBuildFile; fileRef = 6CDBE80B14092DB00072F287 /* ledge.png */; }; 126 6CDBE80C14092DB00072F287 /* ledge.png in Resources */ = {isa = PBXBuildFile; fileRef = 6CDBE80B14092DB00072F287 /* ledge.png */; };
127 6CE5F7EA1483FAC8008E9ADA /* GameModeInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 6CE5F7E91483FAC8008E9ADA /* GameModeInfo.m */; };
128 6CE5F7EE14855331008E9ADA /* GameModeManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 6CE5F7ED14855331008E9ADA /* GameModeManager.m */; };
129 6CE5F7F214869D98008E9ADA /* star_1.png in Resources */ = {isa = PBXBuildFile; fileRef = 6CE5F7EF14869D98008E9ADA /* star_1.png */; };
130 6CE5F7F314869D98008E9ADA /* star_2.png in Resources */ = {isa = PBXBuildFile; fileRef = 6CE5F7F014869D98008E9ADA /* star_2.png */; };
131 6CE5F7F414869D98008E9ADA /* star_3.png in Resources */ = {isa = PBXBuildFile; fileRef = 6CE5F7F114869D98008E9ADA /* star_3.png */; };
127 6CF64C0B141BA37000F3B702 /* multiplier.png in Resources */ = {isa = PBXBuildFile; fileRef = 6CF64C0A141BA37000F3B702 /* multiplier.png */; }; 132 6CF64C0B141BA37000F3B702 /* multiplier.png in Resources */ = {isa = PBXBuildFile; fileRef = 6CF64C0A141BA37000F3B702 /* multiplier.png */; };
128 6CF64C11141BA84200F3B702 /* Absorption2.wav in Resources */ = {isa = PBXBuildFile; fileRef = 6CF64C10141BA84200F3B702 /* Absorption2.wav */; }; 133 6CF64C11141BA84200F3B702 /* Absorption2.wav in Resources */ = {isa = PBXBuildFile; fileRef = 6CF64C10141BA84200F3B702 /* Absorption2.wav */; };
129 6CF64C1D141BFA9600F3B702 /* FallingObjectFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = 6CF64C1C141BFA9600F3B702 /* FallingObjectFactory.m */; }; 134 6CF64C1D141BFA9600F3B702 /* FallingObjectFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = 6CF64C1C141BFA9600F3B702 /* FallingObjectFactory.m */; };
@@ -459,6 +464,13 @@
459 6CC89DE013F3197F003704F7 /* FallingObjectDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FallingObjectDelegate.h; sourceTree = "<group>"; }; 464 6CC89DE013F3197F003704F7 /* FallingObjectDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FallingObjectDelegate.h; sourceTree = "<group>"; };
460 6CDBE80B14092DB00072F287 /* ledge.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ledge.png; sourceTree = "<group>"; }; 465 6CDBE80B14092DB00072F287 /* ledge.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ledge.png; sourceTree = "<group>"; };
461 6CDBE80E140936CF0072F287 /* CartDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CartDelegate.h; sourceTree = "<group>"; }; 466 6CDBE80E140936CF0072F287 /* CartDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CartDelegate.h; sourceTree = "<group>"; };
467 6CE5F7E81483FAC8008E9ADA /* GameModeInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameModeInfo.h; sourceTree = "<group>"; };
468 6CE5F7E91483FAC8008E9ADA /* GameModeInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GameModeInfo.m; sourceTree = "<group>"; };
469 6CE5F7EC14855331008E9ADA /* GameModeManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameModeManager.h; sourceTree = "<group>"; };
470 6CE5F7ED14855331008E9ADA /* GameModeManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GameModeManager.m; sourceTree = "<group>"; };
471 6CE5F7EF14869D98008E9ADA /* star_1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = star_1.png; sourceTree = "<group>"; };
472 6CE5F7F014869D98008E9ADA /* star_2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = star_2.png; sourceTree = "<group>"; };
473 6CE5F7F114869D98008E9ADA /* star_3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = star_3.png; sourceTree = "<group>"; };
462 6CF64C0A141BA37000F3B702 /* multiplier.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = multiplier.png; sourceTree = "<group>"; }; 474 6CF64C0A141BA37000F3B702 /* multiplier.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = multiplier.png; sourceTree = "<group>"; };
463 6CF64C10141BA84200F3B702 /* Absorption2.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = Absorption2.wav; sourceTree = "<group>"; }; 475 6CF64C10141BA84200F3B702 /* Absorption2.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = Absorption2.wav; sourceTree = "<group>"; };
464 6CF64C1B141BFA9600F3B702 /* FallingObjectFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FallingObjectFactory.h; sourceTree = "<group>"; }; 476 6CF64C1B141BFA9600F3B702 /* FallingObjectFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FallingObjectFactory.h; sourceTree = "<group>"; };
@@ -780,6 +792,9 @@
780 3F6C7F4D13D647B600C038FE /* Sprites */ = { 792 3F6C7F4D13D647B600C038FE /* Sprites */ = {
781 isa = PBXGroup; 793 isa = PBXGroup;
782 children = ( 794 children = (
795 6CE5F7EF14869D98008E9ADA /* star_1.png */,
796 6CE5F7F014869D98008E9ADA /* star_2.png */,
797 6CE5F7F114869D98008E9ADA /* star_3.png */,
783 6CF64C0A141BA37000F3B702 /* multiplier.png */, 798 6CF64C0A141BA37000F3B702 /* multiplier.png */,
784 6CDBE80B14092DB00072F287 /* ledge.png */, 799 6CDBE80B14092DB00072F287 /* ledge.png */,
785 6C39CFE613FC46CD002B21AF /* water.png */, 800 6C39CFE613FC46CD002B21AF /* water.png */,
@@ -934,6 +949,10 @@
934 6CC89DDE13F31413003704F7 /* TutorialMode.m */, 949 6CC89DDE13F31413003704F7 /* TutorialMode.m */,
935 6C39CFE313FC4635002B21AF /* JumpGameMode.h */, 950 6C39CFE313FC4635002B21AF /* JumpGameMode.h */,
936 6C39CFE413FC4635002B21AF /* JumpGameMode.m */, 951 6C39CFE413FC4635002B21AF /* JumpGameMode.m */,
952 6CE5F7E81483FAC8008E9ADA /* GameModeInfo.h */,
953 6CE5F7E91483FAC8008E9ADA /* GameModeInfo.m */,
954 6CE5F7EC14855331008E9ADA /* GameModeManager.h */,
955 6CE5F7ED14855331008E9ADA /* GameModeManager.m */,
937 ); 956 );
938 name = "Game Modes"; 957 name = "Game Modes";
939 sourceTree = "<group>"; 958 sourceTree = "<group>";
@@ -1467,6 +1486,9 @@
1467 6CDBE80C14092DB00072F287 /* ledge.png in Resources */, 1486 6CDBE80C14092DB00072F287 /* ledge.png in Resources */,
1468 6CF64C0B141BA37000F3B702 /* multiplier.png in Resources */, 1487 6CF64C0B141BA37000F3B702 /* multiplier.png in Resources */,
1469 6CF64C11141BA84200F3B702 /* Absorption2.wav in Resources */, 1488 6CF64C11141BA84200F3B702 /* Absorption2.wav in Resources */,
1489 6CE5F7F214869D98008E9ADA /* star_1.png in Resources */,
1490 6CE5F7F314869D98008E9ADA /* star_2.png in Resources */,
1491 6CE5F7F414869D98008E9ADA /* star_3.png in Resources */,
1470 ); 1492 );
1471 runOnlyForDeploymentPostprocessing = 0; 1493 runOnlyForDeploymentPostprocessing = 0;
1472 }; 1494 };
@@ -1517,6 +1539,8 @@
1517 6C85834414055B2E009EF100 /* notificationDesign.m in Sources */, 1539 6C85834414055B2E009EF100 /* notificationDesign.m in Sources */,
1518 6C4400041415080800A9E1D7 /* ZoomFadeTransition.m in Sources */, 1540 6C4400041415080800A9E1D7 /* ZoomFadeTransition.m in Sources */,
1519 6CF64C1D141BFA9600F3B702 /* FallingObjectFactory.m in Sources */, 1541 6CF64C1D141BFA9600F3B702 /* FallingObjectFactory.m in Sources */,
1542 6CE5F7EA1483FAC8008E9ADA /* GameModeInfo.m in Sources */,
1543 6CE5F7EE14855331008E9ADA /* GameModeManager.m in Sources */,
1520 ); 1544 );
1521 runOnlyForDeploymentPostprocessing = 0; 1545 runOnlyForDeploymentPostprocessing = 0;
1522 }; 1546 };
diff --git a/Classes/ClassicGameMode.m b/Classes/ClassicGameMode.m index 306c1d1..9356fea 100755 --- a/Classes/ClassicGameMode.m +++ b/Classes/ClassicGameMode.m
@@ -10,8 +10,6 @@
10#import "FallingObject.h" 10#import "FallingObject.h"
11#import "GameOverScene.h" 11#import "GameOverScene.h"
12#import "SimpleAudioEngine.h" 12#import "SimpleAudioEngine.h"
13#import "CCNotifications.h"
14#import "TestFlight.h"
15 13
16@implementation ClassicGameMode 14@implementation ClassicGameMode
17 15
@@ -22,6 +20,26 @@ typedef enum {
22 kRockObject 20 kRockObject
23} FallingObjects; 21} FallingObjects;
24 22
23static GameModeInfo* info;
24
25+ (GameModeInfo*)info
26{
27 if (info == nil)
28 {
29 info = [[GameModeInfo alloc] initWithName:@"Collect"
30 location:@"Paris"
31 numOfStars:3
32 imageFilename:[[NSBundle mainBundle] pathForResource:@"paris" ofType:@"png"]
33 unlocked:NO
34 unlockCondition:@"Beat the tutorial!"
35 gameClass:[ClassicGameMode class]
36 globalHighscoreKey:@"Classic"
37 starsToUnlock:0];
38 }
39
40 return info;
41}
42
25- (void)tick:(ccTime)dt 43- (void)tick:(ccTime)dt
26{ 44{
27 int lastScore = score; 45 int lastScore = score;
@@ -32,7 +50,7 @@ typedef enum {
32 { 50 {
33 [self unscheduleAllSelectors]; 51 [self unscheduleAllSelectors];
34 52
35 [[CCDirector sharedDirector] replaceScene:[CCTransitionSlideInT transitionWithDuration:1.5f scene:[GameOverScene sceneWithScore:score gameMode:@"Collect"]]]; 53 [[CCDirector sharedDirector] replaceScene:[CCTransitionSlideInT transitionWithDuration:1.5f scene:[GameOverScene sceneWithScore:score gameMode:[ClassicGameMode info]]]];
36 } else if (score > lastScore) 54 } else if (score > lastScore)
37 { 55 {
38 if ((lastScore < 6500) && (score >= 6500)) 56 if ((lastScore < 6500) && (score >= 6500))
@@ -45,24 +63,14 @@ typedef enum {
45 [self unschedule:@selector(randomlyAddObject:)]; 63 [self unschedule:@selector(randomlyAddObject:)];
46 [self schedule:@selector(randomlyAddObject:) interval:0.7f]; 64 [self schedule:@selector(randomlyAddObject:) interval:0.7f];
47 addSpeed = 0.7f; 65 addSpeed = 0.7f;
48 } else if ((lastScore < 3000) && (score >= 3000))
49 {
50 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
51
52 if (![defaults boolForKey:@"unlockedJumpMode"])
53 {
54 [[CCNotifications sharedManager] addWithTitle:@"Jump" message:@"You've unlocked a new game mode!" image:@"venice.png"];
55
56 [defaults setBool:YES forKey:@"unlockedJumpMode"];
57 [defaults synchronize];
58
59 [TestFlight passCheckpoint:@"Unlocked Jump Mode"];
60 }
61 } else if ((lastScore < 2500) && (score >= 2500)) 66 } else if ((lastScore < 2500) && (score >= 2500))
62 { 67 {
63 [self unschedule:@selector(randomlyAddObject:)]; 68 [self unschedule:@selector(randomlyAddObject:)];
64 [self schedule:@selector(randomlyAddObject:) interval:0.8f]; 69 [self schedule:@selector(randomlyAddObject:) interval:0.8f];
65 addSpeed = 0.8f; 70 addSpeed = 0.8f;
71 } else if ((lastScore < 2000) && (score >= 2000))
72 {
73 [[ClassicGameMode info] setStar:1 withMessage:@"Get 2000 points"];
66 } else if ((lastScore < 1500) && (score >= 1500)) 74 } else if ((lastScore < 1500) && (score >= 1500))
67 { 75 {
68 [self unschedule:@selector(randomlyAddObject:)]; 76 [self unschedule:@selector(randomlyAddObject:)];
@@ -73,6 +81,8 @@ typedef enum {
73 [self unschedule:@selector(randomlyAddObject:)]; 81 [self unschedule:@selector(randomlyAddObject:)];
74 [self schedule:@selector(randomlyAddObject:) interval:1.0f]; 82 [self schedule:@selector(randomlyAddObject:) interval:1.0f];
75 addSpeed = 1.0f; 83 addSpeed = 1.0f;
84
85 [[ClassicGameMode info] setStar:0 withMessage:@"Get 500 points"];
76 } else if ((lastScore < 150) && (score >= 150)) 86 } else if ((lastScore < 150) && (score >= 150))
77 { 87 {
78 [self unschedule:@selector(randomlyAddObject:)]; 88 [self unschedule:@selector(randomlyAddObject:)];
diff --git a/Classes/GameMode.h b/Classes/GameMode.h index cd0359d..cd41884 100644 --- a/Classes/GameMode.h +++ b/Classes/GameMode.h
@@ -9,6 +9,7 @@
9#import "CCLayer.h" 9#import "CCLayer.h"
10#import "Cart.h" 10#import "Cart.h"
11#import "FallingObjectFactory.h" 11#import "FallingObjectFactory.h"
12#import "GameModeInfo.h"
12 13
13#define GAME_SCENE 436 14#define GAME_SCENE 436
14#define GAME_LAYER 437 15#define GAME_LAYER 437
@@ -37,7 +38,6 @@
37@property (nonatomic,assign) int lives; 38@property (nonatomic,assign) int lives;
38@property (nonatomic,assign) int pointMultiplier; 39@property (nonatomic,assign) int pointMultiplier;
39@property (readonly) BOOL isPaused; 40@property (readonly) BOOL isPaused;
40+ (CCScene*)scene;
41- (void)tick:(ccTime)dt; 41- (void)tick:(ccTime)dt;
42- (BOOL)canPause; 42- (BOOL)canPause;
43- (void)pause; 43- (void)pause;
@@ -45,5 +45,6 @@
45- (void)mainmenu; 45- (void)mainmenu;
46- (void)scheduleDelayedAction:(void(^)(void))delayedAction delay:(float)delay; 46- (void)scheduleDelayedAction:(void(^)(void))delayedAction delay:(float)delay;
47- (void)runDelayedAction; 47- (void)runDelayedAction;
48+ (GameModeInfo*)info;
48 49
49@end 50@end
diff --git a/Classes/GameMode.m b/Classes/GameMode.m index 1f2451d..3e2f3ee 100644 --- a/Classes/GameMode.m +++ b/Classes/GameMode.m
@@ -14,19 +14,6 @@
14 14
15@synthesize cart, score, lives, isPaused, pointMultiplier; 15@synthesize cart, score, lives, isPaused, pointMultiplier;
16 16
17+ (CCScene*)scene
18{
19 CCScene* scene = [CCScene node];
20
21 GameMode* layer = [self node];
22 layer.tag = GAME_LAYER;
23 [scene addChild:layer];
24
25 scene.tag = GAME_SCENE;
26
27 return scene;
28}
29
30- (id)init 17- (id)init
31{ 18{
32 self = [super init]; 19 self = [super init];
@@ -213,6 +200,13 @@
213 } 200 }
214} 201}
215 202
203+ (GameModeInfo*)info
204{
205 [NSException raise:@"Unimplemented method" format:@"Method -info of GameMode subclasses must be overridden"];
206
207 return nil;
208}
209
216- (void)dealloc 210- (void)dealloc
217{ 211{
218 [objects release]; 212 [objects release];
diff --git a/Classes/GameModeInfo.h b/Classes/GameModeInfo.h new file mode 100644 index 0000000..2262526 --- /dev/null +++ b/Classes/GameModeInfo.h
@@ -0,0 +1,41 @@
1//
2// GameModeInfo.h
3// Cartographic
4//
5// Created by Starla Insigna on 11/28/11.
6// Copyright (c) 2011 Four Island. All rights reserved.
7//
8
9#import <Foundation/Foundation.h>
10#import "cocos2d.h"
11
12@interface GameModeInfo : NSObject {
13 NSString* name;
14 NSString* location;
15 BOOL* stars;
16 int numOfStars;
17 BOOL unlocked;
18 UIImage* image;
19 NSString* unlockCondition;
20 Class gameClass;
21 NSString* globalHighscoreKey;
22 int starsToUnlock;
23}
24
25@property (readonly) NSString* name;
26@property (readonly) NSString* location;
27@property (readonly) int numOfStars;
28@property (readonly) UIImage* image;
29@property (readonly) BOOL unlocked;
30@property (readonly) NSString* unlockCondition;
31@property (readonly) NSString* globalHighscoreKey;
32@property (readonly) int starsToUnlock;
33- (id)initWithName:(NSString*)m_name location:(NSString*)m_location numOfStars:(int)m_numOfStars imageFilename:(NSString*)m_imageFilename unlocked:(BOOL)m_unlocked unlockCondition:(NSString*)m_unlockCondition gameClass:(Class)m_gameClass globalHighscoreKey:(NSString*)m_globalHighscoreKey starsToUnlock:(int)m_starsToUnlock;
34- (void)setStar:(int)star_id withMessage:(NSString*)message;
35- (BOOL)star:(int)star_id;
36- (int)starsCollected;
37- (CCScene*)scene;
38- (void)unlock;
39- (void)dealloc;
40
41@end
diff --git a/Classes/GameModeInfo.m b/Classes/GameModeInfo.m new file mode 100644 index 0000000..8b33fd8 --- /dev/null +++ b/Classes/GameModeInfo.m
@@ -0,0 +1,128 @@
1//
2// GameModeInfo.m
3// Cartographic
4//
5// Created by Starla Insigna on 11/28/11.
6// Copyright (c) 2011 Four Island. All rights reserved.
7//
8
9#import "GameModeInfo.h"
10#import "CCNotifications.h"
11#import "GameMode.h"
12#import "GameModeManager.h"
13#import "TestFlight.h"
14
15@implementation GameModeInfo
16
17@synthesize name, location, numOfStars, image, unlocked, unlockCondition, globalHighscoreKey, starsToUnlock;
18
19- (id)initWithName:(NSString*)m_name location:(NSString*)m_location numOfStars:(int)m_numOfStars imageFilename:(NSString*)m_imageFilename unlocked:(BOOL)m_unlocked unlockCondition:(NSString*)m_unlockCondition gameClass:(Class)m_gameClass globalHighscoreKey:(NSString*)m_globalHighscoreKey starsToUnlock:(int)m_starsToUnlock
20{
21 self = [super init];
22
23 if (nil != self)
24 {
25 name = m_name;
26 location = m_location;
27 numOfStars = m_numOfStars;
28 image = [[UIImage alloc] initWithContentsOfFile:m_imageFilename];
29 unlockCondition = m_unlockCondition;
30 globalHighscoreKey = m_globalHighscoreKey;
31 starsToUnlock = m_starsToUnlock;
32
33 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
34 unlocked = [defaults boolForKey:[NSString stringWithFormat:@"gameModeUnlocked-%@", name]];
35 if (!unlocked)
36 {
37 unlocked = m_unlocked;
38 }
39
40 stars = (BOOL*) calloc(numOfStars, sizeof(BOOL));
41 for (int i=0; i<numOfStars; i++)
42 {
43 stars[i] = [defaults boolForKey:[NSString stringWithFormat:@"gameModeStar-%@-%d", name, i]];
44 }
45
46 if ([m_gameClass isSubclassOfClass:[GameMode class]])
47 {
48 gameClass = m_gameClass;
49 } else {
50 [NSException raise:@"Invalid gameClass value" format:@"gameClass must be a subclass of GameMode"];
51 }
52 }
53
54 return self;
55}
56
57- (void)setStar:(int)star_id withMessage:(NSString*)message
58{
59 if (!stars[star_id])
60 {
61 stars[star_id] = YES;
62
63 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
64 [defaults setBool:YES forKey:[NSString stringWithFormat:@"gameModeStar-%@-%d", name, star_id]];
65
66 [[CCNotifications sharedManager] addWithTitle:@"Star Achieved!" message:message image:[NSString stringWithFormat:@"star_%d.png", star_id+1]];
67
68 [GameModeManager sharedInstance].stars++;
69 }
70}
71
72- (BOOL)star:(int)star_id
73{
74 return stars[star_id];
75}
76
77- (int)starsCollected
78{
79 int result = 0;
80
81 for (int i=0; i<numOfStars; i++)
82 {
83 if (stars[i])
84 {
85 result++;
86 }
87 }
88
89 return result;
90}
91
92- (CCScene*)scene
93{
94 CCScene* scene = [CCScene node];
95
96 GameMode* layer = [[((GameMode*) [gameClass alloc]) init] autorelease];
97 layer.tag = GAME_LAYER;
98 [scene addChild:layer];
99
100 scene.tag = GAME_SCENE;
101
102 return scene;
103}
104
105- (void)unlock
106{
107 if (!unlocked)
108 {
109 unlocked = YES;
110
111 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
112 [defaults setBool:YES forKey:[NSString stringWithFormat:@"gameModeUnlocked-%@", name]];
113
114 CCTexture2D* texture = [[CCTexture2D alloc] initWithImage:image];
115 [[CCNotifications sharedManager] addWithTitle:name message:@"You've unlocked a new game mode!" texture:texture];
116 [texture release];
117
118 [TestFlight passCheckpoint:[NSString stringWithFormat:@"Unlocked %@ Mode", name]];
119 }
120}
121
122- (void)dealloc
123{
124 free(stars);
125 [super dealloc];
126}
127
128@end
diff --git a/Classes/GameModeManager.h b/Classes/GameModeManager.h new file mode 100644 index 0000000..fdaae60 --- /dev/null +++ b/Classes/GameModeManager.h
@@ -0,0 +1,20 @@
1//
2// GameModeManager.h
3// Cartographic
4//
5// Created by Starla Insigna on 11/29/11.
6// Copyright (c) 2011 Four Island. All rights reserved.
7//
8
9#import <Foundation/Foundation.h>
10
11@interface GameModeManager : NSObject {
12 NSArray* gameModes;
13 int stars;
14}
15
16@property (readonly) NSArray* gameModes;
17@property (assign) int stars;
18+ (GameModeManager*)sharedInstance;
19
20@end
diff --git a/Classes/GameModeManager.m b/Classes/GameModeManager.m new file mode 100644 index 0000000..5a6e109 --- /dev/null +++ b/Classes/GameModeManager.m
@@ -0,0 +1,74 @@
1//
2// GameModeManager.m
3// Cartographic
4//
5// Created by Starla Insigna on 11/29/11.
6// Copyright (c) 2011 Four Island. All rights reserved.
7//
8
9#import "GameModeManager.h"
10#import "GameModeInfo.h"
11#import "TutorialMode.h"
12#import "ClassicGameMode.h"
13#import "JumpGameMode.h"
14
15@implementation GameModeManager
16
17@synthesize gameModes;
18
19static GameModeManager* sharedInstance = nil;
20
21+ (GameModeManager*)sharedInstance
22{
23 if (sharedInstance == nil)
24 {
25 sharedInstance = [[GameModeManager alloc] init];
26 }
27
28 return sharedInstance;
29}
30
31- (id)init
32{
33 self = [super init];
34
35 if (nil != self)
36 {
37 gameModes = [[NSArray alloc] initWithObjects:
38 [TutorialMode info],
39 [ClassicGameMode info],
40 [JumpGameMode info],
41 nil];
42
43 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
44 stars = [defaults integerForKey:@"stars"];
45 }
46
47 return self;
48}
49
50- (void)setStars:(int)m_stars
51{
52 if (stars != m_stars)
53 {
54 stars = m_stars;
55
56 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
57 [defaults setInteger:m_stars forKey:@"stars"];
58
59 for (GameModeInfo* gameMode in gameModes)
60 {
61 if ((!gameMode.unlocked) && (stars >= gameMode.starsToUnlock))
62 {
63 [gameMode unlock];
64 }
65 }
66 }
67}
68
69- (int)stars
70{
71 return stars;
72}
73
74@end
diff --git a/Classes/GameModeSelection.h b/Classes/GameModeSelection.h index bdb38fb..ec6d5ad 100644 --- a/Classes/GameModeSelection.h +++ b/Classes/GameModeSelection.h
@@ -8,23 +8,17 @@
8 8
9#import "cocos2d.h" 9#import "cocos2d.h"
10#import "GameModeSelectionDelegate.h" 10#import "GameModeSelectionDelegate.h"
11#import "GameModeInfo.h"
11 12
12@interface GameModeSelection : CCMenuItem { 13@interface GameModeSelection : CCMenuItem {
13 NSString* name; 14 GameModeInfo* gameMode;
14 NSString* location;
15 BOOL unlocked;
16 NSString* unlockCondition;
17 id<GameModeSelectionDelegate> delegate; 15 id<GameModeSelectionDelegate> delegate;
18} 16}
19 17
20@property (readonly) NSString* name; 18@property (readonly) GameModeInfo* gameMode;
21@property (readonly) NSString* location;
22@property (readonly) BOOL unlocked;
23@property (nonatomic,retain) id<GameModeSelectionDelegate> delegate; 19@property (nonatomic,retain) id<GameModeSelectionDelegate> delegate;
24+ (id)selectionWithName:(NSString*)name location:(NSString*)location filename:(NSString*)filename unlocked:(BOOL)unlocked; 20+ (id)selectionWithGameModeInfo:(GameModeInfo*)m_gameMode;
25+ (id)selectionWithName:(NSString *)name location:(NSString *)location filename:(NSString *)filename unlockCondition:(NSString*)unlockCondition; 21- (id)initWithGameModeInfo:(GameModeInfo*)m_gameMode;
26- (id)initWithName:(NSString*)name location:(NSString*)location filename:(NSString*)filename unlocked:(BOOL)unlocked;
27- (id)initWithName:(NSString *)name location:(NSString *)location filename:(NSString *)filename unlockCondition:(NSString*)unlockCondition;
28- (void)buttonTapped; 22- (void)buttonTapped;
29 23
30@end 24@end
diff --git a/Classes/GameModeSelection.m b/Classes/GameModeSelection.m index 40981b1..61004fa 100644 --- a/Classes/GameModeSelection.m +++ b/Classes/GameModeSelection.m
@@ -13,19 +13,14 @@
13 13
14@implementation GameModeSelection 14@implementation GameModeSelection
15 15
16@synthesize name, location, unlocked, delegate; 16@synthesize gameMode, delegate;
17 17
18+ (id)selectionWithName:(NSString*)name location:(NSString*)location filename:(NSString*)filename unlocked:(BOOL)unlocked 18+ (id)selectionWithGameModeInfo:(GameModeInfo*)m_gameMode
19{ 19{
20 return [[[GameModeSelection alloc] initWithName:name location:location filename:filename unlocked:unlocked] autorelease]; 20 return [[[GameModeSelection alloc] initWithGameModeInfo:m_gameMode] autorelease];
21} 21}
22 22
23+ (id)selectionWithName:(NSString *)name location:(NSString *)location filename:(NSString *)filename unlockCondition:(NSString*)unlockCondition 23- (id)initWithGameModeInfo:(GameModeInfo*)m_gameMode
24{
25 return [[[GameModeSelection alloc] initWithName:name location:location filename:filename unlockCondition:unlockCondition] autorelease];
26}
27
28- (id)initWithName:(NSString*)m_name location:(NSString*)m_location filename:(NSString*)filename unlocked:(BOOL)m_unlocked;
29{ 24{
30 self = [super initWithTarget:nil selector:nil]; 25 self = [super initWithTarget:nil selector:nil];
31 26
@@ -33,19 +28,19 @@
33 { 28 {
34 self.anchorPoint = CGPointMake(0.5f, 0.5f); 29 self.anchorPoint = CGPointMake(0.5f, 0.5f);
35 30
36 name = m_name; 31 gameMode = m_gameMode;
37 location = m_location;
38 unlocked = m_unlocked;
39 32
40 contentSize_ = CGSizeMake(128, 320); 33 contentSize_ = CGSizeMake(128, 320);
41 34
35 NSString* name = gameMode.name;
36 NSString* location = gameMode.location;
42 NSString* filenameMod; 37 NSString* filenameMod;
43 38
44 if (unlocked) 39 if (gameMode.unlocked)
45 { 40 {
46 filenameMod = [NSString stringWithFormat:@"%@-unlocked", filename]; 41 filenameMod = [NSString stringWithFormat:@"%@-unlocked", name];
47 } else { 42 } else {
48 filenameMod = [NSString stringWithFormat:@"%@-locked", filename]; 43 filenameMod = [NSString stringWithFormat:@"%@-locked", name];
49 name = [@"" stringByPaddingToLength:name.length withString:@"?" startingAtIndex:0]; 44 name = [@"" stringByPaddingToLength:name.length withString:@"?" startingAtIndex:0];
50 location = [@"" stringByPaddingToLength:location.length withString:@"?" startingAtIndex:0]; 45 location = [@"" stringByPaddingToLength:location.length withString:@"?" startingAtIndex:0];
51 } 46 }
@@ -93,7 +88,7 @@
93 UIImage* selectionBackground = UIGraphicsGetImageFromCurrentImageContext(); 88 UIImage* selectionBackground = UIGraphicsGetImageFromCurrentImageContext();
94 89
95 // Now we want to put the level image inside the frame without messing up the frame itself 90 // Now we want to put the level image inside the frame without messing up the frame itself
96 UIImage* innerPicture = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:filename ofType:@"png"]]; 91 UIImage* innerPicture = gameMode.image;
97 CGContextClipToMask(context, CGRectMake(0, 0, boxSize.width, boxSize.height), [[selectionBackground opaqueMaskFromWhiteImage] CGImage]); 92 CGContextClipToMask(context, CGRectMake(0, 0, boxSize.width, boxSize.height), [[selectionBackground opaqueMaskFromWhiteImage] CGImage]);
98 [innerPicture drawInRect:CGRectMake(6, 6, 128, 128)]; 93 [innerPicture drawInRect:CGRectMake(6, 6, 128, 128)];
99 selectionBackground = UIGraphicsGetImageFromCurrentImageContext(); 94 selectionBackground = UIGraphicsGetImageFromCurrentImageContext();
@@ -104,7 +99,7 @@
104 context = UIGraphicsGetCurrentContext(); 99 context = UIGraphicsGetCurrentContext();
105 CGContextSaveGState(context); 100 CGContextSaveGState(context);
106 101
107 if (unlocked) 102 if (gameMode.unlocked)
108 { 103 {
109 CGContextSetShadow(context, CGSizeMake(-6, 6), 4.0f); 104 CGContextSetShadow(context, CGSizeMake(-6, 6), 4.0f);
110 [selectionBackground drawInRect:CGRectMake(10, 0, boxSize.width, boxSize.height)]; 105 [selectionBackground drawInRect:CGRectMake(10, 0, boxSize.width, boxSize.height)];
@@ -159,7 +154,7 @@
159 titleSprite.position = ccp(-10, (boxSize.height)/2+(combinedTitleSize.height)/2); 154 titleSprite.position = ccp(-10, (boxSize.height)/2+(combinedTitleSize.height)/2);
160 [self addChild:titleSprite]; 155 [self addChild:titleSprite];
161 156
162 if (unlocked) 157 if (gameMode.unlocked)
163 { 158 {
164 Highscore* localHighscore = [Highscore localHighscoreForGameMode:name]; 159 Highscore* localHighscore = [Highscore localHighscoreForGameMode:name];
165 160
@@ -177,7 +172,7 @@
177 172
178 CGImageRef highscoreImage = [UIGraphicsGetImageFromCurrentImageContext() CGImage]; 173 CGImageRef highscoreImage = [UIGraphicsGetImageFromCurrentImageContext() CGImage];
179 UIGraphicsEndImageContext(); 174 UIGraphicsEndImageContext();
180 CCSprite* highscoreSprite = [CCSprite spriteWithCGImage:highscoreImage key:[NSString stringWithFormat:@"gms-%@-highscore-%d", filename, localHighscore.score]]; 175 CCSprite* highscoreSprite = [CCSprite spriteWithCGImage:highscoreImage key:[NSString stringWithFormat:@"gms-%@-highscore-%d", name, localHighscore.score]];
181 highscoreSprite.position = ccp(-5, 0-64-(highscoreSize.height)/2-10); 176 highscoreSprite.position = ccp(-5, 0-64-(highscoreSize.height)/2-10);
182 [self addChild:highscoreSprite]; 177 [self addChild:highscoreSprite];
183 } 178 }
@@ -187,21 +182,9 @@
187 return self; 182 return self;
188} 183}
189 184
190- (id)initWithName:(NSString *)m_name location:(NSString *)m_location filename:(NSString *)m_filename unlockCondition:(NSString*)m_unlockCondition
191{
192 self = [self initWithName:m_name location:m_location filename:m_filename unlocked:NO];
193
194 if (nil != self)
195 {
196 unlockCondition = m_unlockCondition;
197 }
198
199 return self;
200}
201
202- (void)buttonTapped 185- (void)buttonTapped
203{ 186{
204 if (unlocked) 187 if (gameMode.unlocked)
205 { 188 {
206 if (delegate != nil) 189 if (delegate != nil)
207 { 190 {
@@ -210,7 +193,7 @@
210 NSLog(@"I don't have a GameModeSelectionDelegate to call for some reason..."); 193 NSLog(@"I don't have a GameModeSelectionDelegate to call for some reason...");
211 } 194 }
212 } else { 195 } else {
213 UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"To unlock this game mode:" message:unlockCondition delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:nil]; 196 UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"To unlock this game mode:" message:gameMode.unlockCondition delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:nil];
214 [alertView show]; 197 [alertView show];
215 [alertView release]; 198 [alertView release];
216 } 199 }
diff --git a/Classes/GameModeSelectionLayer.m b/Classes/GameModeSelectionLayer.m index e7b6966..e5a83f1 100644 --- a/Classes/GameModeSelectionLayer.m +++ b/Classes/GameModeSelectionLayer.m
@@ -11,11 +11,10 @@
11#import <sqlite3.h> 11#import <sqlite3.h>
12#import "Cart_CollectAppDelegate.h" 12#import "Cart_CollectAppDelegate.h"
13#import "MainMenuLayer.h" 13#import "MainMenuLayer.h"
14#import "TutorialMode.h"
15#import "ClassicGameMode.h"
16#import "NMPanelMenu.h" 14#import "NMPanelMenu.h"
17#import "JumpGameMode.h"
18#import "ZoomFadeTransition.h" 15#import "ZoomFadeTransition.h"
16#import "GameModeInfo.h"
17#import "GameModeManager.h"
19 18
20@implementation GameModeSelectionLayer 19@implementation GameModeSelectionLayer
21 20
@@ -44,31 +43,12 @@
44 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; 43 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
45 gameModes = [[NSMutableArray alloc] init]; 44 gameModes = [[NSMutableArray alloc] init];
46 45
47 GameModeSelection* tutorialSelection = [GameModeSelection selectionWithName:@"Tutorial" location:@"Florence" filename:@"florence" unlocked:YES]; 46 for (GameModeInfo* info in [[GameModeManager sharedInstance] gameModes])
48 [gameModes addObject:tutorialSelection];
49
50 GameModeSelection* collectSelection;
51
52 if ([defaults boolForKey:@"hasDoneTutorial"])
53 {
54 collectSelection = [GameModeSelection selectionWithName:@"Collect" location:@"Paris" filename:@"paris" unlocked:YES];
55 } else {
56 collectSelection = [GameModeSelection selectionWithName:@"Collect" location:@"Paris" filename:@"paris" unlockCondition:@"Beat the tutorial!"];
57 }
58
59 [gameModes addObject:collectSelection];
60
61 GameModeSelection* jumpSelection;
62
63 if ([defaults boolForKey:@"unlockedJumpMode"])
64 { 47 {
65 jumpSelection = [GameModeSelection selectionWithName:@"Jump" location:@"Venice" filename:@"venice" unlocked:YES]; 48 GameModeSelection* selection = [GameModeSelection selectionWithGameModeInfo:info];
66 } else { 49 [gameModes addObject:selection];
67 jumpSelection = [GameModeSelection selectionWithName:@"Jump" location:@"Venice" filename:@"venice" unlockCondition:@"Get 3000 points in Collect!"];
68 } 50 }
69 51
70 [gameModes addObject:jumpSelection];
71
72 CCMenu* menu = [CCMenu menuWithItems:nil]; 52 CCMenu* menu = [CCMenu menuWithItems:nil];
73 float onePanelWide = 128; 53 float onePanelWide = 128;
74 float padding = 15; 54 float padding = 15;
@@ -131,24 +111,15 @@
131 [[CCDirector sharedDirector] replaceScene:[MainMenuLayer scene]]; 111 [[CCDirector sharedDirector] replaceScene:[MainMenuLayer scene]];
132} 112}
133 113
134- (void)didSelectGameMode:(GameModeSelection *)gameMode 114- (void)didSelectGameMode:(GameModeSelection *)selection
135{ 115{
136 [scrollView setScrollEnabled:NO]; 116 [scrollView setScrollEnabled:NO];
137 [pageControl removeFromSuperview]; 117 [pageControl removeFromSuperview];
138 118
139 CGPoint opp = [scrollView convertPoint:gameMode.position toView:[[CCDirector sharedDirector] openGLView]]; 119 CGPoint opp = [scrollView convertPoint:selection.position toView:[[CCDirector sharedDirector] openGLView]];
140 CGPoint endPosition = ccp(0-(opp.x+158), opp.y); 120 CGPoint endPosition = ccp(0-(opp.x+158), opp.y);
141 121
142 if ([gameMode.name isEqual:@"Tutorial"]) 122 [[CCDirector sharedDirector] replaceScene:[ZoomFadeTransition transitionWithDuration:5.0f scene:[selection.gameMode scene] position:endPosition]];
143 {
144 [[CCDirector sharedDirector] replaceScene:[ZoomFadeTransition transitionWithDuration:5.0f scene:[TutorialMode scene] position:endPosition]];
145 } else if ([gameMode.name isEqual:@"Collect"])
146 {
147 [[CCDirector sharedDirector] replaceScene:[ZoomFadeTransition transitionWithDuration:5.0f scene:[ClassicGameMode scene] position:endPosition]];
148 } else if ([gameMode.name isEqual:@"Jump"])
149 {
150 [[CCDirector sharedDirector] replaceScene:[ZoomFadeTransition transitionWithDuration:5.0f scene:[JumpGameMode scene] position:endPosition]];
151 }
152} 123}
153 124
154@end 125@end
diff --git a/Classes/GameOverScene.h b/Classes/GameOverScene.h index f596211..5987c20 100755 --- a/Classes/GameOverScene.h +++ b/Classes/GameOverScene.h
@@ -8,6 +8,7 @@
8 8
9#import <Foundation/Foundation.h> 9#import <Foundation/Foundation.h>
10#import "cocos2d.h" 10#import "cocos2d.h"
11#import "GameModeInfo.h"
11 12
12@interface GameOverScene : CCScene <UITextFieldDelegate, UIAlertViewDelegate> { 13@interface GameOverScene : CCScene <UITextFieldDelegate, UIAlertViewDelegate> {
13 CCLayer* theLayer; 14 CCLayer* theLayer;
@@ -19,12 +20,12 @@
19 UIButton* backButton; 20 UIButton* backButton;
20 UIButton* playButton; 21 UIButton* playButton;
21 int score; 22 int score;
22 NSString* gameMode; 23 GameModeInfo* gameMode;
23 BOOL playAgain; 24 BOOL playAgain;
24} 25}
25 26
26+ (GameOverScene*)sceneWithScore:(int)score gameMode:(NSString*)gameMode; 27+ (GameOverScene*)sceneWithScore:(int)score gameMode:(GameModeInfo*)gameMode;
27- (id)initWithScore:(int)score gameMode:(NSString*)gameMode; 28- (id)initWithScore:(int)score gameMode:(GameModeInfo*)gameMode;
28- (void)newgame:(id)sender; 29- (void)newgame:(id)sender;
29- (void)submitScore; 30- (void)submitScore;
30- (void)exit; 31- (void)exit;
diff --git a/Classes/GameOverScene.m b/Classes/GameOverScene.m index a56aeac..07186c2 100755 --- a/Classes/GameOverScene.m +++ b/Classes/GameOverScene.m
@@ -11,17 +11,15 @@
11#import <sqlite3.h> 11#import <sqlite3.h>
12#import "cocoslive.h" 12#import "cocoslive.h"
13#import "MainMenuLayer.h" 13#import "MainMenuLayer.h"
14#import "ClassicGameMode.h"
15#import "JumpGameMode.h"
16 14
17@implementation GameOverScene 15@implementation GameOverScene
18 16
19+ (GameOverScene*)sceneWithScore:(int)score gameMode:(NSString*)gameMode 17+ (GameOverScene*)sceneWithScore:(int)score gameMode:(GameModeInfo*)gameMode
20{ 18{
21 return [[[GameOverScene alloc] initWithScore:score gameMode:gameMode] autorelease]; 19 return [[[GameOverScene alloc] initWithScore:score gameMode:gameMode] autorelease];
22} 20}
23 21
24- (id)initWithScore:(int)score2 gameMode:(NSString*)gameMode2 22- (id)initWithScore:(int)m_score gameMode:(GameModeInfo*)m_gameMode
25{ 23{
26 self = [super init]; 24 self = [super init];
27 25
@@ -37,8 +35,8 @@
37 backgroundImage.position = ccp(240, 160); 35 backgroundImage.position = ccp(240, 160);
38 [theLayer addChild:backgroundImage z:0]; 36 [theLayer addChild:backgroundImage z:0];
39 37
40 score = score2; 38 score = m_score;
41 gameMode = gameMode2; 39 gameMode = m_gameMode;
42 40
43 movingLayer = [[UIView alloc] initWithFrame:CGRectMake(0, -320, 480, 320)]; 41 movingLayer = [[UIView alloc] initWithFrame:CGRectMake(0, -320, 480, 320)];
44 movingLayer.backgroundColor = [UIColor clearColor]; 42 movingLayer.backgroundColor = [UIColor clearColor];
@@ -47,7 +45,7 @@
47 scoreField = [[UILabel alloc] initWithFrame:CGRectMake(205, 320-200, 0, 0)]; 45 scoreField = [[UILabel alloc] initWithFrame:CGRectMake(205, 320-200, 0, 0)];
48 [scoreField setFont:[UIFont systemFontOfSize:20.0f]]; 46 [scoreField setFont:[UIFont systemFontOfSize:20.0f]];
49 [scoreField setBackgroundColor:[UIColor clearColor]]; 47 [scoreField setBackgroundColor:[UIColor clearColor]];
50 [scoreField setText:[NSString stringWithFormat:@"%d", score2]]; 48 [scoreField setText:[NSString stringWithFormat:@"%d", score]];
51 CGSize labelSize = [scoreField.text sizeWithFont:scoreField.font constrainedToSize:CGSizeMake(160, 31) lineBreakMode:UILineBreakModeClip]; 49 CGSize labelSize = [scoreField.text sizeWithFont:scoreField.font constrainedToSize:CGSizeMake(160, 31) lineBreakMode:UILineBreakModeClip];
52 [scoreField setFrame:CGRectMake(scoreField.frame.origin.x, scoreField.frame.origin.y, labelSize.width, labelSize.height)]; 50 [scoreField setFrame:CGRectMake(scoreField.frame.origin.x, scoreField.frame.origin.y, labelSize.width, labelSize.height)];
53 [movingLayer addSubview:scoreField]; 51 [movingLayer addSubview:scoreField];
@@ -103,7 +101,7 @@
103 textField.enabled = NO; 101 textField.enabled = NO;
104 submitSwitch.enabled = NO; 102 submitSwitch.enabled = NO;
105 103
106 const char* sqlQuery = [[NSString stringWithFormat:@"INSERT INTO highscores (name, score, gameMode) VALUES (\"%@\",%d,\"%@\")", [textField text], score, gameMode] UTF8String]; 104 const char* sqlQuery = [[NSString stringWithFormat:@"INSERT INTO highscores (name, score, gameMode) VALUES (\"%@\",%d,\"%@\")", [textField text], score, gameMode.name] UTF8String];
107 sqlite3_stmt* compiled_statement; 105 sqlite3_stmt* compiled_statement;
108 106
109 if (sqlite3_prepare_v2([Cart_CollectAppDelegate database], sqlQuery, -1, &compiled_statement, NULL) == SQLITE_OK) 107 if (sqlite3_prepare_v2([Cart_CollectAppDelegate database], sqlQuery, -1, &compiled_statement, NULL) == SQLITE_OK)
@@ -128,14 +126,7 @@
128 126
129 CLScoreServerPost* server = [[CLScoreServerPost alloc] initWithGameName:@"Cart Collect" gameKey:@"38f440a074b3264386455a36b2706d8f" delegate:self]; 127 CLScoreServerPost* server = [[CLScoreServerPost alloc] initWithGameName:@"Cart Collect" gameKey:@"38f440a074b3264386455a36b2706d8f" delegate:self];
130 NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; 128 NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
131 129 [dict setObject:gameMode.globalHighscoreKey forKey:@"cc_category"];
132 if ([gameMode isEqual:@"Collect"])
133 {
134 [dict setObject:@"Classic" forKey:@"cc_category"];
135 } else {
136 [dict setObject:gameMode forKey:@"cc_category"];
137 }
138
139 [dict setObject:[textField text] forKey:@"cc_playername"]; 130 [dict setObject:[textField text] forKey:@"cc_playername"];
140 [dict setObject:[NSNumber numberWithInt:score] forKey:@"cc_score"]; 131 [dict setObject:[NSNumber numberWithInt:score] forKey:@"cc_score"];
141 [server sendScore:dict]; 132 [server sendScore:dict];
@@ -224,13 +215,7 @@
224 215
225 if (playAgain) 216 if (playAgain)
226 { 217 {
227 if ([gameMode isEqual:@"Collect"]) 218 [[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:3.0f scene:[gameMode scene] withColor:ccc3(0, 0, 0)]];
228 {
229 [[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:3.0f scene:[ClassicGameMode scene] withColor:ccc3(0, 0, 0)]];
230 } else if ([gameMode isEqual:@"Jump"])
231 {
232 [[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:3.0f scene:[JumpGameMode scene] withColor:ccc3(0, 0, 0)]];
233 }
234 } else { 219 } else {
235 [[CCDirector sharedDirector] replaceScene:[MainMenuLayer scene]]; 220 [[CCDirector sharedDirector] replaceScene:[MainMenuLayer scene]];
236 } 221 }
diff --git a/Classes/JumpGameMode.m b/Classes/JumpGameMode.m index a5c2b8f..b1c5989 100644 --- a/Classes/JumpGameMode.m +++ b/Classes/JumpGameMode.m
@@ -35,6 +35,26 @@ typedef enum {
35 kPointMultiplierObject 35 kPointMultiplierObject
36} FallingObjects; 36} FallingObjects;
37 37
38static GameModeInfo* info;
39
40+ (GameModeInfo*)info
41{
42 if (info == nil)
43 {
44 info = [[GameModeInfo alloc] initWithName:@"Jump"
45 location:@"Venice"
46 numOfStars:3
47 imageFilename:[[NSBundle mainBundle] pathForResource:@"venice" ofType:@"png"]
48 unlocked:NO
49 unlockCondition:@"Get 2000 points in Collect!"
50 gameClass:[JumpGameMode class]
51 globalHighscoreKey:@"Jump"
52 starsToUnlock:2];
53 }
54
55 return info;
56}
57
38- (id)init 58- (id)init
39{ 59{
40 self = [super init]; 60 self = [super init];
@@ -208,7 +228,7 @@ typedef enum {
208 { 228 {
209 [self unscheduleAllSelectors]; 229 [self unscheduleAllSelectors];
210 230
211 [[CCDirector sharedDirector] replaceScene:[CCTransitionSlideInT transitionWithDuration:1.5f scene:[GameOverScene sceneWithScore:score gameMode:@"Jump"]]]; 231 [[CCDirector sharedDirector] replaceScene:[CCTransitionSlideInT transitionWithDuration:1.5f scene:[GameOverScene sceneWithScore:score gameMode:[JumpGameMode info]]]];
212 } 232 }
213 233
214 if (wave) 234 if (wave)
diff --git a/Classes/TutorialMode.m b/Classes/TutorialMode.m index 156b939..54f4e16 100644 --- a/Classes/TutorialMode.m +++ b/Classes/TutorialMode.m
@@ -10,6 +10,7 @@
10#import "FallingObject.h" 10#import "FallingObject.h"
11#import "GameModeSelectionLayer.h" 11#import "GameModeSelectionLayer.h"
12#import "SimpleAudioEngine.h" 12#import "SimpleAudioEngine.h"
13#import "ClassicGameMode.h"
13 14
14// Item tags: 15// Item tags:
15// 2000 - first dropped item 16// 2000 - first dropped item
@@ -30,6 +31,26 @@ typedef enum {
30 31
31@synthesize currentTutorial; 32@synthesize currentTutorial;
32 33
34static GameModeInfo* info;
35
36+ (GameModeInfo*)info
37{
38 if (info == nil)
39 {
40 info = [[GameModeInfo alloc] initWithName:@"Tutorial"
41 location:@"Florence"
42 numOfStars:0
43 imageFilename:[[NSBundle mainBundle] pathForResource:@"florence" ofType:@"png"]
44 unlocked:YES
45 unlockCondition:nil
46 gameClass:[TutorialMode class]
47 globalHighscoreKey:nil
48 starsToUnlock:0];
49 }
50
51 return info;
52}
53
33- (id)init 54- (id)init
34{ 55{
35 self = [super init]; 56 self = [super init];
@@ -357,8 +378,7 @@ typedef enum {
357 378
358 [self unschedule:@selector(randomlyAddObject:)]; 379 [self unschedule:@selector(randomlyAddObject:)];
359 380
360 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; 381 [[ClassicGameMode info] unlock];
361 [defaults setBool:YES forKey:@"hasDoneTutorial"];
362 382
363 return; 383 return;
364 } else { 384 } else {
diff --git a/Resources/star_1.png b/Resources/star_1.png new file mode 100755 index 0000000..658c711 --- /dev/null +++ b/Resources/star_1.png
Binary files differ
diff --git a/Resources/star_2.png b/Resources/star_2.png new file mode 100755 index 0000000..028a546 --- /dev/null +++ b/Resources/star_2.png
Binary files differ
diff --git a/Resources/star_3.png b/Resources/star_3.png new file mode 100755 index 0000000..97a22b7 --- /dev/null +++ b/Resources/star_3.png
Binary files differ