void OnJellyCollisionEnter(JellyMesh.JellyCollision collision) { // if its not time to play another squelch yet, quit if (Time.time - timeLastPlayedSquelch < timeBetweenSquelches) { return; } // if above threshold to play squelch sound if (collision.Collision.relativeVelocity.magnitude > _playSquelchThreshold.x) { //Debug.Log("collision with velocity " + collision.Collision.relativeVelocity.magnitude); // calculate a force value from 0 - 1, 0 being the lower threshold and 1 being the upper threshold float soundForce = (collision.Collision.relativeVelocity.magnitude / _playSquelchThreshold.y) + (_playSquelchThreshold.x / _playSquelchThreshold.y); soundForce = Mathf.Clamp01(soundForce); PlaySquelchSound(soundForce); timeLastPlayedSquelch = Time.time; } }
void OnJellyCollisionEnter(JellyMesh.JellyCollision collision) { if (collision.Collision.gameObject.tag == "WhiteCube") { hasWon = true; GameObject.Find("blackCurtain").GetComponent <blackCurtainControl>().EndGame(Color.white, new string[] { "This game is based on one of my childhood nightmare", "I wished to share this experience with you", "Thank you for entering the UnderWater" }); Light cubeLight = GameObject.Find("WhiteCube").GetComponent <Light> (); cubeLight.range += 0.1f; } if (collision.Collision.gameObject.tag == "Predator") { Debug.Log(collision.Collision.transform.position - transform.position); StartCoroutine(HitBounce(collision.Collision.transform.position - transform.position)); hitParticle.Play(); SubtractLife(1); collision.Collision.gameObject.GetComponent <PredatorControl> ().readyToAttack = false; // Destroy(collision.Collision.gameObject); collision.Collision.gameObject.tag = "Finish"; hitParticle.Stop(); } if (collision.Collision.gameObject.tag == "PredatorStraight") { Debug.Log(collision.Collision.transform.position - transform.position); StartCoroutine(HitBounce(collision.Collision.transform.position - transform.position)); hitParticle.Play(); SubtractLife(1); // Destroy(collision.Collision.gameObject); collision.Collision.gameObject.tag = "Finish"; hitParticle.Stop(); } if (collision.Collision.gameObject.tag == "BottomFeeder") { Debug.Log(collision.Collision.transform.position - transform.position); StartCoroutine(HitBounce(collision.Collision.transform.position - transform.position)); hitParticle.Play(); SubtractLife(1); collision.Collision.gameObject.GetComponent <BottomFeederControl> ().readyToAttack = false; // Destroy(collision.Collision.gameObject); collision.Collision.gameObject.tag = "Finish"; hitParticle.Stop(); } if (collision.Collision.gameObject.tag == "HealthUp") { AddLife(1); Destroy(collision.Collision.gameObject); collision.Collision.gameObject.tag = "Finish"; } if (collision.Collision.gameObject.tag == "ShellFish") { collision.Collision.gameObject.GetComponentInChildren <ShellFishControl> ().ShellAction(); Debug.Log("Calling Shell!"); } if (collision.Collision.gameObject.tag == "ShellFishShell") { GameObject.Find("blackCurtain").GetComponent <blackCurtainControl>().EndGame(Color.red, ""); Destroy(gameObject); } }