From 6e96fb2144718722208d22f892716b55548135e1 Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Wed, 30 Nov 2011 12:57:06 -0500 Subject: 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 --- Classes/GameModeSelectionLayer.m | 45 +++++++--------------------------------- 1 file changed, 8 insertions(+), 37 deletions(-) (limited to 'Classes/GameModeSelectionLayer.m') 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 @@ #import #import "Cart_CollectAppDelegate.h" #import "MainMenuLayer.h" -#import "TutorialMode.h" -#import "ClassicGameMode.h" #import "NMPanelMenu.h" -#import "JumpGameMode.h" #import "ZoomFadeTransition.h" +#import "GameModeInfo.h" +#import "GameModeManager.h" @implementation GameModeSelectionLayer @@ -44,31 +43,12 @@ NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; gameModes = [[NSMutableArray alloc] init]; - GameModeSelection* tutorialSelection = [GameModeSelection selectionWithName:@"Tutorial" location:@"Florence" filename:@"florence" unlocked:YES]; - [gameModes addObject:tutorialSelection]; - - GameModeSelection* collectSelection; - - if ([defaults boolForKey:@"hasDoneTutorial"]) - { - collectSelection = [GameModeSelection selectionWithName:@"Collect" location:@"Paris" filename:@"paris" unlocked:YES]; - } else { - collectSelection = [GameModeSelection selectionWithName:@"Collect" location:@"Paris" filename:@"paris" unlockCondition:@"Beat the tutorial!"]; - } - - [gameModes addObject:collectSelection]; - - GameModeSelection* jumpSelection; - - if ([defaults boolForKey:@"unlockedJumpMode"]) + for (GameModeInfo* info in [[GameModeManager sharedInstance] gameModes]) { - jumpSelection = [GameModeSelection selectionWithName:@"Jump" location:@"Venice" filename:@"venice" unlocked:YES]; - } else { - jumpSelection = [GameModeSelection selectionWithName:@"Jump" location:@"Venice" filename:@"venice" unlockCondition:@"Get 3000 points in Collect!"]; + GameModeSelection* selection = [GameModeSelection selectionWithGameModeInfo:info]; + [gameModes addObject:selection]; } - [gameModes addObject:jumpSelection]; - CCMenu* menu = [CCMenu menuWithItems:nil]; float onePanelWide = 128; float padding = 15; @@ -131,24 +111,15 @@ [[CCDirector sharedDirector] replaceScene:[MainMenuLayer scene]]; } -- (void)didSelectGameMode:(GameModeSelection *)gameMode +- (void)didSelectGameMode:(GameModeSelection *)selection { [scrollView setScrollEnabled:NO]; [pageControl removeFromSuperview]; - CGPoint opp = [scrollView convertPoint:gameMode.position toView:[[CCDirector sharedDirector] openGLView]]; + CGPoint opp = [scrollView convertPoint:selection.position toView:[[CCDirector sharedDirector] openGLView]]; CGPoint endPosition = ccp(0-(opp.x+158), opp.y); - if ([gameMode.name isEqual:@"Tutorial"]) - { - [[CCDirector sharedDirector] replaceScene:[ZoomFadeTransition transitionWithDuration:5.0f scene:[TutorialMode scene] position:endPosition]]; - } else if ([gameMode.name isEqual:@"Collect"]) - { - [[CCDirector sharedDirector] replaceScene:[ZoomFadeTransition transitionWithDuration:5.0f scene:[ClassicGameMode scene] position:endPosition]]; - } else if ([gameMode.name isEqual:@"Jump"]) - { - [[CCDirector sharedDirector] replaceScene:[ZoomFadeTransition transitionWithDuration:5.0f scene:[JumpGameMode scene] position:endPosition]]; - } + [[CCDirector sharedDirector] replaceScene:[ZoomFadeTransition transitionWithDuration:5.0f scene:[selection.gameMode scene] position:endPosition]]; } @end -- cgit 1.4.1