public bool HasResources(CraftingRequirements resource)
        {
            var found = true;

            foreach (var item in resource.resourcesRequirements)
            {
                if (_numResources.ContainsKey(item.type))
                {
                    if (_numResources[item.type] < item.number)
                    {
                        found = false;
                    }
                }
                else
                {
                    found = false;
                }
            }

            if (found)
            {
                foreach (var item in resource.resourcesRequirements)
                {
                    _numResources[item.type] -= item.number;
                }
            }
            return(found);
        }
示例#2
0
        public void Config_SetResourceRequirements()
        {
            List <CraftingMap> defaultListRequirements = shopCraftingSystemBehaviour.system.craftingSubSubSystem.craftingRequirement;
            List <CraftingMap> newListRequirements     = new List <CraftingMap>();

            foreach (CraftingMap craftingMap in defaultListRequirements)
            {
                CraftingChoice newCraftingChoice = craftingMap.choice;

                UsableItem newResultingItem  = craftingMap.resource.resultingItem;
                float      newTimeToCreation = craftingMap.resource.timeToCreation;
                List <ResourceRequirement> newResourcesRequirements = new List <ResourceRequirement>();
                foreach (ResourceRequirement resourceRequirement in craftingMap.resource.resourcesRequirements)
                {
                    CraftingResources newType = resourceRequirement.type;
                    int newNumber             = UnityEngine.Random.Range(1, 10);
                    newResourcesRequirements.Add(new ResourceRequirement(newType, newNumber));
                }

                CraftingRequirements newCraftingRequirements = new CraftingRequirements
                {
                    resultingItem         = newResultingItem,
                    timeToCreation        = newTimeToCreation,
                    resourcesRequirements = newResourcesRequirements
                };

                CraftingMap newCraftingMap = new CraftingMap
                {
                    choice   = newCraftingChoice,
                    resource = newCraftingRequirements
                };

                newListRequirements.Add(newCraftingMap);
            }

            configSystem.SetResourceRequirements(newListRequirements);

            Assert.AreEqual(shopCraftingSystemBehaviour.system.craftingSubSubSystem.craftingRequirement, newListRequirements);
            Assert.AreNotEqual(defaultListRequirements, newListRequirements);
        }
 public CraftableItemDefinition(ItemDefinition item, CraftingRequirements craftingRequirements)
 {
     Item = item;
     CraftingRequirements = craftingRequirements;
 }
示例#4
0
 public void AddResource(int aAmount, ref CraftingRequirements craftingRequirement)
 {
     craftingRequirement.AddResource(aAmount);
     //TODO
 }
示例#5
0
    public CraftingResourceIndicator CreateResourceRequirement(Item aResourceType, int craftingAmount, ref CraftingRequirements trackingRequirements)
    {
        CraftingResourceIndicator indicator = Instantiate(mIndicatorPrefab, this.transform);

        indicator.SetCraftingAmount(craftingAmount);
        indicator.SetResourceImage(aResourceType.ItemSprite);
        indicator.SetScale(aResourceType.spriteScale);
        mIndicators.Add(indicator);
        return(indicator);
    }