private void Update() { // Jumping if (Input.GetKeyDown(KeyCode.Space) && isGrounded == true) // && isCrouch == false) { rigidbody2d.velocity = new Vector2(0f, 0f); rigidbody2d.AddForce(new Vector2(0f, jumpheight)); } // Attacking if (Input.GetKeyDown(KeyCode.X) && attack == false) { NormalAttack(); // Set to attack to true. attackTimer = attackCd; damagedealt = -25; // Checking if the knight is grounded to trigger specific attacks. if (isGrounded == true) { animation.SetTrigger("Attack"); } else { animation.SetTrigger("JumpAttack"); } } // Trigger Death if (currentHealth == 0) { isInvincible = true; // set invincibility frames. invincibleTimer = timeInvincible * 2; animation.SetTrigger("Death"); // trigger death. StartCoroutine("FadeDeath"); // fade away then respawn else where. // reset health and mana values. changeHealth(maxHealth); changeMana(maxMana); } // Reveal if (startTimerReveal == true) { startCooldownReveal -= Time.fixedDeltaTime; RevealUI.RevealBar.SetValue(startCooldownReveal / (float)cooldownReveal); durationTimer -= Time.fixedDeltaTime; if (startCooldownReveal <= 0f) { startTimerReveal = false; } if (durationTimer <= 0f) { reveal.SetActive(false); } } if (Input.GetKeyDown(KeyCode.D) && startTimerReveal == false) { reveal.SetActive(true); StartCoroutine("FadeReveal"); startTimerReveal = true; startCooldownReveal = cooldownReveal; durationTimer = durationReveal; } // Opening Gate (Reactivate when the player walks into the room and awakens the final boss) if (Input.GetKeyDown(KeyCode.S)) { RaycastHit2D gateHit = Physics2D.Raycast(transform.position + (Vector3.up * 0.4f), lookDirection, 1.0f, LayerMask.GetMask("Gate")); RaycastHit2D signHit = Physics2D.Raycast(transform.position + (Vector3.up * 0.2f), lookDirection, 1.0f, LayerMask.GetMask("Sign")); if (gateHit.collider != null) { GameObject gateTile = gateHit.collider.gameObject; if (Collectible.collected == 5) { gateTile.SetActive(false); torches.SetActive(false); } } if (signHit.collider != null) { Sign sign = signHit.collider.GetComponent <Sign>(); if (sign != null) { sign.DisplayDialog(); } } } // Crouch /* if (Input.GetKey(KeyCode.LeftControl) && isGrounded == true) * { * isCrouch = true; * rigidbody2d.velocity = Vector3.zero; // stop movement; * rigidbody2d.angularVelocity = 0; * } * else * { * isCrouch = false; * } * animation.SetBool("Crouch", isCrouch);*/ // Block if (Input.GetKeyDown(KeyCode.Z) && isInvincible == false && isGrounded == true) { animation.SetBool("Block", true); isInvincible = true; isBlock = true; invincibleTimer = Blocktime; } }