Пример #1
0
 private void Update(object sender, EventArgs e)
 {
     BoardController.ResetArea();
     if (!BoardController.Collide())
     {
         BoardController.currentFigure.MoveDown();
     }
     else
     {
         BoardController.Merge();
         BoardController.SliceBoard(label1, label2, label4);
         timer1.Interval = BoardController.Interval;
         BoardController.currentFigure.ResetFigure(rand.Next(0, 7), 0);
         if (BoardController.Collide())
         {
             UserDataController.SaveRecords(playerName);
             BoardController.ClearBoard();
             timer1.Tick -= new EventHandler(Update);
             timer1.Stop();
             MessageBox.Show("Your score: " + BoardController.score);
             Init();
         }
     }
     BoardController.Merge();
     Invalidate();
 }
Пример #2
0
        public void Init()
        {
            UserDataController.ShowScoreRecords(label3);
            this.Text                     = "Tetris: current user - " + playerName;
            BoardController.size          = 25;
            BoardController.score         = 0;
            BoardController.linesRemoved  = 0;
            BoardController.level         = 1;
            BoardController.currentFigure = new Figure(rand.Next(0, 7), 0);
            BoardController.Interval      = 300;
            label1.Text                   = "Score: " + BoardController.score;
            label2.Text                   = "Lines: " + BoardController.linesRemoved;
            label4.Text                   = "Level: " + BoardController.level;

            timer1.Interval = BoardController.Interval;
            timer1.Tick    += new EventHandler(Update);
            timer1.Start();

            Invalidate();
        }
Пример #3
0
 private void OnLoadGameClick(object sender, EventArgs e)
 {
     BoardController.currentFigure.ResetFigure(rand.Next(0, 7), 0);
     BoardController.board = UserDataController.LoadGame(playerName);
 }
Пример #4
0
 private void OnSaveGameClick(object sender, EventArgs e)
 {
     UserDataController.SaveGame(playerName);
     MessageBox.Show("Saved!", "Save Game");
 }