private void Reload()
    {
        int needed = maxAmmo - inventory.ItemCount();

        if (needed == 0 || wielder == null)
        {
            return;
        }

        IHasAmmo ammoHolder = wielder as IHasAmmo;

        if (ammoHolder == null)
        {
            return;
        }

        if (ammoHolder.CheckAmmo(ammoType, 1) == 0)
        {
            return;
        }

        speaker.PlayEffect(Sound.Effects.RifleReload);
        List <ItemData> receivedAmmo = ammoHolder.RequestAmmo(ammoType, needed);

        foreach (ItemData ammo in receivedAmmo)
        {
            inventory.StoreItemData(ammo);
        }
    }
Beispiel #2
0
    private void Reload()
    {
        int needed = maxAmmo - ammo;

        if (needed == 0 || wielder == null)
        {
            return;
        }

        IHasAmmo ammoHolder = wielder as IHasAmmo;

        if (ammoHolder == null)
        {
            return;
        }

        if (ammoHolder.CheckAmmo(ammoType, 1) == 0)
        {
            return;
        }

        speaker.PlayEffect(Sound.Effects.RifleReload);
        int receivedAmmo = ammoHolder.RequestAmmo(ammoType, needed);

        StoreAmmo(ammoType, receivedAmmo);
    }
Beispiel #3
0
    public override string GetInfo()
    {
        string ret = name + "[" + ammo + "/" + maxAmmo;

        if (wielder != null)
        {
            IHasAmmo ammoHolder = wielder as IHasAmmo;
            if (ammoHolder != null)
            {
                ret += "/" + ammoHolder.CheckAmmo(ammoType, -1);
            }
        }
        ret += "]";
        return(ret);
    }
Beispiel #4
0
    void ManageAmmo(IHasAmmo ammoHaver)
    {
        string[] ammoTypes = ammoHaver.AmmoTypes();
        if (ammoTypes == null || ammoTypes.Length == 0)
        {
            return;
        }

        string ammoType   = ammoTypes[0];
        int    haverCount = ammoHaver.CheckAmmo(ammoType, -1);
        int    actorCount = actor.CheckAmmo(ammoType, -1);

        if (haverCount == 0 && actorCount > 0)
        {
            actor.Use(Item.Uses.D);
        }
    }
Beispiel #5
0
    public override string GetInfo()
    {
        string ret       = name + "[" + inventory.ItemCount() + "/" + maxAmmo;
        int    ammoTotal = CheckReserveAmmo(ammoType, 0);

        if (wielder != null)
        {
            IHasAmmo ammoHolder = wielder as IHasAmmo;
            if (ammoHolder != null)
            {
                ammoTotal += ammoHolder.CheckAmmo(ammoType, 0);
            }
        }
        ret += "/" + ammoTotal;

        ret += "]";
        return(ret);
    }