Beispiel #1
0
 private void btnStart_Click(object sender, RoutedEventArgs e)
 {
     if (iconStart.Kind == PackIconKind.Play)
     {
         iconStart.Kind     = PackIconKind.Pause;
         btnReset.IsEnabled = false;
         Status.isEnd       = false;
         if (Setting.isTimer)
         {
             if (timerRun.Check())
             {
                 timerRun.Start();
                 return;
             }
             else
             {
                 MainWindow.OperateMessage(Message.TimeInvalid);
             }
         }
         else if (Setting.isDelayer)
         {
             delayRun.Start();
         }
         else
         {
             hourMeterRun.Start();
         }
         Status.isStart = true;
     }
     else
     {
         if (Status.isNowOvertime)
         {
             overtimeRun.Close();
         }
         else if (!Status.isStart)
         {
             timerRun.Close();
         }
         else
         {
             hourMeterRun.Close();
         }
         iconStart.Kind     = PackIconKind.Play;
         btnReset.IsEnabled = true;
         Status.isStart     = false;
         if (Status.isEnd)
         {
             sp.Stop();
         }
     }
 }
Beispiel #2
0
 private void pause_Click(object sender, EventArgs e)
 {
     if (!eluosIsRun)
     {
         return;
     }
     if (TimerRun.Enabled)
     {
         TimerRun.Stop();
         pause.Text = "|>";
     }
     else
     {
         TimerRun.Start();
         pause.Text = "||";
     }
 }
Beispiel #3
0
        private void start_Click(object sender, EventArgs e)
        {
            //初始化背景、数组
            GameLabel.Text      = "Come On!";
            GameLabel.ForeColor = Color.Lime;
            for (int i = 0; i < W * H; i++)
            {
                PicBox[i].BackColor   = Color.Black;
                PicBox[i].BorderStyle = BorderStyle.None;
            }
            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    GameArry[i, j] = 0;
                }
            }
            for (int i = 0; i < 4 * 4; i++)
            {
                NextPic[i].BackColor   = Color.Black;
                NextPic[i].BorderStyle = BorderStyle.None;
            }

            //speed
            int speed = 100 * (SpeedComBox.SelectedIndex + 1);

            TimerRun.Interval = speed;
            TimerRun.Start();

            //score
            Score           = 0;
            ScoreLabel.Text = Score.ToString();

            //禁用comboBox1
            SpeedComBox.Enabled = false;

            //下一个方块清空,重新创造,并且运行
            NextTetromino = 0;
            Create();
            TimerRun.Enabled = true;
            eluosIsRun       = true;
        }