private void NextBut_Click(object sender, EventArgs e) { try { Thisguan++; path = "..\\..\\files\\map\\" + Thisguan.ToString() + ".map"; OpenMap(s, path); time = 0; timer1.Start(); Form1.count = 0; } catch (FileNotFoundException m) { MessageBox.Show("不存在此关卡", "警告"); Thisguan--; } }
private void toolStripButton2_Click(object sender, EventArgs e) { string str = Microsoft.VisualBasic.Interaction.InputBox("选择你要的关卡!", "提示", "", -1, -1); int fanhui = Thisguan; Thisguan = int.Parse(str); path = "..\\..\\files\\map\\" + Thisguan.ToString() + ".map"; try { OpenMap(s, path); DrawMap(); } catch { MessageBox.Show("这关不存在", "错误"); Thisguan = fanhui; } }
private void Form1_Paint(object sender, PaintEventArgs e) { DrawMap(); label1.Text = "现在是第:" + Thisguan.ToString() + "关"; }
private void Form1_KeyDown(object sender, KeyEventArgs e) { Undo aa = new Undo(); aa.n = new Status[15, 15]; for (int i = 0; i < 15; i++) { for (int j = 0; j < 15; j++) { aa.n[i, j] = s[i, j]; } } if (e.KeyCode == Keys.Down) { if (work.WorkMove(s, ref manX, ref manY, 0, 1)) { count++; Cancel.Push(aa.n); } if (s[manX, manY] != Status.WorkerInDestination) { s[manX, manY] = Status.down; } } if (e.KeyCode == Keys.Up) { if (work.WorkMove(s, ref manX, ref manY, 0, -1)) { count++; Cancel.Push(aa.n); } if (s[manX, manY] != Status.WorkerInDestination) { s[manX, manY] = Status.up; } } if (e.KeyCode == Keys.Right) { if (work.WorkMove(s, ref manX, ref manY, 1, 0)) { count++; Cancel.Push(aa.n); } if (s[manX, manY] != Status.WorkerInDestination) { s[manX, manY] = Status.right; } } if (e.KeyCode == Keys.Left) { if (work.WorkMove(s, ref manX, ref manY, -1, 0)) { count++; Cancel.Push(aa.n); } if (s[manX, manY] != Status.WorkerInDestination) { s[manX, manY] = Status.left; } } if ((e.Control) && (e.KeyCode == Keys.Z)) { try { s = Cancel.Pop(); count--; DrawMap(); } catch { MessageBox.Show("不可后退", "Error"); } } if (e.KeyCode == Keys.G) { goodMethod(); } else if (e.KeyCode == Keys.B) { badMethod(); } DrawMap(); if (work.IsWin(s)) { timer1.Stop(); MessageBox.Show("过关", "恭喜"); Thisguan++; path = "..\\..\\files\\map\\" + Thisguan.ToString() + ".map"; OpenMap(s, path); DrawMap(); label1.Text = "现在是第:" + (Thisguan).ToString() + "关"; count = 0; } }