Пример #1
0
    /**
     * Method to update the bird.
     **/
    private void Update()
    {
        switch (state)
        {
        default:
        case State.WaitingToStart:
            if (TestInput())
            {
                // Start playing
                state = State.Playing;
                birdRigidbody2D.bodyType = RigidbodyType2D.Dynamic;
                Jump();
                if (OnStartedPlaying != null)
                {
                    OnStartedPlaying(this, EventArgs.Empty);
                }
            }
            break;

        case State.Playing:
            if (TestInput())
            {
                Jump();
            }

            // Rotate bird as it jumps and falls
            transform.eulerAngles = new Vector3(0, 0, birdRigidbody2D.velocity.y * .15f);
            break;

        case State.Dead:
            break;

        case State.Question:
            if (Question != null)
            {
                Question(this, EventArgs.Empty);
            }
            if (Answers != null)
            {
                Answers(this, EventArgs.Empty);
            }
            if (waiting == false)
            {
                state = State.Playing;
                birdRigidbody2D.bodyType = RigidbodyType2D.Dynamic;
                questionWindow.Hide();
                answersWindow.Hide();
                waiting = true;
                if (OnStartedPlaying != null)
                {
                    OnStartedPlaying(this, EventArgs.Empty);
                }
            }
            break;

        case State.Feedback:
            if (Feedback != null)
            {
                Feedback(this, EventArgs.Empty);
            }
            if (waiting == false)
            {
                state = State.Playing;
                birdRigidbody2D.bodyType = RigidbodyType2D.Dynamic;
                feedbackWindow.Hide();
                waiting = true;
                wrongAnswer();
                if (wrongAnswer() == false)
                {
                    if (OnStartedPlaying != null)
                    {
                        OnStartedPlaying(this, EventArgs.Empty);
                    }
                }
                if (wrongAnswer() == true)
                {
                    if (OnDied != null)
                    {
                        OnDied(this, EventArgs.Empty);
                    }
                }
            }
            break;
        }
        aboveMap();
    }