private IEnumerator Shoot() { while (shooting) { Projectile proj; if (projPool.Count > 0) { proj = projPool.Dequeue(); proj.gameObject.SetActive(true); } else { proj = (Projectile)Instantiate(bulletPrefab); } audioPlayer.PlayOneShot(shootAudioClips[UnityEngine.Random.Range(0, shootAudioClips.Length)]); proj.transform.position = transform.position; proj.Initialise(this, projectileSpeed); projectiles.Add(proj); yield return(new WaitForSeconds(secsBetweenBullets)); } }
public void DoDamage() { shieldAnimator.SetTrigger(DAMAGE_HASH); if (--health <= 0) { OnDefeated(); } if (onDamageAudioClips != null && onDamageAudioClips.Length > 0) { gameAudio.PlayOneShot(onDamageAudioClips[UnityEngine.Random.Range(0, onDamageAudioClips.Length)]); } }
private IEnumerator _AnimateText(string toDisplay, float secsBetweenChar, float secEndDelay) { int i = 0; animText.text = ""; while (i < toDisplay.Length) { if (onCharClip) { audioPlayer.PlayOneShot(onCharClip); } animText.text += toDisplay[i++]; yield return(new WaitForSeconds(secsBetweenChar)); } yield return(new WaitForSeconds(secEndDelay)); if (onTextAnimationFinished != null) { onTextAnimationFinished(); } }
public void OnDeath() { audioPlayer.PlayOneShot(audioOnDeath [UnityEngine.Random.Range(0, audioOnDeath.Length)]); shouldUpdate = false; animator.SetTrigger(DAMAGE_HASH); }