public WeaponEngine(ContentPool Content, ObjectPool Objects)
 {
     this.Content = Content;
     this.Objects = Objects;
     this.availableWeapons = new List<WeaponBase>();
     this.currentWeapon = null;
     GameStats.CreateStat("FiredBullets", 0);
 }
 public override void OnHit(WeaponBase weapon, Vector2 from)
 {
     health -= weapon.Damage;
     if (health <= 0)
     {
         //Update Stats
         GameStats.AppendStat("KilledEnemies", 1);
     }
     base.OnHit(weapon, from);
 }
 public void Update(GameTime gameTime, int playerX, int playerY, MapBase map, double rotation, double aimX, double aimY)
 {
     KeyboardState kybd = Keyboard.GetState();
     if (kybd.IsKeyDown(Keys.Tab) && tabActivated == false)
     {
         if (currentWeapon != null)
         {
             if (availableWeapons.IndexOf(currentWeapon) + 1 < availableWeapons.Count)
             {
                 currentWeapon = availableWeapons[availableWeapons.IndexOf(currentWeapon) + 1];
             }
             else
             {
                 if (availableWeapons.Count >= 1)
                 {
                     currentWeapon = availableWeapons[0];
                 }
             }
         }
         else
         {
             if (availableWeapons.Count >= 1)
             {
                 currentWeapon = availableWeapons[0];
             }
         }
         tabActivated = true;
     }
     if (kybd.IsKeyUp(Keys.Tab) && tabActivated == true)
     {
         tabActivated = false;
     }
     if (Mouse.GetState().LeftButton == ButtonState.Pressed && canFire)
     {
         currentWeapon.Shoot(rotation, playerX + int.Parse(map.Offset.X.ToString()), playerY + int.Parse(map.Offset.Y.ToString()), map, aimX, aimY);
         GameStats.AppendStat("FiredBullets", 1);
     }
     if ((kybd.IsKeyDown(Keys.R) && canReload) || (currentWeapon.Ammo == 0 && canReload))
     {
         if (currentWeapon.Ammo == currentWeapon.MaxClip) { }
         timeSinceReload = DateTime.Now;
         reloading = true;
         canFire = false;
         canReload = false;
         
     }
     if (reloading)
     {
         TimeSpan reloadCheck = DateTime.Now - timeSinceReload;
         if((reloadCheck.TotalMilliseconds / 1000) >= currentWeapon.ReloadTime)
         {
             int ammoToAdd = currentWeapon.MaxClip - currentWeapon.Ammo;
             currentWeapon.Ammo += ammoToAdd;
             ammo9MM.Remaining -= ammoToAdd;
             reloading = false;
             canReload = true;
             canFire = true;
         }
     }
     currentWeapon.Update(gameTime, playerX, playerY, rotation);
 }
 public void AddAvailableWeapon(WeaponBase weapon)
 {
     availableWeapons.Add(weapon);
     availableWeapons[availableWeapons.Count - 1].LoadContent(Content, Objects);
     if (this.availableWeapons.Count == 1)
     {
         currentWeapon = availableWeapons[0];
     }
 }
        public virtual void OnHit(WeaponBase weapon, Vector2 from)
        {

        }