コード例 #1
0
        private void PlayerHP_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            if (this.PlayerHp.Value < this.PlayerHp.Maximum / 4) //Damit immer nach 25% geprüft wird
            {
                this.PlayerHp.Foreground = Brushes.Red;
            }
            else if (this.PlayerHp.Value < this.PlayerHp.Maximum / 2)
            {
                this.PlayerHp.Foreground = Brushes.Orange;
            }
            else
            {
                this.PlayerHp.Foreground = Brushes.Green;
            }

            if (this.PlayerHp.Value == this.PlayerHp.SmoothValue &&
                this.PlayerHp.SmoothValue != this.PlayerHp.Maximum && this.PlayerHp.SmoothValue != 0)
            {
                this.EnableButtons();
            }

            if (Math.Abs(this.PlayerHp.SmoothValue - this.PlayerHp.Value) > 0) //genauer als ==
            {
                if ((string)this.PlayerHp.Tag != @"ShouldBlink")
                {
                    this.PlayerHp.Tag = "ShouldBlink";
                }
            }
            else
            {
                this.PlayerHp.Tag = "ShouldNotBlink";
            }

            if (this.PlayerHp.Value == 0 && this.PlayerHp.SmoothValue == 0)
            {
                bool waitforChoice = true;
                this.battleMusic.Stop();
                MessageBox.Show("You died!");
                while (waitforChoice)
                {
                    MessageBoxResult restartGame = MessageBox.Show("Do you want to restart the Game?", "Restart Pokemon PoGl", MessageBoxButton.YesNo);
                    if (restartGame == MessageBoxResult.Yes)
                    {
                        waitforChoice = false;
                        CharSelectView startWindow = new CharSelectView();
                        startWindow.Show();
                        this.Close();
                    }
                    else
                    {
                        MessageBoxResult exitGame = MessageBox.Show("Are you sure you want to exit?", "Exit the Pokemon PoGl", MessageBoxButton.YesNo);
                        if (exitGame == MessageBoxResult.Yes)
                        {
                            waitforChoice = false;
                            Environment.Exit(0);
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: App.xaml.cs プロジェクト: daerup/PkmnProject
        private void App_OnStartUp(object sender, StartupEventArgs e)
        {
            CharSelectView charSelectView = new CharSelectView()
            {
                DataContext = new CharSelectViewModel()
            };

            charSelectView.Show();
        }
コード例 #3
0
 private void CheckIfWon()
 {
     if (this.allPokemon.Count == 0)
     {
         if (!this.Groudon.Beaten)
         {
             this.allPokemon.Add(this.Groudon);
         }
         else
         {
             bool waitforChoice = true;
             JsonSerialization.WriteToJsonFile(@"../../res/json/unlocked.json", true);
             this.battleMusic.Stop();
             MessageBox.Show("You have unlocked Groudon as playable character!", "You won!");
             while (waitforChoice)
             {
                 MessageBoxResult restartGame = MessageBox.Show("Do you want to restart the Game?", "Restart Pokemon PoGl", MessageBoxButton.YesNo);
                 if (restartGame == MessageBoxResult.Yes)
                 {
                     waitforChoice = false;
                     CharSelectView startWindow = new CharSelectView();
                     GameSettings.Won = true;
                     this.Close();
                     startWindow.Show();
                 }
                 else
                 {
                     MessageBoxResult exitGame = MessageBox.Show("Are you sure you want to exit?", "Exit the Pokemon PoGl", MessageBoxButton.YesNo);
                     if (exitGame == MessageBoxResult.Yes)
                     {
                         waitforChoice = false;
                         Environment.Exit(0);
                     }
                 }
             }
         }
     }
 }