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/GameModeSelectionLayer.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/GameModeSelectionLayer.m')
-rw-r--r-- | Classes/GameModeSelectionLayer.m | 45 |
1 files changed, 8 insertions, 37 deletions
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 |