Example #1
0
        public void shootBullet(BulletType bulletType, Vector2 target, int speed, double rotation, float scale)
        {
            float angle = (float)Math.Atan2((double)(target.Y - CenterPoint.Y), (double)(target.X - CenterPoint.X));

            float moveX = speed * (float)Math.Cos(angle);
            float moveY = speed * (float)Math.Sin(angle);

            Bullet b = new Bullet(bulletType, new Vector2(moveX, moveY));

            b.Y = (int)this.CenterPoint.Y;
            b.X = (int)this.CenterPoint.X + b.Width / 4;

            b.Rotation = (float)rotation;
            b.Width    = (int)(b.Width * scale);
            b.Height   = (int)(b.Height * scale);
        }
Example #2
0
 public Bullet(BulletType bulletType, Vector2 speed)
     : base(new Rectangle(0, 0, (int)bulletType.Size.X, (int)bulletType.Size.Y), speed)
 {
     //this.X = (int)bulletType.Size.X;
     //this.Y = (int)bulletType.Size.Y;
     this.Texture = bulletType.Texture;
     this.bulletType = bulletType;
     if (bulletType == BulletType.Peanut)
     {
         isPeanut = true;
         Peanuts.Add(this);
     }
     else if (BulletType.Cans.Contains<BulletType>(bulletType))
     {
         isCan = true;
         Cans.Add(this);
     }
 }
Example #3
0
 public Bullet(BulletType bulletType, Vector2 speed)
     : base(new Rectangle(0, 0, (int)bulletType.Size.X, (int)bulletType.Size.Y), speed)
 {
     //this.X = (int)bulletType.Size.X;
     //this.Y = (int)bulletType.Size.Y;
     this.Texture    = bulletType.Texture;
     this.bulletType = bulletType;
     if (bulletType == BulletType.Peanut)
     {
         isPeanut = true;
         Peanuts.Add(this);
     }
     else if (BulletType.Cans.Contains <BulletType>(bulletType))
     {
         isCan = true;
         Cans.Add(this);
     }
 }
Example #4
0
 public ExplodingBullet(BulletType type, float speed, Vector2 target)
     : base(type, new Vector2(speed, speed))
 {
     this.target = target;
 }
Example #5
0
 public ExplodingBullet(BulletType type, float speed, Vector2 target)
     : base(type, new Vector2(speed, speed))
 {
     this.target = target;
 }
Example #6
0
        public void shootBullet(BulletType bulletType, Vector2 target, int speed, double rotation, float scale)
        {
            float angle = (float)Math.Atan2((double)(target.Y - CenterPoint.Y), (double)(target.X - CenterPoint.X));

            float moveX = speed * (float)Math.Cos(angle);
            float moveY = speed * (float)Math.Sin(angle);

            Bullet b = new Bullet(bulletType, new Vector2(moveX, moveY));

            b.Y = (int)this.CenterPoint.Y;
            b.X = (int)this.CenterPoint.X + b.Width / 4;

            b.Rotation = (float)rotation;
            b.Width = (int)(b.Width * scale);
            b.Height = (int)(b.Height * scale);
        }
Example #7
0
 // bill shoot
 public void shootBullet(BulletType bulletType, Vector2 target, int speed)
 {
     shootBullet(bulletType, target, speed, 0, 1);
 }
