Ejemplo n.º 1
0
        }                                          //画出每个方块

        private void gameOver()
        {
            if (c.bestGrade < c.grade)                                    //判断本次成绩是否刷新纪录
            {
                c.bestGrade    = c.grade;
                bestgrade.Text = c.bestGrade.ToString();
                _2048Screen();
                _2048messageBox mes3 = new _2048messageBox();
                mes3.a = "恭喜!";
                mes3.b = "新的记录!自动为您保存截图。\r\n保存在" + bitfile;
                mes3.ShowDialog();
                c.Reset();
                drow();
                Num_pictureBox.Refresh();
            }
            else
            {
                Game_Over g = new Game_Over();
                g.bg = c.bestGrade;
                g.g  = c.grade;
                DialogResult d = g.ShowDialog();
                switch (d)
                {
                case DialogResult.Retry:
                    c.Reset();
                    drow();
                    Num_pictureBox.Refresh();
                    grade.Text     = c.grade.ToString();
                    bestgrade.Text = c.bestGrade.ToString();
                    break;

                case DialogResult.Abort:
                    _2048Screen();
                    _2048messageBox mes2 = new _2048messageBox();
                    mes2.a = "保存成功";
                    mes2.b = "保存在" + bitfile;
                    mes2.ShowDialog();
                    c.Reset();
                    classSave();
                    drow();
                    Num_pictureBox.Refresh();
                    break;

                case DialogResult.No:
                    c.Reset();
                    this.Close();
                    break;
                }
            }
        }                                                                    //游戏结束时需要的操作
Ejemplo n.º 2
0
 private void Form1_Load(object sender, EventArgs e)
 {
     if (File.Exists("D:\\2048记录")) //监测是否有存档
     {
         ToLoad();
     }
     else                             //如果没有存档,生成新的游戏。
     {
         _2048messageBox mes1 = new _2048messageBox();
         mes1.a             = "提示";
         mes1.b             = "    检测到您是第一次打开,可按F1打开帮助。\r\n    游戏为无限模式,直到GameOver才会终止。";
         mes1.StartPosition = FormStartPosition.CenterScreen;
         mes1.ShowDialog();
         c = new Class1();
         c.Reset();
     }
     mes.a = "提示";                   //生成帮助菜单
     mes.b = "F2:窗口总在最前\r\nF3:解锁/锁定窗口\r\nF4:隐藏任务栏图标\r\nF5:重新开始\r\nF6:截图并保存\r\nShife + ↑↓:调整透明度\r\n↑↓←→:控制方块移动\r\nESC:退出";
     drow();
     Num_pictureBox.Refresh();
 }          //窗口加载前的操作
Ejemplo n.º 3
0
 private void Form1_Load(object sender, EventArgs e)
 {
     if (File.Exists("D:\\2048记录")) //监测是否有存档
     {
         ToLoad();
     }
     else                             //如果没有存档,生成新的游戏。
     {
         _2048messageBox mes1 = new _2048messageBox();
         mes1.a = "提示";
         mes1.b = "    检测到您是第一次打开,可按F1打开帮助。\r\n    游戏为无限模式,直到GameOver才会终止。";
         mes1.StartPosition = FormStartPosition.CenterScreen;
         mes1.ShowDialog();
         c = new Class1();
         c.Reset();
     }
     mes.a = "提示";                   //生成帮助菜单
     mes.b = "F2:窗口总在最前\r\nF3:解锁/锁定窗口\r\nF4:隐藏任务栏图标\r\nF5:重新开始\r\nF6:截图并保存\r\nShife + ↑↓:调整透明度\r\n↑↓←→:控制方块移动\r\nESC:退出";
     drow();
     Num_pictureBox.Refresh();
 }          //窗口加载前的操作
