private void Jump() { if (!Input.GetButtonDown("Jump")) { myAnimator.SetBool("Jumping", false); return; } if (isGrounded) { myRigidBody.velocity = new Vector3(myRigidBody.velocity.x, jumpHeight, myRigidBody.velocity.z); jumpSFX.audioSource.pitch = 1.0f; jumpSFX.PlayRandomSfx(); myAnimator.SetBool("Jumping", true); } else if (doubleJump) { myRigidBody.velocity = new Vector3(myRigidBody.velocity.x, jumpHeight, myRigidBody.velocity.z); doubleJump = false; jumpSFX.audioSource.pitch = Random.Range(1.1f, 1.2f); jumpSFX.PlayRandomSfx(); myAnimator.SetBool("Jumping", true); } }
private bool GroundChecker() { myAnimator.SetBool("Landing", false); Vector3 checkBoxOrigin = new Vector3(transform.position.x, transform.position.y - jumpCheckOffset, transform.position.z); Collider[] colliders = Physics.OverlapBox(checkBoxOrigin, transform.localScale / 2.1f, Quaternion.Euler(Vector3.down)); if (colliders.Length <= 0) { return(false); } for (int i = 0; i < colliders.Length; i++) { for (int s = 0; s < tagsToJumpOn.Length; s++) { if (colliders[i].CompareTag(tagsToJumpOn[s])) { if (!isGrounded) { myAnimator.SetBool("Landing", true); landSFX.PlayRandomSfx(); } return(true); } } } return(false); }
private void Shoot() { Timer(); if (timer < shootingTimer) { return; } timer -= shootingTimer; myAnimator.SetBool("Shooting", true); GameObject cannonBall = Instantiate(cannonBallPrefab, transform.position + (transform.forward * spawnOffset), Quaternion.identity) as GameObject; if (hasRandomAim) { Vector3 randomAim = new Vector3(Random.Range(randomAimMinMaxX.x, randomAimMinMaxX.y), (Random.Range(randomAimMinMaxY.x, randomAimMinMaxY.y)), 0); cannonBall.GetComponent <CannonBall>().SetCannonBall(ballLifetime, ballSpeed, transform.forward + randomAim, pipe); } else { cannonBall.GetComponent <CannonBall>().SetCannonBall(ballLifetime, ballSpeed, transform.forward, pipe); } particlesSmoke.Play(); particlesFire.Play(); fireCannonSFX.PlayRandomSfx(); }
public void GruesomeDeath() { playerBody.isKinematic = true; playerMovement.isDead = true; playerGFX.SetActive(false); playerCollider.enabled = false; cinemachineFreeLookCam.Follow = null; cinemachineFreeLookCam.LookAt = null; gruesomeDeathSFX.PlayRandomSfx(); Instantiate(bloodSplatterFX, transform.position, transform.rotation); StartCoroutine("RestartLevel", timeToReloadLevel); MusicManager.Instance.PlayGameOverMusic(); }