コード例 #1
0
ファイル: HostileAI.cs プロジェクト: justi1jc/FPS
    /* Returns the slot numbers of all ranged weapons in inventory that either
     * have ammo loaded, or can be loaded from ammo in the inventory.
     */
    public List <int> RangedWeapons()
    {
        List <int> ret = new List <int>();

        if (actor == null || actor.inventory == null)
        {
            return(ret);
        }
        Inventory inv = actor.inventory;

        for (int i = 0; i < inv.slots; i++)
        {
            Data dat = inv.Peek(i);
            if (dat != null)
            {
                if (dat.itemType == Item.RANGED)
                {
                    bool hasAmmo = Ranged.Ammo(dat) > 0;
                    if (!hasAmmo)
                    {
                        string ammoName = Ranged.AmmoName(dat);
                        hasAmmo = inv.ItemCount(ammoName) > 0;
                    }
                    if (hasAmmo)
                    {
                        ret.Add(i);
                    }
                }
            }
        }
        return(ret);
    }