コード例 #1
0
ファイル: Plate.cs プロジェクト: mnnthomas/SaladChef
        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));
        }
コード例 #2
0
 /// <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;
     }
 }
コード例 #3
0
 private void DropVegetable(VegetableData veg)
 {
     Destroy(mVegetableObjectsInHand[0]);
     mVegetableObjectsInHand.RemoveAt(0);
     if (mVegetableObjectsInHand.Count > 0)
     {
         mVegetableObjectsInHand[0].transform.localPosition = Vector3.up * 1.5f;
     }
 }
コード例 #4
0
        /// <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;
        }
コード例 #5
0
 public void OnDropItem(object droppedItem, PlayerController droppedBy)
 {
     if (!_IsBusy)
     {
         VegetableData veg = droppedItem as VegetableData;
         if (veg != null)
         {
             _IsBusy        = true;
             mChopCoroutine = StartCoroutine("ChopVegetable", veg);
         }
     }
 }
コード例 #6
0
 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();
         }
     }
 }
コード例 #7
0
 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;
         }
     }
 }
コード例 #8
0
ファイル: TrashCan.cs プロジェクト: mnnthomas/SaladChef
        /// <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);
                }
            }
        }
コード例 #9
0
 private void OnDroppedItemInChoppingBoard(VegetableData veg)
 {
     DropVegetable(veg);
     mPauseCoroutine = StartCoroutine("PauseForSeconds", veg._CutDuration);
 }
コード例 #10
0
 public void AddIngredients(VegetableData vegData)
 {
     _Ingredients.Add(vegData);
 }