Exemplo n.º 1
0
    IEnumerator GetToFloor()
    {
        foreach (char c in InputInfo.InputString)
        {
            if (c == '(')
            {
                if (!santaScript.facingRight)
                {
                    santaScript.Flip();
                }
                yield return(new WaitForSeconds(0.5f));

                santaAnim.SetTrigger("Jump");
                santaRb2d.AddForce(new Vector2(300, 700));
                yield return(new WaitForSeconds(1.5f));

                santaScript.Disappear();
                santa.transform.position = new Vector2(-4f, -2.97f);
                yield return(new WaitForSeconds(0.5f));

                santaScript.Appear();
                yield return(new WaitForSeconds(0.5f));

                santaAnim.SetTrigger("Jump");
                santaRb2d.AddForce(new Vector2(320, 700));
                yield return(new WaitForSeconds(1));

                santa.transform.position = new Vector2(0, 0);
                floorNumber++;
            }
            if (c == ')')
            {
                if (santaScript.facingRight)
                {
                    santaScript.Flip();
                }
                yield return(new WaitForSeconds(0.5f));

                santaAnim.SetTrigger("Jump");
                santaRb2d.AddForce(new Vector2(-470, 0));
                yield return(new WaitForSeconds(1.5f));

                santaScript.Disappear();
                santa.transform.position = new Vector2(4f, 2.8f);
                yield return(new WaitForSeconds(0.5f));

                santaScript.Appear();
                yield return(new WaitForSeconds(0.5f));

                santaAnim.SetTrigger("Jump");
                santaRb2d.AddForce(new Vector2(-470, 0));
                yield return(new WaitForSeconds(1));

                santa.transform.position = new Vector2(0, 0);
                floorNumber--;
            }
            floorNumberText.text = floorNumber.ToString();
        }
        yield return(new WaitForSeconds(1));

        christmasTree1.SetActive(true);
        christmasTree2.SetActive(true);
    }