public CreateLevel() { InitializeComponent(); gameData = App.GameManager.GameData; GenerateLevelHashCodes(); }
public static void LoadCustomLevels(GameData gameData) { //don't check if already custom cause their could be changes...just always reload custom using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) { if (isf.FileExists(GAME_DATA_FILENAME)) { using (Stream stream = TitleContainer.OpenStream("levels.dat")) { SharpSerializer serializer = new SharpSerializer(true); gameData.Levels = (List<int[,]>)serializer.Deserialize(stream); gameData.LevelLoadedType = LevelLoadedType.Custom; } } } gameData.Levels = gameData.Levels ?? new List<int[,]>(); }
public static void SaveGameData(GameData gameData) { using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) { if (isf.FileExists(GAME_DATA_FILENAME)) isf.DeleteFile(GAME_DATA_FILENAME); using (var stream = isf.OpenFile(GAME_DATA_FILENAME, System.IO.FileMode.Create)) { SharpSerializer serializer = new SharpSerializer(true); serializer.Serialize(gameData, stream); } using (var stream = isf.OpenFile(LEVEL_DATA_FILENAME, System.IO.FileMode.Create)) { SharpSerializer serializer = new SharpSerializer(true); serializer.Serialize(gameData.Levels, stream); } } }
public static void LoadPreBuiltLevels(GameData gameData) { if (gameData.LevelLoadedType != LevelLoadedType.PreBuilt) //prevent reloading pre-built { using (Stream stream = TitleContainer.OpenStream("levels.dat")) { SharpSerializer serializer = new SharpSerializer(true); gameData.Levels = (List<int[,]>)serializer.Deserialize(stream); gameData.LevelLoadedType = LevelLoadedType.PreBuilt; } } }
public GameManager(GameData gameData) { _gameData = gameData; _gameState = gameData.GameState; SetupAudioTimer(); using (Stream stream = TitleContainer.OpenStream("tile_on.wav")) _soundEffectTileOff = SoundEffect.FromStream(stream); using (Stream stream = TitleContainer.OpenStream("tile_on.wav")) _soundEffectTileOn = SoundEffect.FromStream(stream); TimerCallback tcb = Timer_Tick; _timer = new Timer(tcb, null, Timeout.Infinite, Timeout.Infinite); }