Example #1
0
        public void FireAt(GameTime gameTime, TilePlayer player)
        {
            if (Bullet != null && Bullet.ProjectileState == Projectile.PROJECTILE_STATUS.Idle)
            {
                Bullet.PixelPosition = (this.PixelPosition - new Vector2(WIDTH_IN, 0));
            }

            if (Bullet != null)
            {
                if (Bullet.ProjectileState == Projectile.PROJECTILE_STATUS.Idle &&
                    this.angleOfRotation != 0 && Math.Round(this.angleOfRotationPrev, 2) == Math.Round(this.angleOfRotation, 2))
                {
                    // Send this direction to the projectile
                    Bullet.GetDirection(Direction);
                    // Shoot at the specified position
                    Bullet.Shoot(player.CentrePos);
                    // Draw muzzleflash
                    muzzleFlash.angleOfRotation  = this.angleOfRotation;
                    muzzleFlash.PixelPosition    = this.PixelPosition - new Vector2(10, 0) + (this.Direction * (FrameWidth - 10));
                    muzzleFlash.Visible          = true;
                    muzzleFlash.OrbLight.Enabled = true;
                    muzzleFlash.Draw(gameTime);
                }
                else
                {
                    muzzleFlash.Visible          = false;
                    muzzleFlash.OrbLight.Enabled = false;
                }
            }
        }
Example #2
0
        public void Fire(GameTime gameTime)
        {
            Camera thisCamera = (Camera)Game.Services.GetService(typeof(Camera));

            if (Bullet != null && Bullet.ProjectileState == Projectile.PROJECTILE_STATUS.Idle)
            {
                Bullet.PixelPosition = (this.PixelPosition - new Vector2(WIDTH_IN, 0));
            }

            if (Bullet != null)
            {
                if (InputShoot() &&
                    Bullet.ProjectileState == Projectile.PROJECTILE_STATUS.Idle &&
                    this.angleOfRotation != 0 &&
                    Math.Round(this.angleOfRotationPrev, 2) == Math.Round(this.angleOfRotation, 2))
                {
                    // Send this direction to the projectile
                    Bullet.GetDirection(Direction);
                    // Shoot at the specified position
                    Bullet.Shoot(Crosshair.Position - new Vector2(FrameWidth / 2, FrameHeight / 2));
                    // Draw muzzleflash
                    muzzleFlash.angleOfRotation  = this.angleOfRotation;
                    muzzleFlash.PixelPosition    = this.PixelPosition - new Vector2(10, 0) + (this.Direction * (FrameWidth - 10));
                    muzzleFlash.Visible          = true;
                    muzzleFlash.OrbLight.Enabled = true;
                    muzzleFlash.Draw(gameTime);
                    // Play sounds
                    ShellSound.Play();
                    ShellReload.Play();
                    HumReloadInstance.Play();
                    // Shake the camera
                    thisCamera.Shake(5f, 0.5f);
                    InputEngine.ShakePad(0.4f, 0.5f, 0.5f);
                }
                else
                {
                    muzzleFlash.Visible          = false;
                    muzzleFlash.OrbLight.Enabled = false;
                }
            }
        }