// // FallingObjectFactory.m // Cartographic // // Created by Starla Insigna on 9/10/11. // Copyright (c) 2011 Four Island. All rights reserved. // #import "FallingObjectFactory.h" @interface FallingObjectRecipe : NSObject { NSString* spriteFilename; int weight; } @property (readonly) NSString* spriteFilename; @property (readonly) int weight; - (id)initWithSpriteFilename:(NSString*)filename weight:(int)m_weight; @end @implementation FallingObjectRecipe @synthesize spriteFilename, weight; - (id)initWithSpriteFilename:(NSString*)filename weight:(int)m_weight { self = [super init]; if (nil != self) { spriteFilename = [filename retain]; weight = m_weight; } return self; } @end @implementation FallingObjectFactory - (id)init { self = [super init]; if (nil != self) { recipes = [[NSMutableDictionary alloc] init]; } return self; } - (void)createRecipeWithIdentifier:(int)identifier spriteFilename:(NSString*)filename weight:(int)weight { FallingObjectRecipe* recipe = [[FallingObjectRecipe alloc] initWithSpriteFilename:filename weight:weight]; [recipes setObject:recipe forKey:[NSNumber numberWithInt:identifier]]; [recipe release]; } - (FallingObject*)buildFallingObjectWithRecipeIdentifier:(int)identifier { FallingObjectRecipe* recipe = [recipes objectForKey:[NSNumber numberWithInt:identifier]]; FallingObject* object = [[FallingObject alloc] initWithSpriteFilename:recipe.spriteFilename weight:recipe.weight objectType:identifier]; return [object autorelease]; } @end