private void btn2_Click(object sender, RoutedEventArgs e) { Window level2 = new Level2(); this.Close(); level2.Show(); }
async void Level1_Loaded(object sender, RoutedEventArgs e) { var colors = new Tuple <char, Color>[9] { Tuple.Create('R', Colors.Red), Tuple.Create('G', Colors.Green), Tuple.Create('B', Colors.Blue), Tuple.Create('C', Colors.Cyan), Tuple.Create('M', Colors.Magenta), Tuple.Create('Y', Colors.Yellow), Tuple.Create('K', Colors.Black), Tuple.Create('P', Colors.Pink), Tuple.Create('O', Colors.Orange) }; var combo = new Tuple <char, Color> [9]; var rnd = new Random(); for (int i = 0; i <= 8; i++) { combo[i] = colors[rnd.Next(0, 8)]; } for (int i = 0; i <= 8; i++) { EnableButtons(false); for (int j = 0; j <= i; j++) { grid.Background = new SolidColorBrush(Colors.White); await Task.Delay(500); grid.Background = new SolidColorBrush(combo[j].Item2); await Task.Delay(500); } grid.Background = new SolidColorBrush(Colors.White); inputCombo.Clear(); int answerTime = 1500 + 500 * i; count = answerTime; Countdown.Start(); EnableButtons(true); await Task.Delay(answerTime + 500); int inputLength = inputCombo.Count; if (inputLength != i + 1) { i--; continue; } for (int z = 0; z <= inputCombo.Count - 1; z++) { if (inputCombo[z] != combo[z].Item1) { i--; break; } } } await Task.Delay(1000); lblTimer.Content = "Congratulations!"; lblTimer.FontSize = 48; lblTimer.Foreground = Brushes.White; grid.Background = Brushes.Lime; await Task.Delay(5000); Window level2 = new Level2(); this.Close(); level2.Show(); }