/// <summary> /// Creates a new predefined level /// </summary> /// <param name="number">The number of the level (1, 2 or 3)</param> /// <param name="pAudioPlayer">The AudioPlayer intance that playes all the sound /// effects</param> /// <param name="pContent">Used ContentManager</param> /// <param name="pSpriteBatch">Used SpriteBatch</param> public Level(int number, AudioPlayer pAudioPlayer, ContentManager pContent) { content = pContent; audioPlayer = pAudioPlayer; world = new World(new Vector2(0.0f, 5.0f), true); world.ContactListener = this; rotationData = new RotationData(); bike = new Bike(bikeSpeed, rotationData, world, camPos, content); provider.NumberDecimalSeparator = "."; try { using (Stream stream = TitleContainer.OpenStream("Content/Levels/Level_" + number + ".lvl")) { LoadLevel(stream); } } catch (FileNotFoundException) { } }
/// <summary> /// Creates a new user defined custom level /// </summary> /// <param name="fileName">The name of the file that defines the level</param> /// <param name="pAudioPlayer">The AudioPlayer intance that playes all the sound /// effects</param> /// <param name="pContent">Used ContentManager</param> public Level(String fileName, AudioPlayer pAudioPlayer, ContentManager pContent) { content = pContent; audioPlayer = pAudioPlayer; world = new World(new Vector2(0.0f, 5.0f), true); world.ContactListener = this; rotationData = new RotationData(); bike = new Bike(bikeSpeed, rotationData, world, camPos, content); provider.NumberDecimalSeparator = "."; IsolatedStorageFile savegameStorage = IsolatedStorageFile.GetUserStoreForApplication(); // open isolated storage, and read the savefile. if (savegameStorage.FileExists(fileName)) { using (IsolatedStorageFileStream fs = savegameStorage.OpenFile(fileName, System.IO.FileMode.Open)) { LoadLevel(fs); } } }
/// <summary> /// Create a new empty level with no components in it /// </summary> /// <param name="pAudioPlayer">The AudioPlayer intance that playes all the sound /// effects</param> /// <param name="pContent">Used ContentManager</param> public Level(AudioPlayer pAudioPlayer, ContentManager pContent) { content = pContent; audioPlayer = pAudioPlayer; world = new World(new Vector2(0.0f, 5.0f), true); world.ContactListener = this; rotationData = new RotationData(); bike = new Bike(bikeSpeed, rotationData, world, camPos, content); }