void Update() { if (umbrellaOpen && !noToldo) { hp += Time.deltaTime * 2; } if (walkingOnWater) { hp += Time.deltaTime * 10; } playerDamage.currentDamage = (int)(100f - hp) / 10; if (hp >= 100) { IsDead(); } Debug.Log(hp); if (hp > 20 && cachorra == false) { cachorra = true; _SoundScript.MudaMusica(6, 1); } else if (hp > 70 & hp <= 20 && !cachorra1) { cachorra1 = true; _SoundScript.MudaMusica(3, 1); } else if (hp >= 70 && !cachorra2) { cachorra2 = true; _SoundScript.MudaMusica(6, 1); } // get movement value if (!isAttacking) { h = Input.GetAxis("Horizontal"); } if (this.anim.GetCurrentAnimatorStateInfo(1).IsName("Attack")) { h = 0; } if (h > 0 || h < 0) { if (!audioSource.isPlaying) { if (!walkingOnWater) { audioSource.PlayOneShot(walking); } else { audioSource.PlayOneShot(walkingOnPuddle); } } anim.SetBool("Running", true); } else if (/*h == 0 && Input.GetMouseButtonDown(0) || */ h == 0 && Input.GetKeyDown(KeyCode.C)) { anim.SetBool("Running", false); audioSource.Stop(); } else { anim.SetBool("Running", false); } if (h < 0 && facingRight) { facingRight = false; this.transform.Rotate(0, 180, 0); } else if (h > 0 && !facingRight) { facingRight = true; this.transform.Rotate(0, 180, 0); } #region GravityMechanics if (rbPlayer.velocity.y < -0.1) { isFalling = true; } else { isFalling = false; } // gravity if (gliding && jumping && isFalling) { rbPlayer.AddForce(new Vector3(0, -3.5f, 0), ForceMode.Force); } else if (isGrabbedOnWall) { rbPlayer.AddForce(Vector3.zero); } else { rbPlayer.AddForce(new Vector3(0, -15, 0), ForceMode.Force); } #endregion #region PlayerMovement // move player if (!grinding && !isGrabbedOnWall) { rbPlayer.transform.position += new Vector3(h, 0, 0) * speed * Time.deltaTime; } #endregion #region Jump // jump //if (!noToldo && umbrellaOpen) //{ if (Input.GetButtonDown("Jump") && !jumping && !isFalling) { anim.SetBool("Jumping", true); jumping = true; Invoke("Jump", 0.0f); } //} if (jumping) { audioSource.Stop(); } #endregion #region Glide // glide if ((Input.GetButton("Jump")) && !umbrellaOpen && jumping) { gliding = true; holder1.SetActive(false); holder2.SetActive(true); } else { // holder.transform.rotation = Quaternion.Euler(new Vector3(0, 0, 0)); gliding = false; holder1.SetActive(true); holder2.SetActive(false); } #endregion #region Grabbing // grabbing if (Input.GetKeyDown(KeyCode.Z)) { grabbing = true; } else { grabbing = false; } if (grabbing && touchingWallEdge) { isGrabbedOnWall = true; } if (isGrabbedOnWall) { GrabbedOnWall(); } anim.SetBool("GrabbingOnWall", isGrabbedOnWall); #endregion #region Grinding // griding if (canGrind && Input.GetKeyDown(KeyCode.E) && !grinding) { StartCoroutine(Grinding()); } if (!umbrella && Input.GetKeyDown(KeyCode.R)) { animUmbrella.SetBool("Open", true); umbrella = true; } if (umbrella && Input.GetKeyDown(KeyCode.R)) { animUmbrella.SetBool("Open", false); umbrella = false; } #endregion // Attack if (Input.GetButtonDown("Fire1") && umbrellaOpen && !isAttacking) { isAttacking = true; int rand = Random.Range(0, 11); if (rand < 3) { print(rand); audioSource.PlayOneShot(swoosh1); } else if (rand >= 3 && rand < 6) { print(rand); audioSource.PlayOneShot(swoosh2); } else { print(rand); audioSource. PlayOneShot(swoosh3); } anim.SetTrigger("Attack"); } if (Input.GetKeyDown(KeyCode.C)) { if (umbrellaOpen) { umbrellaOpen = false; changeUmbrella = false; audioSource.PlayOneShot(close); anim.SetBool("UmbrellaOpen", true ); openedUmbrella.SetActive(true); closedUmbrella.SetActive(false); animUmbrella.SetBool("Close", false); } else { animUmbrella.SetBool("Close", true); //float tempo = animUmbrella.GetCurrentAnimatorStateInfo(0).length; //if() //m_Animator.GetCurrentAnimatorStateInfo(0).IsName("Jump") if (changeUmbrella) { StartCoroutine(CloseUmbrella()); } umbrellaOpen = true; } } }