コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        if (GameManager.CurrentState == GameManager.State.gameplay)
        {
            if (!paralyzed)
            {
                if (!playerRepairState.IsRepairing())
                {
                    if (Input.GetButtonDown(Flap))
                    {
                        playerMovement.Flap();
                        playerAnimator.Flap();
                    }

                    if (Input.GetButtonDown(Grab))
                    {
                        bool dropLog;
                        if (playerRepairState.CanStartRepairing(PlayerHasLog(), out dropLog))
                        {
                            if (dropLog)
                            {
                                playerGrabbing.ToggleGrabRelease(true);
                            }

                            playerRepairState.StartRepairing(playerGrabbing.GiveLog());
                        }
                        else
                        {
                            playerGrabbing.ToggleGrabRelease();
                        }
                    }

                    Vector2 direction = Vector2.one;
                    direction.x = Input.GetAxis(Horizontal);
                    direction.y = Input.GetAxis(Vertical);

                    playerMovement.AdjustDirection(direction);
                }
            }
            else
            {
                paralyzeTime -= Time.deltaTime;

                if (paralyzeTime <= 0)
                {
                    paralyzed = false;
                }
            }

            playerAnimator.IsGrabbing(PlayerHasLog());
            playerAnimator.IsRepairing(playerRepairState.IsRepairing());
        }
    }