public override void TakeDamage(int damage) { Debug.Log(gameObject.name); GetComponent <Animator>().SetTrigger("isDamaged"); Debug.Log("Health - damage = " + Health + " - " + damage + " = " + (Health - damage)); Health -= damage; Instantiate(BloodSplash, new Vector2(RigidBody.position.x, RigidBody.position.y - 0.1f), Quaternion.identity); if (Healthbar) { Healthbar.setHealth(Health, MaxHealth); } if (Health > 0) { Debug.Log(Health + " OVER 0"); toPlay = Random.Range(0, rangeScan); SoundToPlay.PlayOneShot(myAudio[toPlay], 0.9F); SoundToPlay.Play(); toPlay = (toPlay + 1) % rangeScan; } else if (Health <= 0) { //Destroy(); SoundToPlay.PlayOneShot(myAudio[IndexDeathSound], 0.9F); SoundToPlay.Play(); Score.enemyScore += Points; transform.Translate(0, -100, Time.deltaTime); Invoke("Die", 0.8f); } }
private void Element_MediaEnded(object sender, EventArgs e) { if (SoundNeeded) { SoundToPlay.Play(); } }
public void PlayIngameSound(SoundToPlay sound) { SoundEffect toPlay = null; switch (sound) { case SoundToPlay.Pickaxe: toPlay = Pickaxe; break; case SoundToPlay.Key: toPlay = PickKey; break; case SoundToPlay.Door: toPlay = InteractDoor; break; case SoundToPlay.Dying: toPlay = Dying; break; default: toPlay = PickKey; break; } var Ins = toPlay.CreateInstance(); Ins.Volume = 1f; Ins.Play(); }
public void Play(SoundToPlay sound) { MediaPlayer.Stop(); switch (sound) { case SoundToPlay.Ingame: MediaPlayer.Play(IngameSong); break; case SoundToPlay.Menu: MediaPlayer.Play(MenuSong); break; case SoundToPlay.Story: MediaPlayer.Play(StorySong); break; case SoundToPlay.GameOver: PlaySoundEffect(gameOverInstance); break; case SoundToPlay.LevelCompleted: PlaySoundEffect(levelCompletedInstance); break; } }
public void PlaySound(SoundToPlay soundToPlay) { adSource.clip = soundToPlay.audioClip; adSource.volume = soundToPlay.volume; adSource.pitch = Random.Range(soundToPlay.pitch.x, soundToPlay.pitch.y); adSource.Play(); }
public void StartMovement() { SoundToPlay.Stop(); if (_sound == SoundType.AllSounds || _sound == SoundType.OnlyMovementSounds) { SoundToPlay.Source = _currentImage.MovementSound; SoundToPlay.Play(); } }
void FindNewInitialSound(int lastRandIndex) { randSoundIndex = Random.Range(0, soundsList.Length); if (randSoundIndex == lastRandIndex) { FindNewInitialSound(lastRandIndex); } initialSound = soundsList[randSoundIndex]; }
//private bool m_diagetic; // Might not need. // Consturctor for copying sounds. // I only really need audiosources since the data is applied in // the awake step of soundmanager already... // I suppose it does allow me to move the 'awake' to the indivdual // to the requester to do. // I will revisit this. public Sound(Sound a_soundCopy, GameObject a_parent) { this.m_source = a_soundCopy.m_source; this.m_name = a_soundCopy.m_name; this.m_volumeScaler = a_soundCopy.m_volumeScaler; this.m_volume = a_soundCopy.m_volume * a_soundCopy.m_volumeScaler; this.m_Identifier = a_soundCopy.m_Identifier; this.m_soundClip = a_soundCopy.m_soundClip; this.m_pitch = a_soundCopy.m_pitch; this.m_mixer = a_soundCopy.m_mixer; }
private void soundTimer_Elapsed(object source, ElapsedEventArgs e) { Dispatcher.Invoke(() => { Controller.Pause(); SoundNeeded = false; SoundToPlay.Stop(); InteractionTimer.Start(); }); SoundTimer.Stop(); }
private void interactionTimer_Elapsed(object source, ElapsedEventArgs e) { Dispatcher.Invoke(() => { Controller.Play(); if (_sound == SoundType.AllSounds || _sound == SoundType.OnlyAttentionSounds) { SoundToPlay.Source = _currentImage.AttentionSound; SoundToPlay.Play(); SoundTimer.Start(); SoundNeeded = true; } }); InteractionTimer.Stop(); }
//public Sound GetSound(SoundToPlay a_identifier) //{ // switch(a_identifier) // { // case SoundToPlay.Walking: // { // return null; // } // case SoundToPlay.Running: // { // return null; // } // case SoundToPlay.Throw: // { // return null; // } // case SoundToPlay.Bounce: // { // return null; // } // case SoundToPlay.Burning: // { // return null; // } // case SoundToPlay.Fix: // { // return null; // } // case SoundToPlay.Fail: // { // return null; // } // case SoundToPlay.Crumble: // { // return null; // } // case SoundToPlay.Projectile: // { // return null; // } // default: // { // Debug.Log("Sound " + a_identifier + " not found."); // return null; // } // } //} //public Sound GetSound(SoundToPlay a_requestedSound) // Changed return from 'sound' to 'audiosource'. //{ // foreach (Sound s in m_soundBank) // { // if(a_requestedSound == s.m_Identifier) // { // return s; // } // } // Debug.Log("Sound " + a_requestedSound.ToString() + "Has not been asaigned in soundbank"); // return null; //} public Sound GetSound(GameObject a_parent, SoundToPlay a_requestedSound) { foreach (Sound s in m_soundBank) { if (a_requestedSound == s.m_Identifier) { // Most of this is safety precations. It does double up some things. s.m_source = a_parent.AddComponent <AudioSource>(); s.m_source.clip = s.m_soundClip; s.m_source.loop = false; s.m_source.pitch = s.m_pitch; s.m_source.volume = s.m_volume; s.m_source.outputAudioMixerGroup = GetMixer(s); s.m_source.playOnAwake = false; return(s); } } Debug.Log("Sound " + a_requestedSound.ToString() + "Has not been asaigned in soundbank"); return(null); }
public void PlaySound(SoundToPlay sound) { SoundsPlayer.Play(sound); }
/// <summary> /// PlaySound - plays sound based on game event /// </summary> /// <param name="sound">SoundToPlay sound</param> private void PlaySound(SoundToPlay sound) { SoundPlayer player; switch (sound) { case SoundToPlay.AteFood: player = new SoundPlayer(@"sounds\109662__grunz__success.wav"); break; case SoundToPlay.GameOver: player = new SoundPlayer(@"sounds\159408__noirenex__life-lost-game-over.wav"); break; default: player = new SoundPlayer(); break; } player.Play(); }
public void PlaySoundAtPosition(SoundToPlay sound) { AudioController.instance.PlaySoundAtPosition(sound.soundName, transform.position, sound.volume, sound.pitch); }
public void PlaySoundAtPlayer(SoundToPlay sound) { AudioController.instance.PlaySoundAtPlayer(sound.soundName, sound.volume, sound.pitch); }