IEnumerator Liquefying() { if (isLiquid || m_animator.GetCurrentAnimationClipState(0)[0].clip.name.Contains("liquid")) { yield break; } isLiquid = true; m_animator.SetBool("Liquefy", isLiquid); yield return(new WaitForFixedUpdate()); float counter = 0f; while (isLiquid) { counter += Time.deltaTime; if (!coolDown.Expend(amountExpendLiquid) || //caso acabe o cooldown. (Input.GetKeyDown(Button.Up) || Input.GetKeyDown(Button.Jump)) || //Caso o jogador pressione para cima ou pulo. (Input.GetKeyUp(Button.Down) && counter < 0.8f) ) { if (!ObstacleAbove) { isLiquid = false; m_animator.SetBool("Liquefy", isLiquid); } } yield return(null); } }
void Update() { // bool cache_inGround = GroundBelow (); // if(inGround != cache_inGround) // { // if(cache_inGround) // { // isJumping = false; // Debug.Log("Triggou o InGround"); // m_animator.SetTrigger("InGround"); // Cooldown.canRecupair = true; // } // else if (!inWater) // Cooldown.canRecupair = false; // } // inGround = cache_inGround; if (inGround != GroundBelow()) { inGround = GroundBelow(); if (!inWater) { Cooldown.canRecupair = inGround; } if (inGround) { isJumping = false; m_animator.SetTrigger("InGround"); } else { m_animator.ResetTrigger("InGround"); } } if (!canMove) { m_animator.SetBool("Move", false); m_animator.SetBool("Float", false); m_animator.SetBool("Glide", false); return; } if (!inWater) { if (inFall && !inGround && Input.GetKey(Button.Glide) && coolDown.Expend(amountEnergyGlide)) { m_rigidbody.gravityScale = gravityInGlide; m_animator.SetBool("Glide", true); } else if (m_rigidbody.gravityScale != normalGravity) { m_rigidbody.gravityScale = normalGravity; m_animator.SetBool("Glide", false); } else { // if(Input.GetKeyDown(Button.Float) && !inGround){ // isFloating = true; // m_animator.SetBool("Float", isFloating); // } // else if (inGround || (isFloating && !Input.GetKey(Button.Float))){ // isFloating = false; // m_animator.SetBool("Float", isFloating); // } if (Input.GetKey(Button.Float) && !inGround && !upJumpButton) { timePressedJump += Time.deltaTime; if (timePressedJump > timeToFloat) { isFloating = true; m_animator.SetBool("Float", isFloating); } } else if (inGround || (isFloating && !Input.GetKey(Button.Float))) { timePressedJump = 0f; isFloating = false; m_animator.SetBool("Float", isFloating); } if (Input.GetKeyDown(Button.Jump) && inGround && !isJumping && !m_animator.GetBool("Liquefy")) { isJumping = true; upJumpButton = false; StartCoroutine(Jump()); m_animator.SetTrigger("Jump"); } if (Input.GetKeyUp(Button.Jump)) { upJumpButton = true; } if (!inFall && m_rigidbody.velocity.y < -1f && !inGround) { inFall = true; m_animator.SetBool("Fall", inFall); } else if (inFall) { inFall = false; m_animator.SetBool("Fall", inFall); } } } }