コード例 #1
0
ファイル: GameWindow.xaml.cs プロジェクト: x-j/Soviet-Russia
        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();
            }
        }
コード例 #2
0
 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());
     }
 }
コード例 #3
0
ファイル: GameWindow.xaml.cs プロジェクト: x-j/Soviet-Russia
        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();
        }
コード例 #4
0
ファイル: GameWindow.xaml.cs プロジェクト: x-j/Soviet-Russia
        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();
        }