Ejemplo n.º 1
0
        public static SodukoGameInfo GetPersistingSodukoGameInfo()
        {
            SodukoGameInfo sgi   = new SodukoGameInfo();
            var            state = ApplicationData.Current.LocalSettings.Values["PersistingInfo"] as ApplicationDataCompositeValue;

            if (state == null)
            {
                // Hasn't completed a game yet so just return the defaults.
                sgi.Entries.Add(new HighscoreKey(1, Difficulty.Easy), new HighscoreEntry(600));
                sgi.Entries.Add(new HighscoreKey(2, Difficulty.Easy), new HighscoreEntry(660));
                sgi.Entries.Add(new HighscoreKey(3, Difficulty.Easy), new HighscoreEntry(720));

                sgi.Entries.Add(new HighscoreKey(1, Difficulty.Normal), new HighscoreEntry(780));
                sgi.Entries.Add(new HighscoreKey(2, Difficulty.Normal), new HighscoreEntry(840));
                sgi.Entries.Add(new HighscoreKey(3, Difficulty.Normal), new HighscoreEntry(900));

                sgi.Entries.Add(new HighscoreKey(1, Difficulty.Hard), new HighscoreEntry(960));
                sgi.Entries.Add(new HighscoreKey(2, Difficulty.Hard), new HighscoreEntry(1020));
                sgi.Entries.Add(new HighscoreKey(3, Difficulty.Hard), new HighscoreEntry(1080));

                return(sgi);
            }

            foreach (KeyValuePair <string, object> key in state)
            {
                sgi.Entries[new HighscoreKey(key.Key)] = new HighscoreEntry((int)key.Value);
            }

            return(sgi);
        }
Ejemplo n.º 2
0
        public static void SavePersistingSodukoGameInfo(SodukoGameInfo sgi)
        {
            var state = new ApplicationDataCompositeValue();

            foreach (KeyValuePair <HighscoreKey, HighscoreEntry> key in sgi.Entries)
            {
                state[key.Key.ToString()] = key.Value.Seconds;
            }
            ApplicationData.Current.LocalSettings.Values["PersistingInfo"] = state;
        }
Ejemplo n.º 3
0
        public HighscoresPage()
        {
            this.InitializeComponent();
            SodukoGameInfo sgi = new SodukoGameInfo();
            sgi = Serilizer.GetPersistingSodukoGameInfo();

            SetHighscores(sgi.Entries);

            // Set all of the time played data in the UI.
            TimesPlayedData.UpdateUI(TotalTimesPlayedTextBlock, EasyTimesPlayedTextBlock, NormalTimesPlayedTextBlock, HardTimesPlayedTextBlock);

            SetPageData();
        }
Ejemplo n.º 4
0
        private async void InitPuzzle()
        {
            _hasSaved = false;
            try
            {
                _puzzle = new SodukoPuzzle(9, PuzzleCanvas, HintMode.Adjacent);
                _puzzle.OnCompletedGame += OnGameCompleted;
            }
            catch (ArgumentException e)
            {
                // Do nothing...
                string failureMessage = e.Message;
            }
            
            _puzzle.ShowNumberSelector += OnObjectTapped;

            if (_sii.RestoreState)
            {
                if (Serilizer.IsStateSaved())
                {
                    LoadData();
                }
            }
            else
            {
                _difficulty = _sii.DesiredDifficulty;
                if (!_puzzle.InitPuzzle(_difficulty))
                {
                    MessageDialog dlg = new MessageDialog("Couldn't init the puzzle!", "Failure");
                    await dlg.ShowAsync();
                }
            }
            // The highscore is completely different and is always saved.
            _gameInfo = Serilizer.GetPersistingSodukoGameInfo();

            _expMgr.LoadData();
            

            DisplayHighScore();
            SetDifficulty(_difficulty);
            ShowNumberSelector();
            StartTimer(true);
            HintModeComboBox.SelectedItem = AdjacentComboBoxItem;
        }
Ejemplo n.º 5
0
        public static SodukoGameInfo GetPersistingSodukoGameInfo()
        {
            SodukoGameInfo sgi = new SodukoGameInfo();
            var state = ApplicationData.Current.LocalSettings.Values["PersistingInfo"] as ApplicationDataCompositeValue;
            if (state == null)
            {
                // Hasn't completed a game yet so just return the defaults.
                sgi.Entries.Add(new HighscoreKey(1, Difficulty.Easy), new HighscoreEntry(600));
                sgi.Entries.Add(new HighscoreKey(2, Difficulty.Easy), new HighscoreEntry(660));
                sgi.Entries.Add(new HighscoreKey(3, Difficulty.Easy), new HighscoreEntry(720));

                sgi.Entries.Add(new HighscoreKey(1, Difficulty.Normal), new HighscoreEntry(780));
                sgi.Entries.Add(new HighscoreKey(2, Difficulty.Normal), new HighscoreEntry(840));
                sgi.Entries.Add(new HighscoreKey(3, Difficulty.Normal), new HighscoreEntry(900));

                sgi.Entries.Add(new HighscoreKey(1, Difficulty.Hard), new HighscoreEntry(960));
                sgi.Entries.Add(new HighscoreKey(2, Difficulty.Hard), new HighscoreEntry(1020));
                sgi.Entries.Add(new HighscoreKey(3, Difficulty.Hard), new HighscoreEntry(1080));

                return sgi;
            }

            foreach (KeyValuePair<string, object> key in state)
            {
                sgi.Entries[new HighscoreKey(key.Key)] = new HighscoreEntry((int)key.Value);
            }

            return sgi;
        }
Ejemplo n.º 6
0
 public static void SavePersistingSodukoGameInfo(SodukoGameInfo sgi)
 {
     var state = new ApplicationDataCompositeValue();
     foreach (KeyValuePair<HighscoreKey,HighscoreEntry> key in sgi.Entries)
     {
         state[key.Key.ToString()] = key.Value.Seconds;
     }
     ApplicationData.Current.LocalSettings.Values["PersistingInfo"] = state;
 }