static void Main() { Sounds sound = new Sounds(); string directoryName = Path.GetDirectoryName(Directory.GetCurrentDirectory()); directoryName = Path.GetDirectoryName(directoryName); directoryName = Path.GetDirectoryName(directoryName); directoryName = directoryName + "\\set_sounds\\sound_options.txt"; string text = System.IO.File.ReadAllText(directoryName); if (text == "true") { sound.PlayMusicIntro(true); } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainMenu()); }
public void PlayWrongTest() { Sounds sound = new Sounds(); Assert.IsTrue(sound.PlayWrong(true)); Assert.IsFalse(sound.PlayWrong(false)); }
public void PlayRightTest() { Sounds sound = new Sounds(); Assert.IsTrue(sound.PlayRight(true)); Assert.IsFalse(sound.PlayRight(false)); }
public void PlayMusicTest() { Sounds sound = new Sounds(); Assert.IsTrue(sound.PlayMusic(true)); Assert.IsFalse(sound.PlayMusic(false)); }
/// <summary> /// Close the option form and save changes /// </summary> /// <param name="sender">The parameter is not used.</param> /// <param name="e">The parameter is not used.</param> private void SaveOptionsLabel_Click(object sender, EventArgs e) { // save settings MessageBox.Show("Your settings were saved!"); // if the mute checkbox is selected and ok is pressed, mute the intro music and all other sounds. Sounds sound = new Sounds(); string directoryName = Path.GetDirectoryName(Directory.GetCurrentDirectory()); directoryName = Path.GetDirectoryName(directoryName); directoryName = Path.GetDirectoryName(directoryName); directoryName = directoryName + "\\set_sounds\\sound_options.txt"; if (muteCheckBox.Checked == true) { sound.PlayMusicIntro(false); // write to txt file to save settings. using (System.IO.StreamWriter file = new System.IO.StreamWriter(directoryName)) { file.Write("false"); } } else { sound.PlayMusicIntro(true); using (System.IO.StreamWriter file = new System.IO.StreamWriter(directoryName)) { file.Write("true"); } } // close otions form this.Close(); }
/// <summary> /// Event handler for user click on startLabel. /// </summary> /// <param name="sender">The parameter is not used.</param> /// <param name="e">The parameter is not used.</param> private void StartLabelClick(object sender, EventArgs e) { // Logic for starting game. int firstOption = -1; if (singleColorModeRadioButton.Checked) firstOption = 0; if (beginnerModeRadioButton.Checked) firstOption = 1; if (tutorialModeRadioButton.Checked) firstOption = 2; int secondOption; bool result = Int32.TryParse(numberOfSetsTextBox.Text, out secondOption); if (!result) { MessageBox.Show("You must specify how many SETs for the round."); return; } Sounds sound = new Sounds(); string directoryName = Path.GetDirectoryName(Directory.GetCurrentDirectory()); directoryName = Path.GetDirectoryName(directoryName); directoryName = Path.GetDirectoryName(directoryName); directoryName = directoryName + "\\set_sounds\\sound_options.txt"; string text = System.IO.File.ReadAllText(directoryName); if (text == "true") { sound.PlayMusicIntro(false); sound.PlayMusic(true); } int[] options = { firstOption, secondOption}; this.Hide(); GameBoard gameBoard = new GameBoard(options); gameBoard.ShowDialog(); }
/// <summary> /// Event handler for user clicking the button labeled set. /// </summary> /// <param name="sender">The parameter is not used.</param> /// <param name="e">The parameter is not used.</param> private void SetButtonClick(object sender, EventArgs e) { Sounds sound = new Sounds(); string directoryName = Path.GetDirectoryName(Directory.GetCurrentDirectory()); directoryName = Path.GetDirectoryName(directoryName); directoryName = Path.GetDirectoryName(directoryName); directoryName = directoryName + "\\set_sounds\\sound_options.txt"; string text = System.IO.File.ReadAllText(directoryName); // Set Logic if (cardsSelected == 3) { int set = game.ConfirmSet(currentSet); if (currentSet.Count() == 3 && set > 0) { if (text == "true") { sound.PlayRight(true); } if (set == 2) { if ("Yes" == MessageBox.Show("Do you want to see the sets you made?", "Congratulations?", MessageBoxButtons.YesNo).ToString()) { var card = game.getUserSets(); string toDisplay = ""; string line = ""; for(int i = 0; i < card.Count; i ++) { line = "Set" + i + ": "; for(int j = 0; j < card[i].Count; j++) { line += card[i][j].Number + "_" + card[i][j].Color + "_" + card[i][j].Shade + "_" + card[i][j].Shape + ", "; } toDisplay = string.Join(Environment.NewLine, line); } MessageBox.Show(toDisplay); } this.Close(); } else { MessageBox.Show("You have a valid set, YAY!"); updateCardsOnBoard(); clearSelectedCards(); } } else { if (text == "true") { sound.PlayWrong(true); } MessageBox.Show("Your SET is NOT valid!"); } // Fix this if you use multiple players player1Score.Text = game.getUserScore().ToString(); } else { MessageBox.Show("You need to have 3 cards selected to declare a SET"); } }