Ejemplo n.º 1
0
    IEnumerator OnMouseDown()
    {
        MemoryMatchGameManager manager = MemoryMatchGameManager.GetInstance();

        if (manager.inputAllowed && !isGuessing && (manager.isGameStarted() || manager.isRunningTutorial()))
        {
            isGuessing = true;

            OpenLid();
            manager.subtitlePanel.Display(myFood.name, myFood.clipOfName);

            if (manager.GetFoodToMatch().name != myFood.name)
            {
                if (!matched && !manager.isRunningTutorial())
                {
                    manager.SubtractTime(3.0f);
                }
                yield return(new WaitForSeconds(2f));

                CloseLid();
            }
            else
            {
                Correct();
                yield return(new WaitForSeconds(1.5f));

                manager.ChooseFoodToMatch();
            }

            //The player can now guess again.
            manager.subtitlePanel.Hide();
            isGuessing = false;
        }
    }
Ejemplo n.º 2
0
 public void Correct()
 {
     SoundManager.GetInstance().PlayCorrectSFX();
     if (!lid.activeSelf)
     {
         lid.SetActive(true);
     }
     dishAnim.Play("Dish_Correct");
     MemoryMatchGameManager.GetInstance().AddToMatchedList(myFood);
     matched = true;
 }
Ejemplo n.º 3
0
    /**
     * \brief OnMouseDown is called when the player clicks (or taps) one of the dishes.
     *
     * Check if this dish's myFood matches the foodToMatch. If it does match, deactivate
     * the top part of the dish permenanatly, otherwise, cover the food again.
     * @return WaitForSeconds for a delay.
     */
    IEnumerator OnMouseDown()
    {
        Animation animation = top.GetComponent <Animation>();

        if (!isGuessing && (MemoryMatchGameManager.GetInstance().isGameStarted() || MemoryMatchGameManager.GetInstance().isRunningTutorial()))
        {
            isGuessing = true;

            //Reveal the food underneath the dish by setting the sprite renderer to disabled.
            top.GetComponent <Animation>().Play(animation["DishTopRevealLift"].name);
            MemoryMatchGameManager.GetInstance().subtitlePanel.Display(myFood.name, myFood.clipOfName);

            if (MemoryMatchGameManager.GetInstance().GetFoodToMatch().name != myFood.name)
            {
                if (!matched)
                {
                    MemoryMatchGameManager.GetInstance().SubtractTime(3.0f);
                    yield return(new WaitForSeconds(2f));
                }

                top.GetComponent <Animation>().Play(animation["DishTopRevealClose"].name);
            }
            else
            {
                top.GetComponent <Animation>().Play(animation["DishTopRevealLift"].name);
                SoundManager.GetInstance().PlayCorrectSFX();
                MemoryMatchGameManager.GetInstance().AddToMatchedList(myFood);
                yield return(new WaitForSeconds(1.5f));

                top.GetComponent <SpriteRenderer>().enabled = false;
                matched = true;

                MemoryMatchGameManager.GetInstance().ChooseFoodToMatch();
            }
            //The player can now guess again.
            MemoryMatchGameManager.GetInstance().subtitlePanel.Hide();
            isGuessing = false;
        }
    }