Ejemplo n.º 1
0
    private void setUtensils()
    {
        List <CookingUtensil> cs = CatfePlayerScript.script.activeRestaurant.data.utensils;

        UpgradesFinishedButton.SetActive(true);
        //set each kitchen utensil based on what the restaurant has
        if (cs != null && cs.Count > 0)
        {
            for (int i = 0; i < cs.Count; i++)
            {
                //if for some reason too much is saved, make sure we only go through possible things
                if (i >= utensilLine.transform.childCount)
                {
                    i = cs.Count;
                }
                else
                {
                    CookingUtensilScript u = utensilLine.transform.GetChild(i).gameObject.GetComponent <CookingUtensilScript>();
                    u.utensil = cs[i];
                    //getting the right sprite to show
                    if (cs[i].upgradeNum > 3)
                    {
                        cs[i].upgradeNum = 3;
                    }
                    u.SetSprite(GetCookingUtenSprite(cs[i].utensil, cs[i].upgradeNum));
                    u.PickUpPlate();
                }
            }
        }
        //if there are no utensils, use the default ones, a knife and a stove
        else
        {
            CookingUtensilScript u = utensilLine.transform.GetChild(0).gameObject.GetComponent <CookingUtensilScript>();
            u.utensil = new CookingUtensil(CookingTools.Knife);
            u.SetSprite(GetCookingUtenSprite(CookingTools.Knife, 0));
            cs.Add(u.utensil);
            u.PickUpPlate();

            u         = utensilLine.transform.GetChild(1).gameObject.GetComponent <CookingUtensilScript>();
            u.utensil = new CookingUtensil(CookingTools.Stove);
            u.SetSprite(GetCookingUtenSprite(CookingTools.Stove, 0));
            cs.Add(u.utensil);
            u.PickUpPlate();
        }
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (currentState == State.finished)
        {
            Reset();
        }
        else if (currentState != State.gameplay && Input.GetMouseButtonDown(0))
        {
            Vector2    mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            Collider2D hit      = Physics2D.Raycast(mousePos, Vector2.up).collider;
            if (hit)
            {
                //access the utensil and check if the player wants to upgrade it
                if (currentState == State.upgrades)
                {
                    if (hit.tag == "utensil")
                    {
                        //will go into choosing to upgrade or not on the popup

                        /*currentState = State.popup;
                         * setPopUp(true);
                         * curUtensil = hit;
                         */
                    }
                }
                if (currentState == State.popup)
                {
                    //don't want to buy the upgrade
                    if (hit.tag == "noButton")
                    {
                        currentState = State.upgrades;
                        setPopUp(false);
                    }
                    else if (hit.tag == "yesButton")
                    {
                        currentState = State.upgrades;
                        if (PlayerData.playerData.playerMoney >= curUtensil.GetUpgradeCost())
                        {
                            curUtensil.Upgrade();
                            curUtensil = null;
                        }
                        else
                        {
                            Debug.Log("not enough money!");
                        }
                        setPopUp(false);
                    }
                }
            }
        }
        else if (currentState == State.gameplay && DateTime.Compare(DateTime.Now, minigameEndTime) > 0)
        {
            minigameTimeLeft.text = "time up!";
            currentState          = State.finished;
            Pause();
            minigameItems.SetActive(false);
            CatfePlayerScript.script.EnterRestaurant();
        }
        else if (currentState == State.gameplay)
        {
            TimeSpan timeLeft = minigameEndTime.Subtract(DateTime.Now);
            minigameTimeLeft.text = "min: " + timeLeft.Minutes + " sec: " + timeLeft.Seconds;
        }
    }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Vector2      mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            RaycastHit2D hit      = Physics2D.Raycast(mousePos, Vector2.up);
            if (hit.collider)
            {
                Vector3 loc = hit.collider.transform.position;
                if (hit.collider.tag == "ingredients")
                {
                    hit.collider.GetComponent <IngredientBoxScript>().OnClick();
                    m_locations.Enqueue(new Vector3(loc.x, loc.y + 2, loc.z));
                }
                else if (hit.collider.tag == "customer")
                {
                    hit.collider.GetComponent <Customer>().OnClick();
                }
            }
        }
        //setting the player to move if there is only one location to go to
        if (!m_needsToMove && m_locations.Count >= 1)
        {
            m_nextLocation = m_locations.Dequeue();
            m_needsToMove  = true;
        }

        //if enough time has passed, put the next item in the queue into the player's hand
        if (!m_needsToMove && m_playerQueue.Count > 0)
        {
            if (m_locations.Count > 0)
            {
                m_nextLocation = m_locations.Dequeue();
                m_needsToMove  = true;
            }
            //putting the ingredient into the player's hand
            if (m_playerQueue.Peek().GetType() == typeof(Ingredients))
            {
                m_itemsInHand.Add((Ingredients)m_playerQueue.Dequeue());
            }
            //"using" the kitchen utensil.  must check if the recipe exists
            else if (m_playerQueue.Peek().GetType() == typeof(CookingUtensilScript))
            {
                CookingUtensilScript tool = (CookingUtensilScript)m_playerQueue.Dequeue();

                //if there is a plate for us to pick up.
                if (tool.HasPlate())
                {
                    //can only pick up the plate if there is no other plate in our hand
                    if (m_plateInHand == null)
                    {
                        //we picked up a plate
                        ChangePlateInHand(tool.PickUpPlate());
                    }
                }
                //if no plate, we will place the recipe as long as we have items to cook and there is nothing on the stove
                else if (m_itemsInHand.Count > 0)
                {
                    Recipe r = GetRecipe(m_itemsInHand.ToArray(), tool.utensil.utensil);

                    //either putting a recipe in or finding what we should get from clicking on the utensil
                    tool.Loading(PlayerData.GetFoodSprite(r.recipeName), r);

                    m_itemsInHand.Clear();
                }
            }
            //clicked on a customer
            else
            {
                Customer c = CustomerGenerator.GetCustomer((int)m_playerQueue.Dequeue());
                GivePlateToCustomer(c.GetOrder(), c.GetCustomerNumber());
            }
        }

        if (m_needsToMove)
        {
            Vector3 catPos = transform.position;
            if (catPos == m_nextLocation)
            {
                m_needsToMove = false;
            }
            else
            {
                transform.position = Vector3.MoveTowards(catPos, m_nextLocation, 0.2f);
            }
        }
    }
Ejemplo n.º 4
0
 public void UtensilUpgradeClicked(CookingUtensilScript c)
 {
     currentState = State.popup;
     setPopUp(true);
     curUtensil = c;
 }
Ejemplo n.º 5
0
 public static void AddCookingToolToPlayerQueue(CookingUtensilScript c)
 {
     m_playerQueue.Enqueue(c);
 }