/// <summary> /// Fire a bullet from the weapon /// </summary> /// <param name="direction">The speed that the bullet is moving</param> public override bool Fire(Vector2 direction) { ControlManager controlManager = ControlManager.Instance; //Check if click condition is met if (controlManager.ControlPressedControlPrevReleased(Control_Types.Fire)) { //Check user can fire or if they need to reload if (!Fired && !Reload && clip <= 0) { Reload = true; return(false); } if (!Fired && !Reload && clip > 0) { Fired = true; clip--; Matrix rotationMatrix = Matrix.CreateRotationZ(Angle); switch (Dir) { case Weapons.Weapon_Dir.UpWest: case Weapons.Weapon_Dir.UpLeft: case Weapons.Weapon_Dir.Left: case Weapons.Weapon_Dir.DownLeft: case Weapons.Weapon_Dir.DownWest: rotationMatrix.M21 = (float)Math.Sin(Angle + Math.PI); rotationMatrix.M22 = -(float)Math.Cos(Angle - Math.PI); break; } Vector2 bulletPosition = Vector2.Transform(bulletOffset, rotationMatrix); ProjectileManager.Instance.Clone(ProjType, Position + bulletPosition, direction, Angle + ((float)Math.PI / 2), owner, WeapRange); AudioManager.Instance.GetSoundEffect("PistolShoot").Play(); return(true); } } return(false); }