Exemple #1
0
    public IEnumerator TestMakeChoice1()
    {
        testObj_dispenser.Init("imaseed", 1, 2.5f, 0f);
        testObj_dispenser.DispenseNext();

        yield return(new WaitForSeconds(1.75f));

        Assert.IsTrue(testObj_dispenser.MakeChoice(true));
    }
    // This function is called each frame the game is waiting for input from the player.
    // When the player makes a choice, it plays appropriate animations and
    // records the metric event, and starts the choice wait coroutine.
    void WaitForPlayer()
    {
        if (Input.GetKeyDown(feedKey) || Input.GetKeyDown(trashKey))
        {
            // set the angle the plate should tilt to. Play monster eating animation & sound if applicable
            if (Input.GetKeyDown(feedKey))
            {
                monster.Play("Base Layer.monster_eat");
                sound.PlayDelayed(0.85f);
                tiltPlateTo = -33f;
            }
            else
            {
                tiltPlateTo = 33f;
            }

            // record the choice made
            mcMetric.recordEvent(new MemoryChoiceEvent(
                                     dispenser.choiceStartTime,
                                     new List <String>(dispenser.goodFoods),
                                     dispenser.currentFood,
                                     Input.GetKeyDown(feedKey),
                                     DateTime.Now
                                     ));

            // animate choice and play plate sound
            sound.PlayOneShot(plate_up);
            StartCoroutine(AnimateChoice(Input.GetKeyDown(feedKey) && !dispenser.MakeChoice(Input.GetKeyDown(feedKey))));
            gameState = GameState.TiltingPlate;
        }
    }
Exemple #3
0
    // When the trashchute detects a food GameObject, it will determine
    // whether the food was correctly discarded. The `recycleIcon` will
    // change to green or red based on the correct or incorrect decision.
    // Food GameObject gets deactivated and rotation reset.
    void OnTriggerEnter2D(Collider2D other)
    {
        recycleIcon.color = dispenser.MakeChoice(false) ? correct : incorrect;
        other.attachedRigidbody.velocity       = Vector2.zero;
        other.gameObject.transform.eulerAngles = Vector3.zero;
        other.gameObject.SetActive(false);
        sound.PlayDelayed(0f);

        StartCoroutine(WaitForIconIndicator());
    }
Exemple #4
0
 // When the monster eats the food GameObject, it will determine
 // whether the food was correctly feed. If incorrectly feed,
 // play the monster spiting animation and sound.
 void OnTriggerEnter2D(Collider2D other)
 {
     if (dispenser.MakeChoice(true))
     {
         other.attachedRigidbody.velocity       = Vector2.zero;
         other.gameObject.transform.eulerAngles = Vector3.zero;
         other.gameObject.SetActive(false);
     }
     else
     {
         anim.Play("Base Layer.monster_spit");
         sound.PlayDelayed(0.2f);
         StartCoroutine(MonsterSpit(other.attachedRigidbody));
     }
 }