/* PLEASE NOTE: * The functions below handle the starting, stopping, pausing, and resuming of the match. * The send score override function is also here. */ /// <summary> /// Starts the match and allows the score buttons to be used /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void startButton_Click(object sender, EventArgs e) { Console.WriteLine("Start Match button pressed."); lastTeam1 = Display.team1; lastTeam2 = Display.team2; GameUtility.beginMatch(); }
/// <summary> /// Parses data received from the arduino and fires off the proper event based on the parsed data /// </summary> /// <param name="data"></param> void parseReceivedData(string data) { switch (int.Parse(data)) //This switch handles all possible events from the arduino and has a failsafe incase we cannot setermine the error { case 0: Console.WriteLine("Command received was a start match command. Starting Match"); setDataText("Match Start."); GameUtility.beginMatch(); break; case 1: Console.WriteLine("Command received was a team 1 band score."); setDataText("Team 1 Rubber Bands"); if (GameUtility.matchState == 1) { if (subtractModeTeam1) { Console.WriteLine("Subtraction mode is activated on team 1! Subtracting instead of adding."); Display.team1Score -= ScoreValues[0]; } else { Display.team1Score += ScoreValues[0]; } } break; case 2: Console.WriteLine("Command received was a team 1 ping pong score."); setDataText("Team 1 Ping Pong"); if (GameUtility.matchState == 1) { if (subtractModeTeam1) { Console.WriteLine("Subtraction mode is activated on team 1! Subtracting instead of adding."); Display.team1Score -= ScoreValues[1]; } else { Display.team1Score += ScoreValues[1]; } } break; case 3: Console.WriteLine("Command received was a team 1 push off score."); setDataText("Team 1 Pushing"); if (GameUtility.matchState == 1) { if (subtractModeTeam1) { Console.WriteLine("Subtraction mode is activated on team 1! Subtracting instead of adding."); Display.team1Score -= ScoreValues[3]; } else { Display.team1Score += ScoreValues[3]; } } break; case 4: Console.WriteLine("Command received was a team 1 disabled score."); setDataText("Team 1 Disable"); if (GameUtility.matchState == 1) { if (subtractModeTeam1) { Console.WriteLine("Subtraction mode is activated on team 1! Subtracting instead of adding."); Display.team1Score -= ScoreValues[2]; } else { Display.team1Score += ScoreValues[2]; } } break; case 5: Console.WriteLine("Command received was a team 2 band score."); setDataText("Team 2 Rubber Bands"); if (GameUtility.matchState == 1) { if (GameUtility.matchState == 1) { if (subtractModeTeam2) { Console.WriteLine("Subtraction mode is activated on team 2! Subtracting instead of adding."); Display.team2Score -= ScoreValues[0]; } else { Display.team2Score += ScoreValues[0]; } } } break; case 6: Console.WriteLine("Command received was a team 2 ping pong score."); setDataText("Team 2 Ping Pong"); if (GameUtility.matchState == 1) { if (subtractModeTeam2) { Console.WriteLine("Subtraction mode is activated on team 2! Subtracting instead of adding."); Display.team2Score -= ScoreValues[1]; } else { Display.team2Score += ScoreValues[1]; } } break; case 7: Console.WriteLine("Command received was a team 2 push off score."); setDataText("Team 2 Pushing"); if (GameUtility.matchState == 1) { if (subtractModeTeam2) { Console.WriteLine("Subtraction mode is activated on team 2! Subtracting instead of adding."); Display.team2Score -= ScoreValues[3]; } else { Display.team2Score += ScoreValues[3]; } } break; case 8: Console.WriteLine("Command received was a team 2 disabled score."); setDataText("Team 2 Disable"); if (GameUtility.matchState == 1) { if (subtractModeTeam2) { Console.WriteLine("Subtraction mode is activated on team 2! Subtracting instead of adding."); Display.team2Score -= ScoreValues[2]; } else { Display.team2Score += ScoreValues[2]; } } break; default: Console.WriteLine("Command was not determinable."); break; } }