Esempio n. 1
0
File: Form1.cs Progetto: mitko0/Maze
        private void panelMaze_MouseClick(object sender, MouseEventArgs e)
        {
            Point p;

            if (g.award.awbJump)
            {
                List <Cell> cls = new List <Cell>();
                int         x1  = g.avatar.cl - 2;
                int         x2  = g.avatar.cl + 2;
                int         y1  = g.avatar.rw - 2;
                int         y2  = g.avatar.rw + 2;
                if (x1 < 0)
                {
                    x1 = 0;
                }
                if (x2 >= g.cols)
                {
                    x2 = g.cols - 1;
                }
                if (y1 < 0)
                {
                    y1 = 0;
                }
                if (y2 >= g.rows)
                {
                    y2 = g.rows - 1;
                }
                for (int i = x1; i <= x2; i++)
                {
                    for (int j = y1; j <= y2; j++)
                    {
                        Cell c = g.maze.cells["c" + i + "r" + j];
                        cls.Add(c);
                    }
                }
                foreach (var r in cls)
                {
                    if (g.InCell(e.Location, r))
                    {
                        g.avatar.rw = r.Row;
                        g.avatar.cl = r.Column;
                        p           = new Point(r.Bounds.X + g.avatar.r, r.Bounds.Y + g.avatar.r);
                        g.award.Jump(p, g.avatar);
                        Point x = new Point(p.X - g.avatar.r, p.Y - g.avatar.r);

                        g.award.CancelJump();
                        g.maze.Dig();
                        g.avatar.maze = g.maze.MazeImage;
                        g.DrawAll();
                        g.award.Consume(g.avatar.Location);
                        CheckFinish();
                        if (g.bombs.Die(x))
                        {
                            if (g.Lifes-- > 0)
                            {
                                g.CanMove     = true;
                                g.TimeCounter = 0;
                                if (g.Level < 11)
                                {
                                    g.rows -= 3;
                                }
                                g.cols -= 3;
                                if (g.wdth > 20)
                                {
                                    g.wdth += 2;
                                }
                                g.Level--;
                                g.LevelUp();
                                Generate();
                                g.bombs.Add(g.Level, g.maze.last);
                                LevelUp();
                            }
                            else
                            {
                                GameOver(true);
                            }
                        }
                        break;
                    }
                }
            }
            Awards();
        }