public void AddSeedToInventoryFromIndex(int plantIndex) { if (NbOfSeeds == 0) { selectedIndexInInventory = 0; } int index = -1; for (int i = 0; i < inventory.Count; i++) { if (inventory [i].plantSeedIndexInPlantManager == plantIndex) { index = i; inventory [i] = new PlantSeedInventory(inventory [i].plantSeedIndexInPlantManager, inventory [i].number + 1); print(inventory [i].number); //print ("found a slot :" + i); } } if (index == -1) { //print ("new slot"); inventory.Add(new PlantSeedInventory(plantIndex, 1)); } if (isLocalPlayer) { CanvasManager.cm.seedSelectionWheel.AddSeed(index); } }
public void SetPlantSeed(PlantSeedInventory plantSeed) { seedTexture.texture = GameManager.gm.pm.plantInformations[plantSeed.plantSeedIndexInPlantManager].plantTexture; Debug.Log("COUNT PLANTS : " + GameManager.gm.pm.plantsPrefabs.Count); string pName = GameManager.gm.pm.plantInformations[plantSeed.plantSeedIndexInPlantManager].plantName; plantName.text = pName; plantNumber.text = plantSeed.number < 2 ? "" : plantSeed.number.ToString(); }
public void UseSeed() { inventory [selectedIndexInInventory] = new PlantSeedInventory(inventory [selectedIndexInInventory].plantSeedIndexInPlantManager, inventory [selectedIndexInInventory].number - 1); if (inventory [selectedIndexInInventory].number == 0) { inventory.RemoveAt(selectedIndexInInventory); selectedIndexInInventory = Mathf.Min(selectedIndexInInventory, NbOfSeeds - 1); if (isLocalPlayer) { CanvasManager.cm.seedSelectionWheel.UseSeed(selectedIndexInInventory, true); } } else { if (isLocalPlayer) { CanvasManager.cm.seedSelectionWheel.UseSeed(selectedIndexInInventory, false); } } }