Exemplo n.º 1
0
 public int GetCountOfItem(Globals.product item)
 {
     if (witchsCoffer.ContainsKey(item))
     {
         return(witchsCoffer[item]);
     }
     return(0);
 }
Exemplo n.º 2
0
 //This is not a very optimal way of handling the witchhut inventory...
 void CreateItemPile(Vector2 location, Globals.product itemtype, int amount)
 {
     amount = (amount > 12)?12:amount;
     for (int i = 0; i < amount; ++i)
     {
         //Debug.Log("creating a " + itemtype);
         GameObject go = Instantiate(Resources.Load("PhysIngredient"), new Vector2(location.x + Random.Range(-.6f, .3f), location.y + Random.Range(-.3f, .3f)), Quaternion.identity) as GameObject;
         go.GetComponent <PhysicalIngredient>().InitializeIngredient(itemtype);
     }
 }
Exemplo n.º 3
0
 public void TallyIncomingGoods(Globals.product prod, int amt)
 {
     if (profit.ContainsKey(prod))
     {
         profit[prod] += amt;
     }
     else
     {
         profit.Add(prod, amt);
     }
 }
Exemplo n.º 4
0
 public void giveResourceBackToVillageCenter(Globals.product resource, int amount)
 {
     //checking if we have enough of said resource to give
     if (RemoveFromWitchesCoffer(resource, amount))
     {
         linkToVillageCenter.addResourceToStorage(resource, amount);
     }
     else
     {
         Debug.Log("Warning: trying to remove more resources than are stored in Witch's Coffer, cannot give back to VillageCenter");
     }
 }
Exemplo n.º 5
0
 public void addToWitchsCoffer(Globals.product resource, int amount)
 {
     //will add amount passed into witch's coffer
     if (!witchsCoffer.ContainsKey(resource))
     {
         //then we need to initialize it first with amount we want to add!
         witchsCoffer.Add(resource, amount);
     }
     else
     {
         //else, it exists in storage and we can add resource to resourceStorage, adding amount to add with current amount in storage
         witchsCoffer[resource] = amount + witchsCoffer[resource];
     }
 }
Exemplo n.º 6
0
 public bool RemoveFromWitchesCoffer(Globals.product resource, int amount)
 {
     //check first if resource has amount in storage
     if (witchsCoffer.ContainsKey(resource) && witchsCoffer [resource] >= amount)
     {
         //then we have enough to take the amount we want of said resource
         witchsCoffer[resource] -= amount;
         return(true);
     }
     else
     {
         //we either dont have enough of resource, or resource isn't contained (meaning we have 0 of said resource)...
         Debug.LogError("Error: attempting to take resource " + resource + " from Witch's Coffer, when none of said resource is stored");
         return(false);
     }
 }
Exemplo n.º 7
0
 public bool subtractResourceFromStorage(Globals.product resource, int amount)
 {
     //check first if resource has amount in storage
     if (resourceStorage.ContainsKey(resource) && resourceStorage [resource] >= amount && amount != 0)
     {
         //then we have enough to take the amount we want of said resource
         resourceStorage[resource] = resourceStorage[resource] - amount;
         //Debug.Log ("Successfully subtracted  " + amount + "x " + resource + " from VillageStorage!");
         return(true);
     }
     else
     {
         //we either dont have enough of resource, or resource isn't contained (meaning we have 0 of said resource)...
         //Debug.Log("Trying to subtract " + amount + "x "+ resource + " from VillageStorage, but there is not enough");
         return(false);
     }
 }
Exemplo n.º 8
0
    public void addResourceToStorage(Globals.product resource, int amount)
    {
        //check first if it is in the dictionary
        //if not, then add with amount = 0 then proceed to avoid error

        if (!resourceStorage.ContainsKey(resource))
        {
            //then we need to initialize it first with amount we want to add!
            resourceStorage.Add(resource, amount);
            //Debug.Log ("Successfully added " + amount + "x " + resource + " from VillageStorage! (From zero)");
        }
        else
        {
            //else, it exists in storage and we can add resource to resourceStorage, adding amount to add with current amount in storage
            resourceStorage[resource] = amount + resourceStorage[resource];
            //Debug.Log ("Successfully added " + amount + "x " + resource + " from VillageStorage!");
        }
    }
Exemplo n.º 9
0
    //could do it one one burst with items added, but then wouldn't have the proper colors tells.
    public void AddIngredient(Globals.product addedIngredient)
    {
        Debug.Log("added ingr: " + addedIngredient.ToString());
        if (!itemsAdded.ContainsKey(addedIngredient))
        {
            itemsAdded.Add(addedIngredient, 0);
        }
        itemsAdded[addedIngredient]++;

        foreach (Element e in IngredientToElementDictionary.Instance.ElementsFromIngredient(addedIngredient))
        {
            //Debug.Log("elem e consists of " + e.energyType + ", " + e.power);
            if (!energyStored.ContainsKey(e.energyType))
            {
                energyStored.Add(e.energyType, e.power);
            }
            else
            {
                energyStored[e.energyType] += e.power;
            }
        }
    }
Exemplo n.º 10
0
 public void InitializeIngredient(Globals.product _ingredient)
 {
     ingredient = _ingredient;
     SetIngredientGraphic();
 }
Exemplo n.º 11
0
 public List <Element> ElementsFromIngredient(Globals.product ingredient)
 {
     return(ingToElemDict[ingredient]);
 }
Exemplo n.º 12
0
 public void giveResourceToVillage(Globals.product resource, int amount)
 {
     //Debug.Log ("Giving Resources to Village: from " + biomeType + ".");
     //Debug.Log ("Adding: " + resource + " x" + amount + ".");
     center.addResourceToStorage(resource, amount);
 }
Exemplo n.º 13
0
 public void InitializeIngredient(Globals.product _ingredient)
 {
     ingredient = _ingredient;
     SetIngredientGraphic();
 }