diff options
author | Starla Insigna <starla4444@gmail.com> | 2013-01-02 23:08:46 -0500 |
---|---|---|
committer | Starla Insigna <starla4444@gmail.com> | 2013-01-02 23:08:46 -0500 |
commit | 28497668761472e085d0c9955aa8077d11bf353c (patch) | |
tree | 48676176c8f2de27f4959d05f209f2f98da3979b /Classes | |
parent | 6e96fb2144718722208d22f892716b55548135e1 (diff) | |
download | cartcollect-28497668761472e085d0c9955aa8077d11bf353c.tar.gz cartcollect-28497668761472e085d0c9955aa8077d11bf353c.tar.bz2 cartcollect-28497668761472e085d0c9955aa8077d11bf353c.zip |
Removed locked game modes from selection screen
Also removed cluttering attributes "unlockCondition" and "starsToUnlock" from GameModeInfo because they're really not that generalized (and unlockCondition doesn't really make sense if locked game modes are invisible anyway). starsToUnlock can be replaced by simply putting if statements in to GameModeManager's setStars: and then unlocking modes based off that. Completing the tutorial also now unlocks both Collect AND Jump. The idea is that we should make more than just Collect available at the start, and have only a few super hidden game modes that are unlockable; hence locked game modes being invisible.
Diffstat (limited to 'Classes')
-rwxr-xr-x | Classes/ClassicGameMode.m | 6 | ||||
-rw-r--r-- | Classes/GameModeInfo.h | 5 | ||||
-rw-r--r-- | Classes/GameModeInfo.m | 6 | ||||
-rw-r--r-- | Classes/GameModeManager.m | 8 | ||||
-rw-r--r-- | Classes/GameModeSelection.m | 90 | ||||
-rw-r--r-- | Classes/GameModeSelectionLayer.m | 7 | ||||
-rw-r--r-- | Classes/JumpGameMode.m | 6 | ||||
-rw-r--r-- | Classes/TutorialMode.m | 6 |
8 files changed, 48 insertions, 86 deletions
diff --git a/Classes/ClassicGameMode.m b/Classes/ClassicGameMode.m index 9356fea..00bf049 100755 --- a/Classes/ClassicGameMode.m +++ b/Classes/ClassicGameMode.m | |||
@@ -30,11 +30,9 @@ static GameModeInfo* info; | |||
30 | location:@"Paris" | 30 | location:@"Paris" |
31 | numOfStars:3 | 31 | numOfStars:3 |
32 | imageFilename:[[NSBundle mainBundle] pathForResource:@"paris" ofType:@"png"] | 32 | imageFilename:[[NSBundle mainBundle] pathForResource:@"paris" ofType:@"png"] |
33 | unlocked:NO | 33 | unlocked:YES |
34 | unlockCondition:@"Beat the tutorial!" | ||
35 | gameClass:[ClassicGameMode class] | 34 | gameClass:[ClassicGameMode class] |
36 | globalHighscoreKey:@"Classic" | 35 | globalHighscoreKey:@"Classic"]; |
37 | starsToUnlock:0]; | ||
38 | } | 36 | } |
39 | 37 | ||
40 | return info; | 38 | return info; |
diff --git a/Classes/GameModeInfo.h b/Classes/GameModeInfo.h index 2262526..7d60645 100644 --- a/Classes/GameModeInfo.h +++ b/Classes/GameModeInfo.h | |||
@@ -19,7 +19,6 @@ | |||
19 | NSString* unlockCondition; | 19 | NSString* unlockCondition; |
20 | Class gameClass; | 20 | Class gameClass; |
21 | NSString* globalHighscoreKey; | 21 | NSString* globalHighscoreKey; |
22 | int starsToUnlock; | ||
23 | } | 22 | } |
24 | 23 | ||
25 | @property (readonly) NSString* name; | 24 | @property (readonly) NSString* name; |
@@ -27,10 +26,8 @@ | |||
27 | @property (readonly) int numOfStars; | 26 | @property (readonly) int numOfStars; |
28 | @property (readonly) UIImage* image; | 27 | @property (readonly) UIImage* image; |
29 | @property (readonly) BOOL unlocked; | 28 | @property (readonly) BOOL unlocked; |
30 | @property (readonly) NSString* unlockCondition; | ||
31 | @property (readonly) NSString* globalHighscoreKey; | 29 | @property (readonly) NSString* globalHighscoreKey; |
32 | @property (readonly) int starsToUnlock; | 30 | - (id)initWithName:(NSString*)m_name location:(NSString*)m_location numOfStars:(int)m_numOfStars imageFilename:(NSString*)m_imageFilename unlocked:(BOOL)m_unlocked gameClass:(Class)m_gameClass globalHighscoreKey:(NSString*)m_globalHighscoreKey; |
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; | 31 | - (void)setStar:(int)star_id withMessage:(NSString*)message; |
35 | - (BOOL)star:(int)star_id; | 32 | - (BOOL)star:(int)star_id; |
36 | - (int)starsCollected; | 33 | - (int)starsCollected; |
diff --git a/Classes/GameModeInfo.m b/Classes/GameModeInfo.m index 8b33fd8..1f85978 100644 --- a/Classes/GameModeInfo.m +++ b/Classes/GameModeInfo.m | |||
@@ -14,9 +14,9 @@ | |||
14 | 14 | ||
15 | @implementation GameModeInfo | 15 | @implementation GameModeInfo |
16 | 16 | ||
17 | @synthesize name, location, numOfStars, image, unlocked, unlockCondition, globalHighscoreKey, starsToUnlock; | 17 | @synthesize name, location, numOfStars, image, unlocked, globalHighscoreKey; |
18 | 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 | 19 | - (id)initWithName:(NSString*)m_name location:(NSString*)m_location numOfStars:(int)m_numOfStars imageFilename:(NSString*)m_imageFilename unlocked:(BOOL)m_unlocked gameClass:(Class)m_gameClass globalHighscoreKey:(NSString*)m_globalHighscoreKey |
20 | { | 20 | { |
21 | self = [super init]; | 21 | self = [super init]; |
22 | 22 | ||
@@ -26,9 +26,7 @@ | |||
26 | location = m_location; | 26 | location = m_location; |
27 | numOfStars = m_numOfStars; | 27 | numOfStars = m_numOfStars; |
28 | image = [[UIImage alloc] initWithContentsOfFile:m_imageFilename]; | 28 | image = [[UIImage alloc] initWithContentsOfFile:m_imageFilename]; |
29 | unlockCondition = m_unlockCondition; | ||
30 | globalHighscoreKey = m_globalHighscoreKey; | 29 | globalHighscoreKey = m_globalHighscoreKey; |
31 | starsToUnlock = m_starsToUnlock; | ||
32 | 30 | ||
33 | NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; | 31 | NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; |
34 | unlocked = [defaults boolForKey:[NSString stringWithFormat:@"gameModeUnlocked-%@", name]]; | 32 | unlocked = [defaults boolForKey:[NSString stringWithFormat:@"gameModeUnlocked-%@", name]]; |
diff --git a/Classes/GameModeManager.m b/Classes/GameModeManager.m index 5a6e109..d7cd21e 100644 --- a/Classes/GameModeManager.m +++ b/Classes/GameModeManager.m | |||
@@ -56,13 +56,7 @@ static GameModeManager* sharedInstance = nil; | |||
56 | NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; | 56 | NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; |
57 | [defaults setInteger:m_stars forKey:@"stars"]; | 57 | [defaults setInteger:m_stars forKey:@"stars"]; |
58 | 58 | ||
59 | for (GameModeInfo* gameMode in gameModes) | 59 | // Here, unlock game modes that have reached enough stars |
60 | { | ||
61 | if ((!gameMode.unlocked) && (stars >= gameMode.starsToUnlock)) | ||
62 | { | ||
63 | [gameMode unlock]; | ||
64 | } | ||
65 | } | ||
66 | } | 60 | } |
67 | } | 61 | } |
68 | 62 | ||
diff --git a/Classes/GameModeSelection.m b/Classes/GameModeSelection.m index 61004fa..ea5f45b 100644 --- a/Classes/GameModeSelection.m +++ b/Classes/GameModeSelection.m | |||
@@ -26,6 +26,13 @@ | |||
26 | 26 | ||
27 | if (nil != self) | 27 | if (nil != self) |
28 | { | 28 | { |
29 | if (!m_gameMode.unlocked) | ||
30 | { | ||
31 | @throw [NSException exceptionWithName:NSInvalidArgumentException | ||
32 | reason:@"Game mode must be unlocked to appear on selection screen" | ||
33 | userInfo:nil]; | ||
34 | } | ||
35 | |||
29 | self.anchorPoint = CGPointMake(0.5f, 0.5f); | 36 | self.anchorPoint = CGPointMake(0.5f, 0.5f); |
30 | 37 | ||
31 | gameMode = m_gameMode; | 38 | gameMode = m_gameMode; |
@@ -34,16 +41,6 @@ | |||
34 | 41 | ||
35 | NSString* name = gameMode.name; | 42 | NSString* name = gameMode.name; |
36 | NSString* location = gameMode.location; | 43 | NSString* location = gameMode.location; |
37 | NSString* filenameMod; | ||
38 | |||
39 | if (gameMode.unlocked) | ||
40 | { | ||
41 | filenameMod = [NSString stringWithFormat:@"%@-unlocked", name]; | ||
42 | } else { | ||
43 | filenameMod = [NSString stringWithFormat:@"%@-locked", name]; | ||
44 | name = [@"" stringByPaddingToLength:name.length withString:@"?" startingAtIndex:0]; | ||
45 | location = [@"" stringByPaddingToLength:location.length withString:@"?" startingAtIndex:0]; | ||
46 | } | ||
47 | 44 | ||
48 | // First, create the frame that we will put the level picture inside | 45 | // First, create the frame that we will put the level picture inside |
49 | CGImageRef framestuff = [[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"framestuff" ofType:@"png"]] CGImage]; | 46 | CGImageRef framestuff = [[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"framestuff" ofType:@"png"]] CGImage]; |
@@ -99,26 +96,13 @@ | |||
99 | context = UIGraphicsGetCurrentContext(); | 96 | context = UIGraphicsGetCurrentContext(); |
100 | CGContextSaveGState(context); | 97 | CGContextSaveGState(context); |
101 | 98 | ||
102 | if (gameMode.unlocked) | 99 | CGContextSetShadow(context, CGSizeMake(-6, 6), 4.0f); |
103 | { | 100 | [selectionBackground drawInRect:CGRectMake(10, 0, boxSize.width, boxSize.height)]; |
104 | CGContextSetShadow(context, CGSizeMake(-6, 6), 4.0f); | ||
105 | [selectionBackground drawInRect:CGRectMake(10, 0, boxSize.width, boxSize.height)]; | ||
106 | } else { | ||
107 | // Draw the picture in grayscale if the level has not yet been unlocked | ||
108 | CGContextClipToMask(context, CGRectMake(10, 0, boxSize.width, boxSize.height), [selectionBackground CGImage]); | ||
109 | CGContextSetFillColorWithColor(context, [[UIColor whiteColor] CGColor]); | ||
110 | CGContextFillRect(context, CGRectMake(10, 0, boxSize.width, boxSize.height)); | ||
111 | CGContextRestoreGState(context); | ||
112 | |||
113 | CGContextSaveGState(context); | ||
114 | CGContextSetShadow(context, CGSizeMake(-6, 6), 4.0f); | ||
115 | [selectionBackground drawInRect:CGRectMake(10, 0, boxSize.width, boxSize.height) blendMode:kCGBlendModeLuminosity alpha:1.0]; | ||
116 | } | ||
117 | 101 | ||
118 | CGContextRestoreGState(context); | 102 | CGContextRestoreGState(context); |
119 | CGImageRef pictureRef = [UIGraphicsGetImageFromCurrentImageContext() CGImage]; | 103 | CGImageRef pictureRef = [UIGraphicsGetImageFromCurrentImageContext() CGImage]; |
120 | 104 | ||
121 | CCSprite* picture = [CCSprite spriteWithCGImage:pictureRef key:[NSString stringWithFormat:@"gms-%@", filenameMod]]; | 105 | CCSprite* picture = [CCSprite spriteWithCGImage:pictureRef key:[NSString stringWithFormat:@"gms-%@", name]]; |
122 | 106 | ||
123 | // We're also going to need a "selected" image state for the button | 107 | // We're also going to need a "selected" image state for the button |
124 | CGContextSaveGState(context); | 108 | CGContextSaveGState(context); |
@@ -128,7 +112,7 @@ | |||
128 | CGContextRestoreGState(context); | 112 | CGContextRestoreGState(context); |
129 | CGImageRef selectedButtonRef = [UIGraphicsGetImageFromCurrentImageContext() CGImage]; | 113 | CGImageRef selectedButtonRef = [UIGraphicsGetImageFromCurrentImageContext() CGImage]; |
130 | UIGraphicsEndImageContext(); | 114 | UIGraphicsEndImageContext(); |
131 | CCSprite* selectedButton = [CCSprite spriteWithCGImage:selectedButtonRef key:[NSString stringWithFormat:@"gms-%@-selected", filenameMod]]; | 115 | CCSprite* selectedButton = [CCSprite spriteWithCGImage:selectedButtonRef key:[NSString stringWithFormat:@"gms-%@-selected", name]]; |
132 | 116 | ||
133 | CCMenuItemSprite* pictureMenuItem = [CCMenuItemSprite itemFromNormalSprite:picture selectedSprite:selectedButton target:self selector:@selector(buttonTapped)]; | 117 | CCMenuItemSprite* pictureMenuItem = [CCMenuItemSprite itemFromNormalSprite:picture selectedSprite:selectedButton target:self selector:@selector(buttonTapped)]; |
134 | NMPanelMenu* theMenu = [NMPanelMenu menuWithItems:pictureMenuItem, nil]; | 118 | NMPanelMenu* theMenu = [NMPanelMenu menuWithItems:pictureMenuItem, nil]; |
@@ -150,32 +134,29 @@ | |||
150 | 134 | ||
151 | CGImageRef titleImage = [UIGraphicsGetImageFromCurrentImageContext() CGImage]; | 135 | CGImageRef titleImage = [UIGraphicsGetImageFromCurrentImageContext() CGImage]; |
152 | UIGraphicsEndImageContext(); | 136 | UIGraphicsEndImageContext(); |
153 | CCSprite* titleSprite = [CCSprite spriteWithCGImage:titleImage key:[NSString stringWithFormat:@"gms-%@-title", filenameMod]]; | 137 | CCSprite* titleSprite = [CCSprite spriteWithCGImage:titleImage key:[NSString stringWithFormat:@"gms-%@-title", name]]; |
154 | titleSprite.position = ccp(-10, (boxSize.height)/2+(combinedTitleSize.height)/2); | 138 | titleSprite.position = ccp(-10, (boxSize.height)/2+(combinedTitleSize.height)/2); |
155 | [self addChild:titleSprite]; | 139 | [self addChild:titleSprite]; |
156 | 140 | ||
157 | if (gameMode.unlocked) | 141 | Highscore* localHighscore = [Highscore localHighscoreForGameMode:name]; |
142 | |||
143 | if (localHighscore != nil) | ||
158 | { | 144 | { |
159 | Highscore* localHighscore = [Highscore localHighscoreForGameMode:name]; | 145 | // Render the highscore label |
146 | NSString* highscoreString = [NSString stringWithFormat:@"Highscore: %d", localHighscore.score]; | ||
147 | UIFont* highscoreFont = [UIFont fontWithName:@"AmericanTypewriter" size:16.0f]; | ||
148 | CGSize highscoreSize = [highscoreString sizeWithFont:highscoreFont]; | ||
160 | 149 | ||
161 | if (localHighscore != nil) | 150 | UIGraphicsBeginImageContext(CGSizeMake(highscoreSize.width+10, highscoreSize.height+10)); |
162 | { | 151 | CGContextRef context = UIGraphicsGetCurrentContext(); |
163 | // Render the highscore label | 152 | CGContextSetShadow(context, CGSizeMake(-6, 6), 4.0f); |
164 | NSString* highscoreString = [NSString stringWithFormat:@"Highscore: %d", localHighscore.score]; | 153 | [highscoreString drawInRect:CGRectMake(10, 0, highscoreSize.width, highscoreSize.height) withFont:highscoreFont]; |
165 | UIFont* highscoreFont = [UIFont fontWithName:@"AmericanTypewriter" size:16.0f]; | 154 | |
166 | CGSize highscoreSize = [highscoreString sizeWithFont:highscoreFont]; | 155 | CGImageRef highscoreImage = [UIGraphicsGetImageFromCurrentImageContext() CGImage]; |
167 | 156 | UIGraphicsEndImageContext(); | |
168 | UIGraphicsBeginImageContext(CGSizeMake(highscoreSize.width+10, highscoreSize.height+10)); | 157 | CCSprite* highscoreSprite = [CCSprite spriteWithCGImage:highscoreImage key:[NSString stringWithFormat:@"gms-%@-highscore-%d", name, localHighscore.score]]; |
169 | CGContextRef context = UIGraphicsGetCurrentContext(); | 158 | highscoreSprite.position = ccp(-5, 0-64-(highscoreSize.height)/2-10); |
170 | CGContextSetShadow(context, CGSizeMake(-6, 6), 4.0f); | 159 | [self addChild:highscoreSprite]; |
171 | [highscoreString drawInRect:CGRectMake(10, 0, highscoreSize.width, highscoreSize.height) withFont:highscoreFont]; | ||
172 | |||
173 | CGImageRef highscoreImage = [UIGraphicsGetImageFromCurrentImageContext() CGImage]; | ||
174 | UIGraphicsEndImageContext(); | ||
175 | CCSprite* highscoreSprite = [CCSprite spriteWithCGImage:highscoreImage key:[NSString stringWithFormat:@"gms-%@-highscore-%d", name, localHighscore.score]]; | ||
176 | highscoreSprite.position = ccp(-5, 0-64-(highscoreSize.height)/2-10); | ||
177 | [self addChild:highscoreSprite]; | ||
178 | } | ||
179 | } | 160 | } |
180 | } | 161 | } |
181 | 162 | ||
@@ -184,18 +165,11 @@ | |||
184 | 165 | ||
185 | - (void)buttonTapped | 166 | - (void)buttonTapped |
186 | { | 167 | { |
187 | if (gameMode.unlocked) | 168 | if (delegate != nil) |
188 | { | 169 | { |
189 | if (delegate != nil) | 170 | [delegate didSelectGameMode:self]; |
190 | { | ||
191 | [delegate didSelectGameMode:self]; | ||
192 | } else { | ||
193 | NSLog(@"I don't have a GameModeSelectionDelegate to call for some reason..."); | ||
194 | } | ||
195 | } else { | 171 | } else { |
196 | UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"To unlock this game mode:" message:gameMode.unlockCondition delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:nil]; | 172 | NSLog(@"I don't have a GameModeSelectionDelegate to call for some reason..."); |
197 | [alertView show]; | ||
198 | [alertView release]; | ||
199 | } | 173 | } |
200 | } | 174 | } |
201 | 175 | ||
diff --git a/Classes/GameModeSelectionLayer.m b/Classes/GameModeSelectionLayer.m index e5a83f1..4e51357 100644 --- a/Classes/GameModeSelectionLayer.m +++ b/Classes/GameModeSelectionLayer.m | |||
@@ -45,8 +45,11 @@ | |||
45 | 45 | ||
46 | for (GameModeInfo* info in [[GameModeManager sharedInstance] gameModes]) | 46 | for (GameModeInfo* info in [[GameModeManager sharedInstance] gameModes]) |
47 | { | 47 | { |
48 | GameModeSelection* selection = [GameModeSelection selectionWithGameModeInfo:info]; | 48 | if (info.unlocked) |
49 | [gameModes addObject:selection]; | 49 | { |
50 | GameModeSelection* selection = [GameModeSelection selectionWithGameModeInfo:info]; | ||
51 | [gameModes addObject:selection]; | ||
52 | } | ||
50 | } | 53 | } |
51 | 54 | ||
52 | CCMenu* menu = [CCMenu menuWithItems:nil]; | 55 | CCMenu* menu = [CCMenu menuWithItems:nil]; |
diff --git a/Classes/JumpGameMode.m b/Classes/JumpGameMode.m index b1c5989..3788c97 100644 --- a/Classes/JumpGameMode.m +++ b/Classes/JumpGameMode.m | |||
@@ -45,11 +45,9 @@ static GameModeInfo* info; | |||
45 | location:@"Venice" | 45 | location:@"Venice" |
46 | numOfStars:3 | 46 | numOfStars:3 |
47 | imageFilename:[[NSBundle mainBundle] pathForResource:@"venice" ofType:@"png"] | 47 | imageFilename:[[NSBundle mainBundle] pathForResource:@"venice" ofType:@"png"] |
48 | unlocked:NO | 48 | unlocked:YES |
49 | unlockCondition:@"Get 2000 points in Collect!" | ||
50 | gameClass:[JumpGameMode class] | 49 | gameClass:[JumpGameMode class] |
51 | globalHighscoreKey:@"Jump" | 50 | globalHighscoreKey:@"Jump"]; |
52 | starsToUnlock:2]; | ||
53 | } | 51 | } |
54 | 52 | ||
55 | return info; | 53 | return info; |
diff --git a/Classes/TutorialMode.m b/Classes/TutorialMode.m index 54f4e16..3f37505 100644 --- a/Classes/TutorialMode.m +++ b/Classes/TutorialMode.m | |||
@@ -11,6 +11,7 @@ | |||
11 | #import "GameModeSelectionLayer.h" | 11 | #import "GameModeSelectionLayer.h" |
12 | #import "SimpleAudioEngine.h" | 12 | #import "SimpleAudioEngine.h" |
13 | #import "ClassicGameMode.h" | 13 | #import "ClassicGameMode.h" |
14 | #import "JumpGameMode.h" | ||
14 | 15 | ||
15 | // Item tags: | 16 | // Item tags: |
16 | // 2000 - first dropped item | 17 | // 2000 - first dropped item |
@@ -42,10 +43,8 @@ static GameModeInfo* info; | |||
42 | numOfStars:0 | 43 | numOfStars:0 |
43 | imageFilename:[[NSBundle mainBundle] pathForResource:@"florence" ofType:@"png"] | 44 | imageFilename:[[NSBundle mainBundle] pathForResource:@"florence" ofType:@"png"] |
44 | unlocked:YES | 45 | unlocked:YES |
45 | unlockCondition:nil | ||
46 | gameClass:[TutorialMode class] | 46 | gameClass:[TutorialMode class] |
47 | globalHighscoreKey:nil | 47 | globalHighscoreKey:nil]; |
48 | starsToUnlock:0]; | ||
49 | } | 48 | } |
50 | 49 | ||
51 | return info; | 50 | return info; |
@@ -379,6 +378,7 @@ static GameModeInfo* info; | |||
379 | [self unschedule:@selector(randomlyAddObject:)]; | 378 | [self unschedule:@selector(randomlyAddObject:)]; |
380 | 379 | ||
381 | [[ClassicGameMode info] unlock]; | 380 | [[ClassicGameMode info] unlock]; |
381 | [[JumpGameMode info] unlock]; | ||
382 | 382 | ||
383 | return; | 383 | return; |
384 | } else { | 384 | } else { |