Ejemplo n.º 4
0
        }          //窗口加载前的操作

        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.Up:
                if (e.Modifiers == Keys.Shift)
                {
                    this.Opacity -= 0.1;
                }
                else
                {
                    c.Up();
                    if (c.change)
                    {
                        c.Add();
                    }
                }
                break;

            case Keys.Down:
                if (e.Modifiers == Keys.Shift)
                {
                    this.Opacity += 0.1;
                }
                else
                {
                    c.Down();
                    if (c.change)
                    {
                        c.Add();
                    }
                }
                break;

            case Keys.Left:
                c.Left();
                if (c.change)
                {
                    c.Add();
                }
                break;

            case Keys.Right:
                c.Right();
                if (c.change)
                {
                    c.Add();
                }
                break;

            case Keys.F1:
                mes.ShowDialog();
                break;

            case Keys.F2:
                this.TopMost = !this.TopMost;
                break;

            case Keys.F3:
                if (this.FormBorderStyle == FormBorderStyle.FixedToolWindow)
                {
                    this.FormBorderStyle = FormBorderStyle.None;
                }
                else
                {
                    this.FormBorderStyle = FormBorderStyle.FixedToolWindow;
                }
                break;

            case Keys.F4:
                this.ShowInTaskbar = !this.ShowInTaskbar;
                break;

            case Keys.F5:
                c = new Class1();
                c.Reset();
                Num_pictureBox.Refresh();
                break;

            case Keys.F6:
                _2048Screen();
                _2048messageBox mes2 = new _2048messageBox();
                mes2.a = "保存成功";
                mes2.b = "保存在" + Directory.GetCurrentDirectory() + "\\成绩截图.bmp";
                mes2.ShowDialog();
                break;

            case Keys.Escape:
                this.Close();
                break;
            }
            drow();
            Num_pictureBox.Refresh();
            grade.Text = c.grade.ToString();
            if (c.die)
            {
                gameOver();
            }
        }    //捕捉键盘按下的键,做出相应操作
Ejemplo n.º 5
0
 }          //窗口加载前的操作
 private void Form1_KeyDown(object sender, KeyEventArgs e)
 {
     switch (e.KeyCode)
     {
         case Keys.Up:
             if (e.Modifiers == Keys.Shift)
                 this.Opacity -= 0.1;
             else
             {
                 c.Up();
                 if (c.change)
                     c.Add();
             }
             break;
         case Keys.Down:
             if (e.Modifiers == Keys.Shift)
                 this.Opacity += 0.1;
             else
             {
                 c.Down();
                 if (c.change)
                     c.Add();
             }
             break;
         case Keys.Left:
             c.Left();
             if (c.change)
                 c.Add();
             break;
         case Keys.Right:
             c.Right();
             if (c.change)
                 c.Add();
             break;
         case Keys.F1:
             mes.ShowDialog();
             break;
         case Keys.F2:
             this.TopMost = !this.TopMost;
             break;
         case Keys.F3:
             if (this.FormBorderStyle == FormBorderStyle.FixedToolWindow)
                 this.FormBorderStyle = FormBorderStyle.None;
             else
                 this.FormBorderStyle = FormBorderStyle.FixedToolWindow;
             break;
         case Keys.F4:
             this.ShowInTaskbar = !this.ShowInTaskbar;
             break;
         case Keys.F5:
             c = new Class1();
             c.Reset();
             Num_pictureBox.Refresh();
             break;
         case Keys.F6:
             _2048Screen();
             _2048messageBox mes2 = new _2048messageBox();
             mes2.a = "保存成功";
             mes2.b = "保存在" + Directory.GetCurrentDirectory() + "\\成绩截图.bmp";
             mes2.ShowDialog();
             break;
         case Keys.Escape:
             this.Close();
             break;
     }
     drow();
     Num_pictureBox.Refresh();
     grade.Text = c.grade.ToString();
     if (c.die)
     {
         gameOver();
     }
 }    //捕捉键盘按下的键,做出相应操作
Ejemplo n.º 6
0
        }                                          //画出每个方块

        private void gameOver()
        {
            if (c.bestGrade < c.grade)                                    //判断本次成绩是否刷新纪录
            {
                c.bestGrade = c.grade;
                bestgrade.Text = c.bestGrade.ToString();
                _2048Screen();
                _2048messageBox mes3 = new _2048messageBox();
                mes3.a = "恭喜!";
                mes3.b = "新的记录!自动为您保存截图。\r\n保存在" + bitfile;
                mes3.ShowDialog();
                c.Reset();
                drow();
                Num_pictureBox.Refresh();

            }
            else
            {
                Game_Over g = new Game_Over();
                g.bg = c.bestGrade;
                g.g = c.grade;
                DialogResult d = g.ShowDialog();
                switch (d)
                {
                    case DialogResult.Retry:
                        c.Reset();
                        drow();
                        Num_pictureBox.Refresh();
                        grade.Text = c.grade.ToString();
                        bestgrade.Text = c.bestGrade.ToString();
                        break;
                    case DialogResult.Abort:
                        _2048Screen();
                        _2048messageBox mes2 = new _2048messageBox();
                        mes2.a = "保存成功";
                        mes2.b = "保存在" + bitfile;
                        mes2.ShowDialog();
                        c.Reset();
                        classSave();
                        drow();
                        Num_pictureBox.Refresh();
                        break;
                    case DialogResult.No:
                        c.Reset();
                        this.Close();
                        break;
                }
            }
        }                                      //游戏结束时需要的操作