Exemplo n.º 1
0
        public static void TimeStep(object sender, EventArgs e)
        {
            if (GamePaused == true || GameLost == true)
            {
                return;
            }
            if (ActiveObject == null)
            {
                if (NextActiveObject == null)
                {
                    ActiveObject     = CreateObject();
                    NextActiveObject = CreateObject();
                }
                else
                {
                    ActiveObject     = NextActiveObject;
                    NextActiveObject = CreateObject();
                }
                DrawPreview();
            }
            else
            {
                bool isGameOver;
                if (ActiveObject.MoveDown(out isGameOver) == false)
                {
                    if (isGameOver)
                    {
                        Timer.Stop();
                        GameLost              = true;
                        mw.MESSAGE.Text       = "GAME OVER";
                        mw.MESSAGE.FontSize   = 35;
                        mw.MESSAGE.Foreground = Brushes.Red;
                        mw.MESSAGE.Visibility = Visibility.Visible;

                        //Highscores w = new Highscores();
                        //w.Show();
                        return;
                    }
                    ActiveObject.Merge();
                    ActiveObject = null;
                    int n_rows_deleted = CleanFullRows();
                    if (n_rows_deleted > 0)
                    {
                        Points         += n_rows_deleted * Level * levelPoints[n_rows_deleted - 1];
                        Destroyed_Rows += n_rows_deleted;
                    }
                }
            }

            Visualize();
        }