示例#1
0
    // Update is called once per frame
    void Update()
    {
        // ActivateRage();
        //  triggerWaterScene();
        UpdateUI();
        row();
        //EnragedJump();

        if (_stopActions == false)
        {
            if (Input.GetButtonDown("Fire1") && hasClub == true && _isSwimming == false)
            {
                _anim.Attack();

                int randSound = Random.Range(1, 3);
                switch (randSound)
                {
                case 1:
                    PlayAudio(audioStorage._woosh_1, 0.15f);
                    break;

                case 2:
                    PlayAudio(audioStorage._woosh_2, 0.15f);
                    break;

                default:
                    print("Randomizer selected a non-existant sound option.");
                    break;
                }
            }


            maxSpeed       = 5;
            targetVelocity = new Vector2(Input.GetAxis("Horizontal") * maxSpeed, 0);
            _anim.Move(Mathf.Abs(Input.GetAxis("Horizontal")));

            if (Input.GetAxis("Horizontal") < 0)
            {
                transform.localScale = new Vector3(-1, 1, 1);
            }
            else if (Input.GetAxis("Horizontal") > 0)
            {
                transform.localScale = new Vector3(1, 1, 1);
            }
            if (Input.GetButtonDown("Jump") && isRaging == false && grounded)
            {
                velocity.y = jumpPower;
                _anim.Jump(true);
                StartCoroutine(ResetJumpCoroutine());
                enragedJumpBool = true;
            }

            if (Input.GetButtonDown("Jump") && isRaging == true)
            {
                jumpCount++;
                if (jumpCount == 0)
                {
                    velocity.y = jumpPower;
                    _anim.Jump(true);
                    StartCoroutine(ResetJumpCoroutine());
                    enragedJumpBool = true;
                }
                else if (jumpCount <= 1)
                {
                    velocity.y = jumpPower;
                    _anim.Jump(true);
                    StartCoroutine(ResetJumpCoroutine());
                    enragedJumpBool = true;
                    jumpCount++;
                }
            }
            if (grounded)
            {
                jumpCount = 0;
            }

            if (hasClub == true && clubCinematic == true)
            {
                _scene.FoundClub();
                _helpLevel = 1;
                _eventManager.UpdateHelpText(_helpLevel);
                _eventManager.FoundClub();
                clubCinematic = false;
            }
        }

        if (_stopActions)
        {
            targetVelocity = new Vector2(Input.GetAxis("Horizontal") * 0, 0);
            _anim.Idle(0);
        }
    }