private void button27_Click_1(object sender, EventArgs e) { s = ""; char same = ' '; Boolean done = false; char [] pom = temp.ToCharArray(); int m = 0; for (int j = 0; j < crticki.Length; j++) { if (crticki[j] == '_' && done == false) { s += pom[j]; crticki[j] = pom[j]; trueLetters++; scorePlayer -= 10; same = pom[j]; done = true; m = j; } else if (pom[j] == same && m != j) { s += pom[j]; crticki[j] = same; trueLetters++; } else { s += crticki[j]; } label3.Text = s; } if (trueLetters == (int)numericUpDown1.Value) { HighScore score = new HighScore(scorePlayer * timeLeft); timer1.Stop(); score.Show(); this.Hide(); } button27.Enabled = false; }
static void AddHighScore(int playerScore) { Console.WriteLine("Your Name: "); string playerName = Console.ReadLine(); //create a gateway to the database MorganEntities db = new MorganEntities(); //create a new highsccore object HighScore newHighScore = new HighScore(); newHighScore.DateCreated = DateTime.Now; newHighScore.Game = "Hangman"; newHighScore.Name = playerName; newHighScore.Score = playerScore; //add it to the database db.HighScores.Add(newHighScore); //save our changes db.SaveChanges(); }
private void btnHighScore_Click(object sender, EventArgs e) { var form = new HighScore(); form.ShowDialog(); }
private void vpisiBukva(char c) { bool flag = false; for (int i = 0; i < (int)numericUpDown1.Value; i++) { c = Char.ToLower(c); if (c == orginal[i]) { crticki[i] = c; trueLetters++; scorePlayer += 10; flag = true; } if (trueLetters == (int)numericUpDown1.Value) { HighScore score = new HighScore(scorePlayer * timeLeft); timer1.Stop(); score.Show(); this.Hide(); break; } } if (!flag) { falseLetters++; } if (falseLetters == 1) { pictureBox2.Visible = false; pictureBox3.Visible = true; } else if (falseLetters == 2) { pictureBox3.Visible = false; pictureBox4.Visible = true; } else if (falseLetters == 3) { pictureBox4.Visible = false; pictureBox5.Visible = true; } else if (falseLetters == 4) { pictureBox5.Visible = false; pictureBox6.Visible = true; } else if (falseLetters == 5) { pictureBox6.Visible = false; pictureBox7.Visible = true; } else if (falseLetters == 6) { pictureBox7.Visible = false; pictureBox8.Visible = true; this.Hide(); GameOver gm = new GameOver(temp); gm.Show(); timer1.Stop(); timer1.Dispose(); } s = ""; for (int j = 0; j < crticki.Length; j++) { s += crticki[j]; label3.Text = s; } }