private void click_game_event(object sender, RoutedEventArgs e) { number_dots_clicked += 1; set_textblock_game_data(thisGame.size, number_dots_clicked, thisGame.user_game_score_euc, thisGame.user_game_score_man, thisGame.user_game_score_euc_combo, thisGame.user_game_score_man_combo, thisGame.show_button_duration); if (number_dots_clicked < thisGame.number_dots) { custom_button new_button = sender as custom_button; button_array[new_button.x, new_button.y].Template = Control_Template.Template; button_array[new_button.x, new_button.y].IsEnabled = false; cooridinate new_coord = new cooridinate(); new_coord.x = new_button.x; new_coord.y = new_button.y; selections.Add(new_coord); Console.WriteLine("Click: " + number_dots_clicked + " of " + thisGame.number_dots); } else { custom_button new_button = sender as custom_button; button_array[new_button.x, new_button.y].Template = Control_Template.Template; cooridinate new_coord = new cooridinate(); new_coord.x = new_button.x; new_coord.y = new_button.y; selections.Add(new_coord); List <cooridinate> answers2 = new List <cooridinate>(answers); List <cooridinate> answers3 = new List <cooridinate>(answers); List <cooridinate> answers4 = new List <cooridinate>(answers); List <cooridinate> selections2 = new List <cooridinate>(selections); List <cooridinate> selections3 = new List <cooridinate>(selections); List <cooridinate> selections4 = new List <cooridinate>(selections); thisGame.user_game_score_man = rowbasedMinManhattanDistance(answers2, selections2); thisGame.user_game_score_euc = rowbasedMinEuclideanDistance(answers, selections); thisGame.user_game_score_man_combo = combinationMinManhattanDistance(answers3, selections3); thisGame.user_game_score_euc_combo = combinationMinEuclideanDistance(answers4, selections4); thisGame.game_end = DateTime.Now; thisGame.game_play_duration = thisGame.game_start - thisGame.game_end; button_next_game.Visibility = Visibility.Visible; // games over go to the next game number_dots_clicked = 0; foreach (Button b in button_array) { b.IsEnabled = false; } set_game_data(); } }
private custom_button[,] get_button_array(int size) { //builds the complete button grid, but hides each button //Console.WriteLine("Starting set button grid"); custom_button[,] buttonArray = new custom_button[size, size]; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { custom_button button1 = new custom_button(); button1.Height = 45; button1.Width = 45; button1.Background = Brushes.CornflowerBlue; button1.Content = " "; button1.Name = "button" + i.ToString() + "button" + j.ToString(); button1.x = i; button1.y = j; button1.Visibility = Visibility.Hidden; buttonArray[i, j] = button1; } } return(buttonArray); }