/// <summary>
 /// Loop through inventory array from stats Class
 /// if inventoryItem is the weapon we want to add to inventory, run addAmmo function from the weapon class
 /// else if inventoryItem is empty don't check last condition and move to next iteration of the loop
 /// else it doesn't exist in the inventory and we must put a reference to the weapon there.
 /// </summary>
 /// <param name="stats">reference to instigators stats, instigator is actor who entered trigger</param>
 void AddToInventory(Stats stats)
 {
     Debug.Log(stats.name);
     for (int i = 0; i < stats.inventory.Length; i++)
     {
         if (stats.inventory[i] == weapon)
         {
             // Add ammo instead
             weapon.AddAmmo(stats);
             break;
         }
         else if (stats.inventory[i] != null)
         {
             continue;
         }
         else
         {
             // add to inventory
             stats.inventory[i] = weapon;
             stats.pawn.ManageInventory();
             weapon.AddAmmo(stats);
             break;
         }
     }
 }
Esempio n. 2
0
    protected override bool Activate()
    {
        Weapon weapon = player.playerCombat.GetWeaponFromType(weaponType);

        Weapon playerWeapon = player.playerCombat.CurrentWeapon;

        if (!player.playerCombat.weaponInventory.Contains(weapon))
        {
            return(false);
        }

        int ammoDiff = playerWeapon.MaxAmmoTotal - playerWeapon.TotalAmmo;

        if (ammoDiff == 0)
        {
            return(false);
        }

        if (ammoToGive > ammoDiff)
        {
            playerWeapon.AddAmmo(ammoDiff);
        }
        else
        {
            playerWeapon.AddAmmo(ammoToGive);
        }

        return(true);
    }
Esempio n. 3
0
 public void AddAmmo(int amount)
 {
     if (currentWeapon)
     {
         currentWeapon.AddAmmo(amount);
     }
 }
Esempio n. 4
0
 public void AddWeapon(Weapon weaponToAdd)
 {
     if (weaponToAdd.WeaponType == Types.WeaponTypes.Pistol)
     {
         if (EquippedPistol == null)
         {
             EquippedPistol = weaponToAdd;
             UnEquipWeapon(Types.WeaponTypes.Pistol);
         }
         else
         {
             EquippedPistol.AddAmmo(weaponToAdd.CurrentAmmo);
         }
     }
     else if (weaponToAdd.WeaponType == Types.WeaponTypes.Rifle)
     {
         if (EquippedRifle == null)
         {
             EquippedRifle = weaponToAdd;
             UnEquipWeapon(Types.WeaponTypes.Rifle);
         }
         else
         {
             EquippedRifle.AddAmmo(weaponToAdd.CurrentAmmo);
         }
     }
 }
Esempio n. 5
0
 public bool AddAmmo(int num)
 {
     if (currentWeapon == null || currentWeapon.curAmmo == currentWeapon.maxAmmo)
     {
         return(false);
     }
     Debug.Log("adding ammo");
     currentWeapon.AddAmmo(num);
     return(true);
 }
Esempio n. 6
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (canpickup)
     {
         if (collision.gameObject.CompareTag("Player"))
         {
             canpickup = false;
             Destroy(gameObject);
             Weapon weapon = collision.GetComponent <Weapon>();
             // weapon.enabled = true;
             weapon.AddAmmo(4);
         }
     }
 }
Esempio n. 7
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if ((other.gameObject.name == "Player"))
     {
         if (!GameControl.instance.gameOver)
         {
             source.Play();
             weapon.AddAmmo(1);
             ammoEmitter.Play();
             transform.localScale    = new Vector3(0, 0, 0);
             polygonCollider.enabled = false;
             Invoke("DestroyItself", 1f);
         }
     }
 }
Esempio n. 8
0
    /// <summary>
    /// Adds the weapon to the inventory List.
    /// </summary>
    /// <param name='weapon'>
    /// Weapon.
    /// </param>
    public void AddWeapon(Weapon weapon)
    {
        Weapon result = FindWeapon(weapon);

        if (result != null)
        {
            result.AddAmmo(weapon.ammo);
        }
        else
        {
            weapon.owner = owner;
            Weapons.Add(weapon);
        }
        CurrentWeapon = weapon;
        Debug.Log("Added Weapon: " + weapon.name + ", Current COunt: " + Weapons.Count);
    }
Esempio n. 9
0
    public bool AddAmmo(Weapon.AmmoType type, int amount)
    {
        Weapon tmp = null;

        for (int i = 0; i < weapons.Length; i++)
        {
            if (weapons[i].ammotype == type)
            {
                tmp = weapons[i];
                i   = weapons.Length;
            }
        }
        if (tmp != null)
        {
            return(tmp.AddAmmo(amount));
        }
        else
        {
            return(false);
        }
    }
Esempio n. 10
0
 public bool AddWeapon(Weapon weaponToAdd)
 {
     if (weaponToAdd.WeaponType == Types.WeaponTypes.Pistol)
     {
         if (EquippedPistol == null)
         {
             EquippedPistol = weaponToAdd;
             UnEquipWeapon(Types.WeaponTypes.Pistol);
             return(true);
         }
         else
         {
             EquippedPistol.AddAmmo(weaponToAdd.CurrentAmmo);
             Destroy(weaponToAdd.gameObject);
             character.UpdateGUI(true, EquippedPistol);
             return(false);
         }
     }
     else if (weaponToAdd.WeaponType == Types.WeaponTypes.Rifle)
     {
         if (EquippedRifle == null)
         {
             EquippedRifle = weaponToAdd;
             UnEquipWeapon(Types.WeaponTypes.Rifle);
             return(true);
         }
         else
         {
             EquippedRifle.AddAmmo(weaponToAdd.CurrentAmmo);
             Destroy(weaponToAdd.gameObject);
             character.UpdateGUI(true, EquippedRifle);
             return(false);
         }
     }
     return(false);
 }
Esempio n. 11
0
 public void AddAmmo()
 {
     _weapon.AddAmmo(100);
 }