/// <summary>
    /// Add ammo to the inventory
    /// </summary>
    /// <param name="ammo"> the ammo to be added, no max limit</param>
    /// <param name="ammoType">kind of ammo added</param>
    public void AddAmmoToInventory(int ammo, AMMO_TYPE ammoType)
    {
        int actualAmmo = GetAvailableAmmo(ammoType);

        actualAmmo += ammo;
        SetAvailableAmmo(ammoType, actualAmmo);
        UIManager.instance.UpdateAmmoBagInfo(ammoType, actualAmmo);
    }
    /// <summary>
    /// Get the max available ammo from inventory depending on
    /// how much left in the bag, for example, if we want 30 bullets, but
    /// only 3 left, this function will extract the 3 bullets from bag and set actualBullets to 0
    /// </summary>
    /// <returns>
    /// Then number of ammo that was extracted successfully
    /// </returns>
    public int ExtractAmmoFromInventory(int maxAmmo, AMMO_TYPE ammoType)
    {
        int availableAmmo = GetAvailableAmmo(ammoType);
        int extractedAmmo = 0;

        if (availableAmmo > maxAmmo)
        {
            extractedAmmo  = maxAmmo;
            availableAmmo -= maxAmmo;
        }
        else
        {
            // cant extract the full clip of ammo, get the left ammo available
            extractedAmmo = availableAmmo;
            availableAmmo = 0;
        }
        SetAvailableAmmo(ammoType, availableAmmo);
        return(extractedAmmo);
    }
    public int GetAvailableAmmo(AMMO_TYPE ammoType)
    {
        switch (ammoType)
        {
        case AMMO_TYPE.BULLET:
            return(bullets);

        case AMMO_TYPE.PLASMA:
            return(plasma);

        case AMMO_TYPE.ROCKET:
            return(rockets);

        case AMMO_TYPE.LASER:
            return(laser);

        default:
            return(0);
        }
    }
    public void SetAvailableAmmo(AMMO_TYPE ammoType, int ammo)
    {
        switch (ammoType)
        {
        case AMMO_TYPE.BULLET:
            bullets = ammo;
            break;

        case AMMO_TYPE.PLASMA:
            plasma = ammo;
            break;

        case AMMO_TYPE.ROCKET:
            rockets = ammo;
            break;

        case AMMO_TYPE.LASER:
            laser = ammo;
            break;
        }

        UIManager.instance.UpdateAmmoBagInfo(ammoType, ammo);
    }
Exemplo n.º 5
0
 public void increaseAmmo(AMMO_TYPE typeAmmo, uint value)
 {
     ammoInvenotry[typeAmmo] += value;
 }
Exemplo n.º 6
0
 public uint getAmmo(AMMO_TYPE typeAmmo)
 {
     return(ammoInvenotry[typeAmmo]);
 }
Exemplo n.º 7
0
 public void setAmmoType(AMMO_TYPE type)
 {
     m_ammoType = type;
 }