Exemplo n.º 1
0
    private void Update()
    {
        if (!m_jumpInput && Input.GetKey(KeyCode.Space))
        {
            m_jumpInput = true;
        }

        GetFishingInputs();

        if (Input.GetKeyDown(KeyCode.K))
        {
            print("FIXED UPDATE: K pressed");
            if (state == State.BOAT)
            {
                print("Starting transition to Land");

                previousState = state;
                state         = State.LAND;
                ToggleCharacters();
                //print("current: " + state);
                //print("previousState: " + previousState);

                StartCoroutine(FadeOut());
                StartCoroutine(FadeIn());
            }

            else if (state == State.LAND)
            {
                print("Starting transition to Boat");

                previousState = state;
                state         = State.BOAT;
                ToggleCharacters();
                //print("current: " + state);
                //print("previousState: " + previousState);

                StartCoroutine(FadeOut());
                StartCoroutine(FadeIn());
            }
        }

        if (Input.GetKeyDown(KeyCode.P))
        {
            if (state == State.MAP)
            {
                state = previousState;
            }

            else
            {
                previousState = state;
                state         = State.MAP;
            }
        }

        switch (state)
        {
        case State.LAND:
            boatController.enabled = false;
            switch (m_controlMode)
            {
            case ControlMode.Direct:
                DirectUpdate();
                break;

            case ControlMode.Tank:
                TankUpdate();
                break;

            default:
                Debug.LogError("Unsupported state");
                break;
            }
            break;

        case State.BOAT:
            boatController.enabled = true;
            break;

        case State.FISHING:
            boatController.enabled = false;
            if (!fishingRod.GetIsBobberCast())
            {
                switch (m_controlMode)
                {
                case ControlMode.Direct:
                    DirectUpdate();
                    break;

                case ControlMode.Tank:
                    TankUpdate();
                    break;

                default:
                    Debug.LogError("Unsupported state");
                    break;
                }
            }
            Fish();
            break;
        }
        m_wasGrounded = m_isGrounded;
        m_jumpInput   = false;
    }