Example #8
0
        public void shootBullet(BulletType bulletType, Direction d, int speed, float scale)
        {
            if (!this.hasPowerUp(PowerUpType.DoubleShot))
            {
                Bullet bullet = new Bullet(bulletType, new Vector2());
                bullet.Width = (int)(bullet.Width * scale);
                bullet.Height = (int)(bullet.Height * scale);

                if (d == Direction.North)
                {
                    bullet.X = this.X + this.Width / 2 - bullet.Width / 2;
                    bullet.Y = this.Y - bullet.Height;
                }
                else if (d == Direction.South)
                {
                    bullet.X = this.X + this.Width / 2 - bullet.Width / 2;
                    bullet.Y = this.Y + this.Height;
                }
                else if (d == Direction.West)
                {
                    bullet.X = this.X - bullet.Width;
                    bullet.Y = this.Y + this.Height / 2 - bullet.Height / 2;
                }
                else if (d == Direction.East)
                {
                    bullet.X = this.X + this.Width;
                    bullet.Y = this.Y + this.Height / 2 - bullet.Height / 2;
                }
                else if (d == Direction.NorthEast)
                {
                    bullet.X = this.X + this.Width;
                    bullet.Y = this.Y - bullet.Height;
                }
                else if (d == Direction.SouthEast)
                {
                    bullet.X = this.X + this.Width;
                    bullet.Y = this.Y + this.Height;
                }
                else if (d == Direction.NorthWest)
                {
                    bullet.X = this.X - bullet.Width;
                    bullet.Y = this.Y - bullet.Height;
                }
                else if (d == Direction.SouthWest)
                {
                    bullet.X = this.X - bullet.Width;
                    bullet.Y = this.Y + this.Height;
                }

                bullet.speed.X = speed * d.X;
                bullet.speed.Y = speed * d.Y;
            }
            else
            {
                Bullet bullet1 = new Bullet(bulletType, new Vector2());
                Bullet bullet2 = new Bullet(bulletType, new Vector2());
                bullet1.Width = (int)(bullet1.Width * scale);
                bullet1.Height = (int)(bullet1.Height * scale);
                bullet2.Width = (int)(bullet2.Width * scale);
                bullet2.Height = (int)(bullet2.Height * scale);

                if (d == Direction.North)
                {
                    bullet1.X = this.X + (int)(this.Width * .33f) - bullet1.Width / 2;
                    bullet2.X = this.X + (int)(this.Width * .66f) - bullet2.Width / 2;
                    bullet1.Y = bullet2.Y = this.Y - bullet1.Height;
                }
                else if (d == Direction.South)
                {
                    bullet1.X = this.X + (int)(this.Width * .33f) - bullet1.Width / 2;
                    bullet2.X = this.X + (int)(this.Width * .66f) - bullet2.Width / 2;
                    bullet1.Y = bullet2.Y = this.Y + this.Height;
                }
                else if (d == Direction.West)
                {
                    bullet1.X = bullet2.X = this.X - bullet1.Width;
                    bullet1.Y = this.Y + (int)(this.Height * .33f) - bullet1.Height / 2;
                    bullet2.Y = this.Y + (int)(this.Height * .66f) - bullet1.Height / 2;
                }
                else if (d == Direction.East)
                {
                    bullet1.X = bullet2.X = this.X + this.Width;
                    bullet1.Y = this.Y + (int)(this.Height * .33f) - bullet1.Height / 2;
                    bullet2.Y = this.Y + (int)(this.Height * .66f) - bullet1.Height / 2;
                }
                else if (d == Direction.NorthEast)
                {
                    bullet1.X = this.X + (int)(this.Width * .85f) - bullet1.Width / 2;
                    bullet1.Y = this.Y - bullet1.Height;
                    bullet2.X = this.X + this.Width;
                    bullet2.Y = this.Y + (int)(this.Height * .15f) - bullet2.Height / 2;
                }
                else if (d == Direction.SouthEast)
                {
                    bullet1.X = this.X + (int)(this.Width * .85f) - bullet1.Width / 2;
                    bullet1.Y = this.Y + this.Height;
                    bullet2.X = this.X + this.Width;
                    bullet2.Y = this.Y + (int)(this.Height * .85f) - bullet2.Height / 2;
                }
                else if (d == Direction.NorthWest)
                {
                    bullet1.X = this.X + (int)(this.Width * .15f) - bullet1.Width / 2;
                    bullet1.Y = this.Y - bullet1.Height;
                    bullet2.X = this.X - bullet2.Width;
                    bullet2.Y = this.Y + (int)(this.Height * .15f) - bullet2.Height / 2;
                }
                else if (d == Direction.SouthWest)
                {
                    bullet1.X = this.X + (int)(this.Height * .15f) - bullet1.Width / 2;
                    bullet1.Y = this.Y + this.Height;
                    bullet2.X = this.X - bullet2.Width;
                    bullet2.Y = this.Y + (int)(this.Height * .85f) - bullet2.Height / 2;
                }
                bullet1.speed.X = bullet2.speed.X = speed * d.X;
                bullet1.speed.Y = bullet2.speed.Y = speed * d.Y;
            }
        }
Example #9
0
 // isaac shoot
 public void shootBullet(BulletType bulletType, Direction d, int speed)
 {
     shootBullet(bulletType, d, speed, 1);
 }
