void OnMouseDown()
        {
            if (!base.CanGoPlayerSlot())
            {
                return;
            }

            if (AddToPlateBeforeServed)
            {
                var plate = GameObject.Instantiate(platePrefab, transform.position, Quaternion.identity);
                plate.transform.SetParent(transform);
                if (plateOffset.magnitude > 0)
                {
                    plate.transform.localPosition = plateOffset;
                }
                plate.transform.SetAsFirstSibling();//so we know what to delete later
            }
            if (RegenerateProduct)
            {
                //Remove the plate first
                if (AddToPlateBeforeServed)
                {
                    Destroy(transform.GetChild(0).gameObject);
                }
                BasicGameEvents.RaiseInstantiatePlaceHolder(transform.parent, transform.position, gameObject);
            }
            StartCoroutine(AnimateGoingToSlot());
        }
 public virtual bool CanGoPlayerSlot()
 {
     var PlayerSlots = FindObjectOfType<PlayerSlots>();
     if (PlayerSlots.CanHoldItem(orderID))
     {
         BasicGameEvents.RaiseOnProductAddedToSlot(orderID);
         return true;
     }
     else
         return false;
 }
        public override IEnumerator AnimateGoingToSlot()
        {
            if (RegenerateProduct)
            {
                BasicGameEvents.RaiseInstantiatePlaceHolder(transform.parent, initialPosition, gameObject);
            }
            yield return(new WaitForSeconds(cookingObject.doorAnimTime));

            yield return(base.AnimateGoingToSlot());

            gameObject.SetActive(false);
        }
Example #4
0
        public void OrderCompleted()
        {
            //We completed the order,
            //For demo purposes we will just calculate our success based on the serve-time we got
            float success = curServeTime / totalServingTime;

            //we could of course calculate this on various parameters affecting
            //this success value i.e. cooking amount, speed, combo multiplier,
            //combo multipliers of same product in a row or customer happiness

            BasicGameEvents.RaiseOnOrderCompleted(orderID, success);
            StartCoroutine(DoEmphasize());
        }
        void AddToPlayerSpot()
        {
            var PlayerSlots = FindObjectOfType <PlayerSlots>();
            var product     = GetComponent <DrinkableProduct>();

            if (product != null && PlayerSlots != null)
            {
                if (PlayerSlots.CanHoldItem(product.orderID))
                {
                    BasicGameEvents.RaiseOnProductAddedToSlot(product.orderID);
                    StartCoroutine(product.AnimateGoingToSlot());
                }
            }
            else
            {
                Destroy(gameObject);
            }
        }
        public override IEnumerator AnimateGoingToSlot()
        {
            if (RegenerateProduct)
            {
                //Remove the plate first
                if (AddToPlateBeforeServed)
                {
                    Destroy(transform.GetChild(0).gameObject);
                }
                else if (serveAsDifferentGameObject != null)
                {
                    //Remove the served as Different gameobject first
                    Destroy(transform.GetChild(0).gameObject);
                }
                BasicGameEvents.RaiseInstantiatePlaceHolder(transform.parent, initialPosition, gameObject);
            }
            yield return(base.AnimateGoingToSlot());

            gameObject.SetActive(false);
        }
Example #7
0
 private void OnMouseDown()
 {
     if (!doorIsOpen && !isEmpty)
     {
         var PlayerSlots = FindObjectOfType <PlayerSlots>();
         if (PlayerSlots.CanHoldItem(currentProduct.orderID))
         {
             BasicGameEvents.RaiseOnProductAddedToSlot(currentProduct.orderID);
             StartCoroutine(currentProduct.AnimateGoingToSlot());
             currentProduct = null;
             StartCoroutine(PlayDoorAnim(true, true));
         }
         else
         {
             return;
         }
     }
     else if (isEmpty)
     {
         StartCoroutine(PlayDoorAnim(true, true));
     }
 }
 public void DeletePlayerSlotImage()
 {
     ToggleDeleteMode();
     GetComponent <Image>().sprite = null;
     BasicGameEvents.RaiseOnProductDeletedFromSlot(SlotIndex);
 }
Example #9
0
 public void CancelOrder()
 {
     BasicGameEvents.RaiseOnOrderCancelled(orderID);
     //Order is canncelled so destroy the UI object.
     Destroy(gameObject);
 }