예제 #1
1
        public CreateLevel()
        {
            InitializeComponent();
            gameData = App.GameManager.GameData;

            GenerateLevelHashCodes();
        }
예제 #2
1
 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[,]>();
 }
예제 #3
1
        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);
                }
            }
        }
예제 #4
1
 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;
         }
     }
 }
예제 #5
0
        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);
        }