private void PressKey() { if (Input.GetKeyDown(KeyCode.Space)) { hb.Jump(); } if (Input.GetKeyDown(KeyCode.Q)) { hb.Big(); } if (Input.GetKeyDown(KeyCode.E)) { hb.Small(); } if (Input.GetKeyDown(KeyCode.R)) { hb.Normal(); } if (Input.GetMouseButtonDown(0)) { hb.Activate(); } }
void CheckKeys() { float direction = Input.GetAxis("Horizontal"); heroBody.Move(direction); if (Input.GetKeyDown(KeyCode.Space)) { heroBody.Jump(direction); } if (canSlide) { if (Input.GetButtonDown("slide")) { if (direction > 0) { direction = 1; } else if (direction < 0) { direction = -1; } if (direction != 0) { heroBody.Slide(direction); canSlide = false; Invoke("CanSlideAgain", 0.7f); } } } if (!heroBody.onAir) { canGlide = true; } if (heroBody.onAir && canGlide && Input.GetButtonDown("slide")) { heroBody.Glide(); canGlide = false; } if (Input.GetButtonDown("swordAttack")) { if (canAttack) { heroBody.SwordAttack(); canAttack = false; Invoke("CanAttackAgain", 0.3f); } } if (Input.GetButtonDown("kunaiThrow")) { if (canShoot) { if (heroBody.onAir) { heroBody.AirKunaiThrow(); } else { heroBody.KunaiThrow(); } canShoot = false; Invoke("CanShootAgain", 0.7f); } } }