Example #10
0
        public void shootBullet(BulletType bulletType, Direction d, int speed, float scale)
        {
            if (!this.hasPowerUp(PowerUpType.DoubleShot))
            {
                Bullet bullet = new Bullet(bulletType, new Vector2());
                bullet.Width  = (int)(bullet.Width * scale);
                bullet.Height = (int)(bullet.Height * scale);

                if (d == Direction.North)
                {
                    bullet.X = this.X + this.Width / 2 - bullet.Width / 2;
                    bullet.Y = this.Y - bullet.Height;
                }
                else if (d == Direction.South)
                {
                    bullet.X = this.X + this.Width / 2 - bullet.Width / 2;
                    bullet.Y = this.Y + this.Height;
                }
                else if (d == Direction.West)
                {
                    bullet.X = this.X - bullet.Width;
                    bullet.Y = this.Y + this.Height / 2 - bullet.Height / 2;
                }
                else if (d == Direction.East)
                {
                    bullet.X = this.X + this.Width;
                    bullet.Y = this.Y + this.Height / 2 - bullet.Height / 2;
                }
                else if (d == Direction.NorthEast)
                {
                    bullet.X = this.X + this.Width;
                    bullet.Y = this.Y - bullet.Height;
                }
                else if (d == Direction.SouthEast)
                {
                    bullet.X = this.X + this.Width;
                    bullet.Y = this.Y + this.Height;
                }
                else if (d == Direction.NorthWest)
                {
                    bullet.X = this.X - bullet.Width;
                    bullet.Y = this.Y - bullet.Height;
                }
                else if (d == Direction.SouthWest)
                {
                    bullet.X = this.X - bullet.Width;
                    bullet.Y = this.Y + this.Height;
                }

                bullet.speed.X = speed * d.X;
                bullet.speed.Y = speed * d.Y;
            }
            else
            {
                Bullet bullet1 = new Bullet(bulletType, new Vector2());
                Bullet bullet2 = new Bullet(bulletType, new Vector2());
                bullet1.Width  = (int)(bullet1.Width * scale);
                bullet1.Height = (int)(bullet1.Height * scale);
                bullet2.Width  = (int)(bullet2.Width * scale);
                bullet2.Height = (int)(bullet2.Height * scale);

                if (d == Direction.North)
                {
                    bullet1.X = this.X + (int)(this.Width * .33f) - bullet1.Width / 2;
                    bullet2.X = this.X + (int)(this.Width * .66f) - bullet2.Width / 2;
                    bullet1.Y = bullet2.Y = this.Y - bullet1.Height;
                }
                else if (d == Direction.South)
                {
                    bullet1.X = this.X + (int)(this.Width * .33f) - bullet1.Width / 2;
                    bullet2.X = this.X + (int)(this.Width * .66f) - bullet2.Width / 2;
                    bullet1.Y = bullet2.Y = this.Y + this.Height;
                }
                else if (d == Direction.West)
                {
                    bullet1.X = bullet2.X = this.X - bullet1.Width;
                    bullet1.Y = this.Y + (int)(this.Height * .33f) - bullet1.Height / 2;
                    bullet2.Y = this.Y + (int)(this.Height * .66f) - bullet1.Height / 2;
                }
                else if (d == Direction.East)
                {
                    bullet1.X = bullet2.X = this.X + this.Width;
                    bullet1.Y = this.Y + (int)(this.Height * .33f) - bullet1.Height / 2;
                    bullet2.Y = this.Y + (int)(this.Height * .66f) - bullet1.Height / 2;
                }
                else if (d == Direction.NorthEast)
                {
                    bullet1.X = this.X + (int)(this.Width * .85f) - bullet1.Width / 2;
                    bullet1.Y = this.Y - bullet1.Height;
                    bullet2.X = this.X + this.Width;
                    bullet2.Y = this.Y + (int)(this.Height * .15f) - bullet2.Height / 2;
                }
                else if (d == Direction.SouthEast)
                {
                    bullet1.X = this.X + (int)(this.Width * .85f) - bullet1.Width / 2;
                    bullet1.Y = this.Y + this.Height;
                    bullet2.X = this.X + this.Width;
                    bullet2.Y = this.Y + (int)(this.Height * .85f) - bullet2.Height / 2;
                }
                else if (d == Direction.NorthWest)
                {
                    bullet1.X = this.X + (int)(this.Width * .15f) - bullet1.Width / 2;
                    bullet1.Y = this.Y - bullet1.Height;
                    bullet2.X = this.X - bullet2.Width;
                    bullet2.Y = this.Y + (int)(this.Height * .15f) - bullet2.Height / 2;
                }
                else if (d == Direction.SouthWest)
                {
                    bullet1.X = this.X + (int)(this.Height * .15f) - bullet1.Width / 2;
                    bullet1.Y = this.Y + this.Height;
                    bullet2.X = this.X - bullet2.Width;
                    bullet2.Y = this.Y + (int)(this.Height * .85f) - bullet2.Height / 2;
                }
                bullet1.speed.X = bullet2.speed.X = speed * d.X;
                bullet1.speed.Y = bullet2.speed.Y = speed * d.Y;
            }
        }
Example #11
0
 // isaac shoot
 public void shootBullet(BulletType bulletType, Direction d, int speed)
 {
     shootBullet(bulletType, d, speed, 1);
 }
Example #12
0
 // bill shoot
 public void shootBullet(BulletType bulletType, Vector2 target, int speed)
 {
     shootBullet(bulletType, target, speed, 0, 1);
 }