public FireBulletEmitter(Bullet bullet, Texture2D tex, int size)
 {
     this.bullet = bullet;
     this.tex = tex;
     this.size = size;
 }
예제 #2
0
    /// <summary>
    /// Shoot this gun's ShotPatterns. It fires one bullet per ShotPattern with the
    /// appropriate parameters, with NewBullet fired for each bullet, then finally signals
    /// the ShotFired event.
    /// </summary>
    public void Shoot()
    {
      foreach (ShotPattern shot in Shots)
      {
        // Infrequent bullets should only be shot occasionally.
        if ((((shot.Effects & Effects.Infrequent) != 0) && App.Instance.Model.Music.ClickCount % 2 != 0) ||
          (((shot.Effects & Effects.VeryInfrequent) != 0) && App.Instance.Model.Music.ClickCount % 4 != 0))
        {
          continue;
        }

        Vector2 velocity = Constants.BULLET_VELOCITY * new Vector2(
          (float) Math.Cos(Orientation + shot.OrientationModifier),
          (float) Math.Sin(Orientation + shot.OrientationModifier)
        );
        Vector2 locMod = Vector2.Transform(shot.PositionModifier, Matrix.CreateRotationZ(Orientation));
        Bullet bullet = new Bullet(Location + locMod, velocity, Strength, shot.Effects, PlayerId);
        App.Instance.Model.Bullets.Add(bullet);
        if (NewBullet != null) NewBullet(this, new BulletArgs(bullet));
      }
      if (ShotFired != null) ShotFired(this, new ShotArgs(Shots));
    }