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/GameModeInfo.m | 128 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 Classes/GameModeInfo.m (limited to 'Classes/GameModeInfo.m') 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 @@ +// +// GameModeInfo.m +// Cartographic +// +// Created by Starla Insigna on 11/28/11. +// Copyright (c) 2011 Four Island. All rights reserved. +// + +#import "GameModeInfo.h" +#import "CCNotifications.h" +#import "GameMode.h" +#import "GameModeManager.h" +#import "TestFlight.h" + +@implementation GameModeInfo + +@synthesize name, location, numOfStars, image, unlocked, unlockCondition, globalHighscoreKey, starsToUnlock; + +- (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 +{ + self = [super init]; + + if (nil != self) + { + name = m_name; + location = m_location; + numOfStars = m_numOfStars; + image = [[UIImage alloc] initWithContentsOfFile:m_imageFilename]; + unlockCondition = m_unlockCondition; + globalHighscoreKey = m_globalHighscoreKey; + starsToUnlock = m_starsToUnlock; + + NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; + unlocked = [defaults boolForKey:[NSString stringWithFormat:@"gameModeUnlocked-%@", name]]; + if (!unlocked) + { + unlocked = m_unlocked; + } + + stars = (BOOL*) calloc(numOfStars, sizeof(BOOL)); + for (int i=0; i