Пример #1
0
        private async void GameOver(string message)
        {
            var gameOverDialog = new MessageDialog(message + "\nYou got score : " + score);

            gameOverDialog.Commands.Add(new UICommand {
                Label = "New Game?", Id = 0
            });
            gameOverDialog.Commands.Add(new UICommand {
                Label = "Exit", Id = 1
            });
            var f = await gameOverDialog.ShowAsync();

            if ((int)f.Id == 0)
            {
                testing1        = null;
                bagging         = null;
                testing1        = new TetrisGridArray();
                bagging         = new TetrisBag();
                shapeCreate     = new TetrisShapes(bagging.GetCurrent(), testing1, false);
                waitingGameOver = false;
                score           = 0;
                rows            = 0;
                level           = 1;
            }
            else if ((int)f.Id == 1)
            {
                redrawTimer.Dispose();
                gravityTimer2.Dispose();
                CoreApplication.Exit();
            }
        }
Пример #2
0
        public MainPage()
        {
            this.InitializeComponent();
            testing1 = new TetrisGridArray();
            bagging  = new TetrisBag();

            shapeCreate = new TetrisShapes(bagging.GetCurrent(), testing1, false);
            testing1.DrawArray(Gamedraw);
            var autoEvent = new AutoResetEvent(false);

            gravityTimer2 = new Timer(gravityCallBack, autoEvent, 1000, 500);
            redrawTimer   = new Timer(redrawGrid, autoEvent, 150, 100);

            Window.Current.CoreWindow.KeyDown += CoreWindow_KeyDown;
        }