private void ScoreBTextBox_TextChanging(TextBox sender, TextBoxTextChangingEventArgs args)
        {
            try {
                ScoreATextBox.TextChanging -= ScoreATextBox_TextChanging;

                if (ScoreBTextBox.Text.Length != 0)
                {
                    if (ScoreBTextBox.Text == "-")
                    {
                        ScoreA             = 0;
                        ScoreATextBox.Text = "0";
                        ScoreBTextBox.Text.TrimStart('-');
                        string NegativeScore = ScoreBTextBox.Text;
                        NegativeScore += "0";
                        ScoreB         = Convert.ToInt32(NegativeScore);
                        ScoreB         = int.Parse(NegativeScore);
                        ScoreB         = -1 * ScoreA;
                    }
                    else
                    {
                        ScoreA             = 0;
                        ScoreATextBox.Text = "0";
                        ScoreB             = Convert.ToInt32(ScoreBTextBox.Text);
                        ScoreB             = int.Parse(ScoreBTextBox.Text);
                        if ((ScoreB % 5) == 0 && ScoreB != 0)
                        {
                            if ((ScoreB > 100 && ScoreB <= 200) || (ScoreB >= -200 && ScoreB < -100))
                            {
                                ScoreA             = 200 - ScoreB;
                                ScoreATextBox.Text = ScoreA.ToString();
                            }
                            else if ((ScoreB > 200 && ScoreB <= 300) || (ScoreB >= -300 && ScoreB < -200))
                            {
                                ScoreA             = 300 - ScoreB;
                                ScoreATextBox.Text = ScoreA.ToString();
                            }
                            else if (ScoreB == 400)
                            {
                                ScoreA             = 0;
                                ScoreATextBox.Text = ScoreA.ToString();
                            }
                            else if (((ScoreB > 0) && (ScoreB <= 100)))
                            {
                                ScoreA             = 100 - ScoreB;
                                ScoreBTextBox.Text = ScoreB.ToString();
                            }
                            else if ((ScoreB >= -100) && (ScoreB < 0))
                            {
                                ScoreA             = -1 * ScoreB;
                                ScoreATextBox.Text = ScoreA.ToString();
                            }
                        }
                    }
                }
            }
            catch
            {
                ScoreBTextBox.Text = String.Empty;
            }
        }
        private void EnterScoreButton_Click(object sender, RoutedEventArgs e)
        {
            if (!(String.IsNullOrEmpty(ScoreATextBox.Text) || String.IsNullOrEmpty(ScoreBTextBox.Text)))
            {
                ScoreA = Convert.ToInt32(ScoreATextBox.Text);
                ScoreA = int.Parse(ScoreATextBox.Text);
                ScoreB = Convert.ToInt32(ScoreBTextBox.Text);
                ScoreB = int.Parse(ScoreBTextBox.Text);
                if (((ScoreA + ScoreB) == 0 || (ScoreA + ScoreB) == 100 || (ScoreA + ScoreB) == 200 || (ScoreA + ScoreB) == 300 || (ScoreA + ScoreB) == 400) && (ScoreA % 5 == 0) && (ScoreB % 5 == 0))
                {
                    TextBlock _newScoreA = new TextBlock();
                    _newScoreA.Text                = ScoreA.ToString();
                    _newScoreA.FontSize            = 20;
                    _newScoreA.HorizontalAlignment = HorizontalAlignment.Center;
                    ScoreAStackPanel.Children.Add(_newScoreA);
                    TextBlock _newScoreB = new TextBlock();
                    _newScoreB.Text                = ScoreB.ToString();
                    _newScoreB.FontSize            = 20;
                    _newScoreB.HorizontalAlignment = HorizontalAlignment.Center;
                    ScoreBStackPanel.Children.Add(_newScoreB);

                    TotalScoreA += ScoreA;
                    TotalScoreB += ScoreB;
                    TotalAScoreTextBlock.Text = TotalScoreA.ToString();
                    TotalBScoreTextBlock.Text = TotalScoreB.ToString();
                    ScoreATextBox.Text        = String.Empty;
                    ScoreBTextBox.Text        = String.Empty;

                    Rounds++;
                    TextBlock _rounds = new TextBlock();
                    _rounds.Text = Rounds.ToString();
                    _rounds.HorizontalAlignment = HorizontalAlignment.Center;
                    _rounds.FontSize            = 20;
                    RoundsStackPanel.Children.Add(_rounds);
                }
                else
                {
                    ScoreATextBox.Text = String.Empty;
                    ScoreBTextBox.Text = String.Empty;
                }
            }

            ScoreATextBox.TextChanging += ScoreATextBox_TextChanging;
            ScoreBTextBox.TextChanging += ScoreBTextBox_TextChanging;

            //Sqlite part
            game.A.Score[Rounds] = ScoreA;
            game.B.Score[Rounds] = ScoreB;
            game.rounds          = Rounds;
            game.A.calcTotalScore();
            game.B.calcTotalScore();
            conn.Commit();
        }
Exemple #3
0
 private void GiveNote()
 {
     CheckNote = true;
     if (current_Button == ButtonType.ButtonR)
     {
         CL.setMusic(CL.clip_Rnote);
         CL.winAnim.gameObject.GetComponent <Animator>().Play("NoteR");
         ScoreR++;
         txtR.text  = ScoreR.ToString();
         note_StayR = false;
         Destroy(note_prefab);
     }
     else if (current_Button == ButtonType.ButtonB)
     {
         CL.setMusic(CL.clip_Bnote);
         CL.winAnim.gameObject.GetComponent <Animator>().Play("NoteB");
         ScoreB++;
         txtB.text  = ScoreB.ToString();
         note_StayB = false;
         Destroy(note_prefab);
     }
     else if (current_Button == ButtonType.ButtonG)
     {
         CL.setMusic(CL.clip_Gnote);
         CL.winAnim.gameObject.GetComponent <Animator>().Play("NoteG");
         ScoreG++;
         txtG.text  = ScoreG.ToString();
         note_StayG = false;
         Destroy(note_prefab);
     }
     else if (current_Button == ButtonType.ButtonP)
     {
         CL.setMusic(CL.clip_Pnote);
         CL.winAnim.gameObject.GetComponent <Animator>().Play("NoteP");
         ScoreP++;
         txtP.text  = ScoreP.ToString();
         note_StayP = false;
         Destroy(note_prefab);
     }
 }