コード例 #1
0
        public async void OnGameCompleted(object obj, EventArgs args)
        {
            _wasGameBeaten = true;
            Serilizer.ClearSaveGameCache();

            string       message          = null;
            string       levelUpMessage   = null;
            int          numberOfLevelups = 0;
            EventHandler onLevelUp        = (object o, EventArgs e) =>
            {
                numberOfLevelups++;
            };

            // Sub our level up event just in case we did end level up.
            _expMgr.OnLevelUp += onLevelUp;
            _expMgr.PuzzleCompleted(_difficulty, (int)_secondsTicking);

            if (numberOfLevelups != 0)
            {
                levelUpMessage = Environment.NewLine + "You leveled up " + numberOfLevelups.ToString();
                if (numberOfLevelups > 1)
                {
                    levelUpMessage += " times";
                }
                else
                {
                    levelUpMessage += " time";
                }
            }

            if (_gameInfo.AddIfHighScore(_difficulty, (int)_secondsTicking))
            {
                message = "New Highscore";
            }
            string finalMessage = "You win!";

            if (message != null)
            {
                finalMessage = finalMessage + Environment.NewLine + message;
            }
            SaveApplicationData();

            // Add to the total number of times the game was beaten.
            TimesPlayedData.OnGameBeaten(_difficulty);

            MessageDialog dlg = new MessageDialog(finalMessage, "Congragulations!");
            await dlg.ShowAsync();

            Frame.Navigate(typeof(MainPage));
        }
コード例 #2
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();
        }
コード例 #3
0
        public MainPage()
        {
            this.InitializeComponent();
            _expMgr.LoadData();
            Settings settings = new Settings();

            Settings.Restore();
            SetFontColor();
            bool continueGameEnabled = Serilizer.IsStateSaved();

            ContinueButton.Visibility = continueGameEnabled ? Visibility.Visible : Visibility.Collapsed;
            if (continueGameEnabled)
            {
                if (!SetContinueButtonText())
                {
                    // Something has gone terribly wrong.
                }
            }

            TimesPlayedData.LoadData();
            TimesPlayedData.UpdateUI(TimesPlayedTextBlock);

            _expMgr.UpdateControls(LevelProgress, CurrentLevel, CurrentExp);
        }