public void AddSaladIngredient(VegetableData veg) { _Salad.AddIngredients(veg); mCutVeg.Add(Instantiate(veg._CutObject, transform, true)); mCutVeg[mCutVeg.Count - 1].transform.position = transform.position + new Vector3(Random.Range(0, 0.25f), 0.1f * _Salad._Ingredients.Count, Random.Range(0, 0.25f)); }
/// <summary> /// Creates a one time instance of the vegetable in spawn area. /// </summary> private void InitVegetable() { mVegetable = GameManager.pInstance._VegetableConfig.GetVegetableByName(m_VegetableName); if (mVegetable != null && mVegetable._Object) { GameObject obj = Instantiate(mVegetable._Object, transform); obj.transform.position = m_SpawnTransform.position; } }
private void DropVegetable(VegetableData veg) { Destroy(mVegetableObjectsInHand[0]); mVegetableObjectsInHand.RemoveAt(0); if (mVegetableObjectsInHand.Count > 0) { mVegetableObjectsInHand[0].transform.localPosition = Vector3.up * 1.5f; } }
/// <summary> /// Creates a copy of dropped vegetable and Adds cut ingredient to plate after vegetable cut duration /// </summary> /// <param name="vegData">dropped vegetable data</param> /// <returns></returns> IEnumerator ChopVegetable(VegetableData vegData) { mVegObject = Instantiate(vegData._Object, transform, true); mVegObject.transform.position = transform.position + Vector3.up * 0.75f; yield return(new WaitForSeconds(vegData._CutDuration)); Destroy(mVegObject); m_Plate.AddSaladIngredient(vegData); _IsBusy = false; }
public void OnDropItem(object droppedItem, PlayerController droppedBy) { if (!_IsBusy) { VegetableData veg = droppedItem as VegetableData; if (veg != null) { _IsBusy = true; mChopCoroutine = StartCoroutine("ChopVegetable", veg); } } }
private void OnActionButtonClicked() { if (mCurCollider) { //Condition to check and pick item from VegetableSpawn if (mCurCollider.GetComponent <VegetableSpawn>() && mCanPickVegetable) { VegetableData pickedVeg = mCurCollider.GetComponent <IPickable>().PickItem() as VegetableData; if (pickedVeg != null) { OnVegetablePicked(pickedVeg); } } //Condition to drop a vegetable to chopping board else if (mCurCollider.GetComponent <ChoppingBoard>() && !mCurCollider.GetComponent <ChoppingBoard>()._IsBusy&& mSaladInHand == null && mVegetablesInHand.Count > 0) { OnDroppedItemInChoppingBoard(mVegetablesInHand.Peek()); mCurCollider.GetComponent <IDroppable>().OnDropItem(mVegetablesInHand.Dequeue(), this); } //Condition to drop an item to TrashCan else if (mCurCollider.GetComponent <TrashCan>()) { if (mVegetablesInHand.Count > 0) { DropVegetable(mVegetablesInHand.Peek()); mCurCollider.GetComponent <IDroppable>().OnDropItem(mVegetablesInHand.Dequeue(), this); } if (mSaladInHand != null) { mCurCollider.GetComponent <IDroppable>().OnDropItem(mSaladInHand, this); DropSalad(); } } //Condition to pick salad plate else if (mCurCollider.GetComponent <Plate>() && mCurCollider.GetComponent <Plate>().HasSalad() && mVegetableObjectsInHand.Count == 0 && mSaladInHand == null) { Salad pickedSalad = mCurCollider.GetComponent <IPickable>().PickItem() as Salad; if (pickedSalad != null) { mSaladObjectInHand = Instantiate(mCurCollider.GetComponent <Plate>().gameObject, transform, true); mSaladObjectInHand.transform.position = transform.position + Vector3.up; OnSaladPicked(pickedSalad.DeepCopy()); } } //Condition to deliver to customer else if (mCurCollider.GetComponent <Customer>() && mSaladInHand != null) { mCurCollider.GetComponent <IDroppable>().OnDropItem(mSaladInHand, this); DropSalad(); } } }
private void OnVegetablePicked(VegetableData veg) { mVegetablesInHand.Enqueue(veg); if (veg._Object) { mVegetableObjectsInHand.Add(Instantiate(veg._Object, transform)); if (mVegetablesInHand.Count == 1) { mVegetableObjectsInHand[0].transform.localPosition = Vector3.up * 1.5f; } else { mVegetableObjectsInHand[1].transform.localPosition = Vector3.up * 2.5f; } } }
/// <summary> /// Decides which item was dropped and calls events /// </summary> /// <param name="droppedItem">Salad/Vegetable dropped</param> /// <param name="droppedBy">Player who dropped</param> public void OnDropItem(object droppedItem, PlayerController droppedBy) { VegetableData veg = droppedItem as VegetableData; if (veg != null) { OnItemTrashed?.Invoke(droppedBy, m_VegetableTrashedScore); } else { Salad salad = droppedItem as Salad; if (salad != null) { OnItemTrashed?.Invoke(droppedBy, m_SaladTrashedScore); } } }
private void OnDroppedItemInChoppingBoard(VegetableData veg) { DropVegetable(veg); mPauseCoroutine = StartCoroutine("PauseForSeconds", veg._CutDuration); }
public void AddIngredients(VegetableData vegData) { _Ingredients.Add(vegData); }