public static T CreateCopyOf <T>(string prototypeID) where T : class { if (typeof(T).Equals(typeof(GameObject))) { if (_gameObjectPrototypes.ContainsKey(prototypeID)) { BaseEntity entity = _gameObjectPrototypes[prototypeID].Entity; GameObject obj = null; if (entity.GetType().Equals(typeof(BulletEntity))) { BulletEntity bulletEntity = entity as BulletEntity; obj = Factory.Build <GameObject>((GraphicModule)_gameObjectPrototypes[prototypeID].Graphic.Clone(), (BulletEntity)bulletEntity.Clone()); } if (entity.GetType().Equals(typeof(EnemyEntity))) { EnemyEntity bulletEntity = entity as EnemyEntity; obj = Factory.Build <GameObject>((GraphicModule)_gameObjectPrototypes[prototypeID].Graphic.Clone(), (EnemyEntity)bulletEntity.Clone()); } if (entity.GetType().Equals(typeof(PlayerEntity))) { PlayerEntity bulletEntity = entity as PlayerEntity; obj = Factory.Build <GameObject>((GraphicModule)_gameObjectPrototypes[prototypeID].Graphic.Clone(), (PlayerEntity)bulletEntity.Clone()); } return(obj as T); } } if (typeof(T).Equals(typeof(GraphicModule))) { if (_graphicModulePrototypes.ContainsKey(prototypeID)) { GraphicModule graphic = _graphicModulePrototypes[prototypeID]; GameObject obj = null; if (graphic.GetType().Equals(typeof(TexturedGraphicModule))) { return((TexturedGraphicModule)_graphicModulePrototypes[prototypeID].Clone() as T); } if (graphic.GetType().Equals(typeof(GraphicModule))) { return((GraphicModule)_graphicModulePrototypes[prototypeID].Clone() as T); } } } return(null); }