diff options
author | Starla Insigna <starla4444@gmail.com> | 2011-11-30 12:57:06 -0500 |
---|---|---|
committer | Starla Insigna <starla4444@gmail.com> | 2011-11-30 12:57:06 -0500 |
commit | 6e96fb2144718722208d22f892716b55548135e1 (patch) | |
tree | 4dd550de787dd370a13039c03969442f54a3a856 /Classes/GameOverScene.m | |
parent | fd58a0cde1bb5473e39e6cb82d28113da84b9ae0 (diff) | |
download | cartcollect-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
Diffstat (limited to 'Classes/GameOverScene.m')
-rwxr-xr-x | Classes/GameOverScene.m | 31 |
1 files changed, 8 insertions, 23 deletions
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 | } |