Example #1
0
        public void ChangeDirection(Keys keyData, Scene scene)
        {
            Block nextBlock=null;
            Direction  newDir=direction;
            switch (keyData)
            {
                case Keys.Up:
                    nextBlock = scene[r - 1, c];
                    newDir = Direction.UP;
                    break;
                case Keys.Down:
                    nextBlock = scene[r + 1, c];
                    newDir = Direction.DOWN;
                    break;
                case Keys.Left:
                    nextBlock = scene[r, c - 1];
                    newDir = Direction.LEFT;
                    break;
                case Keys.Right:
                    nextBlock = scene[r, c + 1];
                    newDir = Direction.RIGHT;
                    break;
            }
            if (nextBlock != null) {
                if (nextBlock.IsReachable())
                {
                    direction = newDir;
                    IsRunning = true;

                }
            }
        }
Example #2
0
 public void GameOver()
 {
     timer1.Stop();
     timer2.Stop();
     timer3.Stop();
     mciSendString(@"close bgm", null, 0, 0);
     myScene = new Scene(Play.BackColor, type);
 }
Example #3
0
 private Block Next(Scene scene)
 {
     switch (dir)
     {
         default:
         case Direction.UP:
             return scene[r - 1, c];
         case Direction.DOWN:
             return scene[r + 1, c];
         case Direction.LEFT:
             return scene[r, c - 1];
         case Direction.RIGHT:
             return scene[r, c + 1];
     }
 }
Example #4
0
        public void Move(Scene scene)
        {
            Block nextBlock = Next(scene);
                if (nextBlock.IsReachable())
                {
                    this.r = nextBlock.R;
                    this.c = nextBlock.C;
                }
                else
                {
                    //����ǽ���������һ������
                    Random random = new Random();
                    dir = (Direction)random.Next(0, 4);

                }
        }
Example #5
0
 private void 鏖战ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Lev2();
     lev = 2;
     myScene = new Scene(Play.BackColor, type);
 }
Example #6
0
 private void 美利坚ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     type = 1;
     myScene = new Scene(Play.BackColor, type);
     GameStart();
 }
Example #7
0
 private void Game_Load(object sender, EventArgs e)
 {
     myScene = new Scene(Play.BackColor, type);
     EatBean.Interval = 400;
     ReadScore_Name();
     mciSendString(@"open " + @"win.mp3" + " alias win", null, 0, 0);
     mciSendString("play win repeat", null, 0, 0);
 }
Example #8
0
        public void Move(Scene scene)
        {
            if (isRunning)
            {
                Block nextBlock = Next(scene);
                if (nextBlock.IsEatable() && nextBlock.IsReachable())
                {
                    eatBean = true;
                    //将pacman所在块清空
                    scene[r, c] = new Empty(r, c);
                    //pacman移动到下一位置
                    this.r = nextBlock.R;
                    this.c = nextBlock.C;
                    //下一位置置为空块
                    scene[r, c] = new Empty(r, c);
                    //吃金豆,并加分
                    scene.BeanNum--;
                    scene.Score += 10;

                }
                else if (nextBlock.IsReachable())
                {
                    this.r = nextBlock.R;
                    this.c = nextBlock.C;
                }
                else
                {
                    isRunning = false;
                }
            }
        }