private void MoveDown() { if (!CheckCollisionDown()) { foreach (var sq in currentTetro.squares) { int i = Grid.GetRow(sq); int j = Grid.GetColumn(sq); SetLocation(sq, i + 1, j); } gameGrid.InvalidateArrange(); currentTetro.bottomBound = currentTetro.squares.Max(r => Grid.GetRow(r)); } else { timer.Stop(); foreach (var sq in currentTetro.squares) { squares.Add(sq); } Random rand = new Random(); Tetromino t = new Tetromino(gameGrid, rand.Next(0, ROW_COUNT - 4)); currentTetro = t; ClearFilledRows(); timer.Start(); } }
private void shapesButton_Click(object sender, RoutedEventArgs e) { if (ssw == null) { MessageBox.Show("????"); } this.RemoveVisualChild(ssw); ssw = null; if (Tetromino.POSSIBLE_TETROMINOS.Count == 4) { this.RemoveVisualChild(ssw); ssw = new ShapeSelectorWindow(Tetromino.POSSIBLE_TETROMINOS); } else { ssw = new ShapeSelectorWindow(); } this.RemoveVisualChild(ssw); ssw.ShowDialog(); //here be dragons if (ssw.ShapesMadeCount == 4) { Startable = true; Tetromino.GenerateShapes(ssw.ExportSelection()); } }
private void MenuItem_Click(object sender, RoutedEventArgs e) { timer.Stop(); ShapeSelectorWindow ssw = new ShapeSelectorWindow(Tetromino.POSSIBLE_TETROMINOS); ssw.ShowDialog(); ssw.Close(); Tetromino.GenerateShapes(ssw.ExportSelection()); timer.Start(); }
public GameWindow() { InitializeComponent(); this.Closed += GameWindow_Closed; squares = new List <Rectangle>(); timer = new DispatcherTimer(); timer.Interval = new TimeSpan(0, 0, 0, 0, 500); timer.Tick += Timer_Tick; Random rand = new Random(); currentTetro = new Tetromino(gameGrid, rand.Next(0, COLUMN_COUNT - 1)); timer.Start(); }