void OnMouseDown() { if (thirdPersonUserControl.isInsideVegetablePickUpZone) { string objectName = (this.gameObject.name.Remove(0, this.gameObject.name.Length - 1)); char charToBeAdded = objectName [0]; if (thirdPersonUserControl.rawVegetables.Count < maxNumberOfVegetablesPlayerCanCarry) { if (!thirdPersonUserControl.rawVegetables.Contains(charToBeAdded)) { thirdPersonUserControl.rawVegetables.Add(charToBeAdded); } else { thirdPersonUserControl.rawVegetables.Remove(charToBeAdded); } if (thirdPersonUserControl.rawVegetables.Count == 0) { thirdPersonUserControl.rawVegetableHUD.SetActive(false); } else { thirdPersonUserControl.rawVegetableHUD.SetActive(true); thirdPersonUserControl.SetHUD(); } } else if (thirdPersonUserControl.rawVegetables.Count == maxNumberOfVegetablesPlayerCanCarry) { if (thirdPersonUserControl.rawVegetables.Contains(charToBeAdded)) { thirdPersonUserControl.rawVegetables.Remove(charToBeAdded); } if (thirdPersonUserControl.rawVegetables.Count == 0) { thirdPersonUserControl.rawVegetableHUD.SetActive(false); } else { thirdPersonUserControl.rawVegetableHUD.SetActive(true); thirdPersonUserControl.SetHUD(); } } } }
IEnumerator StartChopping() { choppingTime = Time.time + 0.5f; for (int index = 0; index < thirdPersonUserControl.rawVegetables.Count; index++) { vegetableBeingChopped = thirdPersonUserControl.rawVegetables [index]; thirdPersonUserControl.choppedVegetables += thirdPersonUserControl.rawVegetables [index] + ","; yield return(new WaitForSeconds(choppingTimePerVegetable)); } isVegetableChopping = false; thirdPersonUserControl.rawVegetables.Clear(); thirdPersonUserControl.SetHUD(); thirdPersonUserControl.rawVegetableHUD.SetActive(false); choppingTextObject.SetActive(false); thirdPersonUserControl.choppedVegetablesHUD.SetActive(true); thirdPersonUserControl.choppedVegetablesText.text = thirdPersonUserControl.choppedVegetables; }