public void addToInventory(Items.plants plant, int amount) { Items.plants p = null; bool found = false; if (plants.Count == 0) { plants.Add(plantcnt, list.clonePlant(plant)); plants[plantcnt].addAmount(amount); plantcnt++; } else { foreach (KeyValuePair <int, Items.plants> entry in plants) { if (entry.Value.getID() == plant.getID() && !found) { p = entry.Value; found = true; } } if (found) { p.addAmount(amount); } else { plants.Add(plantcnt, list.clonePlant(plant)); plants[plantcnt].addAmount(amount); plantcnt++; } } }
public void setPlant(Items.plants plantToSet) { plant = items.clonePlant(plantToSet); var rend = gameObject.GetComponent <Renderer>(); rend.material = plantTex; planted = true; seed = null; }