Пример #1
0
 public static void drawBullet(Graphics g, int gridWidth, int gridHeight, Bullet bullet, Brush color)
 {
     int bulletX = 5 + (bullet.x * gridWidth) + (int)(gridWidth * 0.5);
     int bulletY = 5 + (bullet.y * gridHeight) + (int)(gridHeight * 0.5);
     Rectangle bulletBaseRect = new Rectangle(bulletX - (int)(gridWidth * 0.4), bulletY - (int)(gridHeight * 0.4), (int)(gridWidth * 0.8), (int)(gridHeight * 0.8));
     g.FillEllipse(color, bulletBaseRect);
 }
Пример #2
0
 public Bullet(Bullet source)
 {
     this.x = source.x;
     this.y = source.y;
     this.direction = source.direction;
     this.id = source.id;
 }
        private void destroyWall(Bullet bullet)
        {
            Point[] points = new Point[5];
            points[0] = new Point(bullet.x, bullet.y);
            switch (bullet.direction)
            {
                case Direction.UP:
                case Direction.DOWN:
                    points[1] = new Point(bullet.x - 2, bullet.y);
                    points[2] = new Point(bullet.x - 1, bullet.y);
                    points[3] = new Point(bullet.x + 1, bullet.y);
                    points[4] = new Point(bullet.x + 2, bullet.y);
                    break;
                case Direction.LEFT:
                case Direction.RIGHT:
                    points[1] = new Point(bullet.x, bullet.y - 2);
                    points[2] = new Point(bullet.x, bullet.y - 1);
                    points[3] = new Point(bullet.x, bullet.y + 1);
                    points[4] = new Point(bullet.x, bullet.y + 2);
                    break;
            }

            foreach (Point pt in points)
            {
                if (this.blocks[pt.X, pt.Y] == State.FULL)
                {
                    this.blocks[pt.X, pt.Y] = State.EMPTY;
                    if (this.onWallDestroyed != null)
                    {
                        this.onWallDestroyed(pt.X, pt.Y);
                    }
                }
            }
        }