示例#1
0
    public bool areResourcesAvailable(List <Tuple <UsableObject, int> > resourceList)
    {
        foreach (Tuple <UsableObject, int> resourceTuple in resourceList)
        {
            UsableObject usableObject   = resourceTuple.Item1;
            int          quantityNeeded = resourceTuple.Item2;

            int quantityFound = 0;
            for (int i = 0; i < bankInventory.Length; i++)
            {
                if (bankInventory[i] != null)
                {
                    if (bankInventory[i].GetType().Equals(usableObject.GetType()))
                    {
                        quantityFound++;
                    }
                }
            }
            if (quantityFound < quantityNeeded)
            {
                return(false);
            }
        }
        return(true);
    }
示例#2
0
    public int getNumberOfObjectInBankInventory(UsableObject usableObject)
    {
        int numberInBank = 0;

        for (int i = 0; i < bankInventory.Length; i++)
        {
            if (bankInventory[i] != null)
            {
                if (bankInventory[i].GetType().Equals(usableObject.GetType()))
                {
                    numberInBank++;
                }
            }
        }

        return(numberInBank);
    }