private void ApplyDamage(int damage) { if (!audioSource.isPlaying && CanPlay()) { audioSource.Play(); } health -= damage; if (health <= 0 && die == false) { die = true; GameObject obj = (GameObject)Instantiate(boom, transform.position, transform.rotation); if (levelManager != null) { levelManager.AnimalDie(gameObject); } else { linelevelManager.AnimalDie(gameObject); } Destroy(gameObject); } }
private void ApplyDamage(int damage) { if (gameObject.name != "Pig" && !audioSource.isPlaying && CanPlay()) { audioSource.Play(); } health -= damage; if (health <= 0 && die == false) { die = true; if (gameObject) { int randint = Random.Range(0, 10); if (randint == 9) { GameObject Bloodbag = (GameObject)Instantiate(bloodbag, transform.position, transform.rotation); Bloodbag.GetComponent <BloodBag>().DestroyProp(20); } else if (randint == 1) { GameObject Randbox = (GameObject)Instantiate(randbox, transform.position, transform.rotation); Randbox.GetComponent <RandBox>().DestroyProp(20); } GameObject Boom = (GameObject)Instantiate(boom, transform.position, transform.rotation); if (levelManager != null) { levelManager.AnimalDie(gameObject); } else { linelevelManager.AnimalDie(gameObject); } Destroy(gameObject); } } }