示例#1
0
    //Show's the victory-screen or generates a new price and moves the coins off-screen
    IEnumerator _CorrectPayment()
    {
        CorrectAnswer = true;
        yield return(new WaitForSeconds(1));

        Audio.PlayOneShot(Correct);
        Lamps.Flicker();

        #region Close drawer
        while (Drawer.position != Closed.position)
        {
            Drawer.position = Vector3.MoveTowards(Drawer.position, Closed.position, Time.deltaTime * 6);
            yield return(null);
        }
        #endregion

        Empty();
        Rounds--;
        if (Rounds == 0)
        {
            CorrectAnswer = false;
            yield return(new WaitForSeconds(0.5f));

            Win();
        }
        else
        {
            #region Generate new price
            yield return(new WaitForSeconds(0.25f));

            StartCoroutine(_GeneratePrice());
            yield return(new WaitForSeconds(0.8f));

            Lamps.Stop();
            yield return(new WaitForSeconds(0.25f));

            #endregion

            CorrectAnswer = false;

            #region Open drawer
            Audio.PlayOneShot(Drag);
            while (Drawer.position != Opened.position)
            {
                Drawer.position = Vector3.MoveTowards(Drawer.position, Opened.position, Time.deltaTime * 6);
                yield return(null);
            }
            #endregion
        }
    }