public void PlaySound(SoundName soundName)
        {
            switch (soundName)
            {
            case SoundName.AsteroidExplosion:
                _soundPlayer.PlayOneShot(asteroidExplosion);
                break;

            case SoundName.MetallicAsteroidHit:
                _soundPlayer.PlayOneShot(metallicAsteroidHit);
                break;

            case SoundName.StickBendingPole:
                _soundPlayer.PlayOneShot(stickBendingPole);
                break;

            case SoundName.ReleaseBendingPole:
                _soundPlayer.PlayOneShot(releaseBendingPole);
                break;

            default:
                Debug.LogWarning("THERE'S NO SOUND LIKE THIS");
                break;
            }
        }
Ejemplo n.º 2
0
 public Sound(SoundName inName, string AssetName)
 {
     Name      = inName;
     Asset     = AssetName;
     maxSound  = 0;
     currSound = 0;
 }
Ejemplo n.º 3
0
    private IEnumerator DropSound(SoundName sound)
    {
        AudioManager.instance.PlaySound(sound);
        yield return(null);

        soundCoroutine = null;
    }
Ejemplo n.º 4
0
        public void Init()
        {
            ClientAssetRepository clientAssetRepo = GameFacade.Instance.RetrieveProxy <ClientAssetRepository>();

            XmlDocument mXmlSoundDocument = XmlUtility.LoadXmlDocument(SOUND_LOOKUP_TABLE_XML_PATH);

            // TODO: Remove this loading hack.
            XmlNodeList soundNodes = mXmlSoundDocument.SelectNodes("Sounds/Sound");

            mSoundsLeftToLoad = soundNodes.Count;

            foreach (XmlNode soundNode in soundNodes)
            {
                string    name      = soundNode.SelectSingleNode("Name").InnerText;
                SoundName soundName = (SoundName)Enum.Parse(typeof(SoundName), name);

                string path = soundNode.SelectSingleNode("Path").InnerText;
                //Console.WriteLine("Loading sound: " + name + ", " + path);
                clientAssetRepo.LoadAssetFromPath <SoundAsset>(path, delegate(SoundAsset asset)
                {
                    RetrieveSoundAssetFromRepoOnLoad(soundName, asset);
                });
            }

            mMainCamera = GameFacade.Instance.RetrieveMediator <CameraManagerMediator>().MainCamera;
        }
Ejemplo n.º 5
0
 public void PlaySound(SoundName soundName)
 {
     foreach (IBlock block in blocks)
     {
         block.PlaySound(soundName);
     }
 }
Ejemplo n.º 6
0
    public AudioSource PlaySoundCue(SoundName sound, Vector3 position, float pitch = 1)
    {
        SoundPrefab soundPrefab;

        // Find the sound cue
        if (!GetSoundFromSoundList(sound, soundList.cues, out soundPrefab))
        {
            return(null);
        }

        // Instantiate the cue
        GameObject         go      = Instantiate(soundPrefab.clip, position, Quaternion.identity);
        OneShotThenDestroy oneShot = go.GetComponent <OneShotThenDestroy>();

        if (oneShot != null)
        {
            oneShot.soundManager = this;
        }

        // Register it
        AudioSource source = go.GetComponent <AudioSource>();

        cues.Add(new Cues(sound, source));

        return(source);
    }
Ejemplo n.º 7
0
 public void PlayAudioOneShot(SoundName audioName)
 {
     if (gameInstaller != null)
     {
         gameInstaller.fxSource.PlayOneShot(ReturnAudio(audioName));
     }
 }
Ejemplo n.º 8
0
    public void PlaySound(SoundName name, Vector3 position)     // TODO try with 3d audio position
    {
        if (this.pistolShotAudio == null || this.rifleShotAudio == null || this.gunReloadAudio == null)
        {
            GD.Print("Audio not set!");
            QueueFree();
            return;
        }

        if (name == SoundName.PISTOL_SHOT)
        {
            this.audioPlayer.Stream = this.pistolShotAudio;
        }
        else if (name == SoundName.RIFLE_SHOT)
        {
            this.audioPlayer.Stream = this.rifleShotAudio;
        }
        else if (name == SoundName.RELOAD)
        {
            this.audioPlayer.Stream = this.gunReloadAudio;
        }
        else
        {
            GD.Print("UNKNOWN STREAM");
            QueueFree();
            return;
        }

        this.audioPlayer.Play();
    }
Ejemplo n.º 9
0
 public Sound(SoundName name, AudioClip clip, float volume = 1.0f, float pitch = 1.0f)
 {
     Name   = name;
     Clip   = clip;
     Volume = volume;
     Pitch  = pitch;
 }
	void Awake()
	{
		if( sounds == null )
			sounds = new List<SoundName>();

		_audio = audio;
		if (_audio == null)
		{
			_audio = gameObject.AddComponent<AudioSource>();
			_audio.playOnAwake = false;
		}

#if UNITY_EDITOR
		foreach (var component in gameObject.GetComponents<Component>())
		{
			object[] attributes = component.GetType().GetCustomAttributes(true);
			foreach (var attr in attributes)
			{
				if (attr is SoundClipAttribute == false) 
					continue;

				string name = ((SoundClipAttribute) attr).name;
				SoundName sound = sounds.Find(s => s.name == name);
				if (sound == null)
				{
					sound = new SoundName();
					sound.name = name;
					sounds.Add(sound);
				}

			}
		}
#endif
	}
Ejemplo n.º 11
0
        public static void PlaySound(SoundName SoundName, bool Looping = true)
        {
            switch (SoundName)
            {
                case SoundName.Saber:
                    SoundPlayer.Stream = Properties.Resources.Saber;
                    break;
                case SoundName.GameBackground:
                    SoundPlayer.Stream = Properties.Resources.GameBackground;
                    break;
                case SoundName.MenuBackground:
                    SoundPlayer.Stream = Properties.Resources.MenuBackground;
                    break;
                case SoundName.CrusadersWin:
                    SoundPlayer.Stream = Properties.Resources.CrusadersWin;
                    break;
                case SoundName.SaracensWin:
                    SoundPlayer.Stream = Properties.Resources.SaracensWin;
                    break;
                default:
                    return;
            }

            if (SoundEnabled) // play only if sound is enabled
            {
                if (Looping) // play in a loop
                    SoundPlayer.PlayLooping();
                else
                    SoundPlayer.Play();
            }
        }
Ejemplo n.º 12
0
        public static Sound Add(SoundName soundName)
        {
            SoundManager soundMan = SoundManager.GetInstance();
            Sound        pSound   = (Sound)soundMan.BaseAdd();

            pSound.Set(soundName);
            return(pSound);
        }
Ejemplo n.º 13
0
    async ValueTask play(SoundName soundName)
    {
        throwIfNotLoaded();

        SoundEffect audio = _loader.GetSoundEffect(soundName);

        await audio.Play();
    }
Ejemplo n.º 14
0
 public static SoundBuffer GetSound(SoundName soundName)
 {
     if (sounds.Count == 0)
     {
         LoadSound();
     }
     return(sounds[soundName]);
 }
Ejemplo n.º 15
0
 public void AddSound(SoundName name, AudioClip audioClip)
 {
     if (mSoundDictionary.ContainsKey(name))
     {
         throw new Exception("mSoundDictionary already contains SoundName: " + name + ".");
     }
     mSoundDictionary.Add(name, audioClip);
 }
Ejemplo n.º 16
0
 public void InspectorAdapt(SoundName sn, bool isiid, float iidcoe, bool isitd, bool issim)
 {
     soundName      = sn;
     isIid          = isiid;
     iidCoefficient = iidcoe;
     isItd          = isitd;
     isSimulation   = issim;
 }
Ejemplo n.º 17
0
 public void PlaySound(SoundName name)
 {
     if (_loadedEffects.TryGetValue(name, out SoundEffect effect))
     {
         var volume = (float)_volume / 100;
         effect.Play(volume, 0f, 0f);
     }
 }
Ejemplo n.º 18
0
 public static Sound getSound(SoundName soundName)
 {
     if (sounds.Count == 0)
     {
         LoadSounds();
     }
     return sounds[soundName];
 }
	public void InspectorAdapt(SoundName sn,bool isiid,float iidcoe,bool isitd,bool issim)
	{
		soundName = sn;
		isIid = isiid;
		iidCoefficient = iidcoe;
		isItd = isitd;
		isSimulation = issim;
	}
Ejemplo n.º 20
0
 public void playSound(SoundName soundName, float volume)
 {
     if (volume > 1)
     {
         volume = 1f;
     }
     sounds[(int)soundName].volume = volume;
     sounds[(int)soundName].Play();
 }
Ejemplo n.º 21
0
    public void StopEffect(SoundName effect)
    {
        Transform audio = transform.Find("(Audio) " + effect.ToString());

        if (audio != null)
        {
            BlockTools.Destroy(audio.gameObject);
        }
    }
Ejemplo n.º 22
0
        /// <summary>
        /// Módulo encargado de ejecutar el sonido y devolver su duración
        /// </summary>
        /// <param name="soundName">Sonido seleccionado</param>
        /// <returns></returns>
        public float PlaySound(SoundName soundName)
        {
            AudioClip aux;

            switch (soundName)
            {
            case SoundName.Heartbeat:
                aux = hearbeatSound;
                break;

            case SoundName.Scare:
                aux = scareSound;
                break;

            case SoundName.Violin:
                aux = violinSound;
                break;

            case SoundName.ButtonMouseEnter:
                aux = buttonMouseEnterSound;
                break;

            case SoundName.ButtonMouseClick:
                aux = buttonMouseClickSound;
                break;

            case SoundName.JumpPlayer:
                aux = jumpPlayerSound;
                break;

            case SoundName.HurtPlayer:
                aux = hurtPlayerSound;
                break;

            case SoundName.DeadPlayer:
                aux = deadPlayerSound;
                break;

            case SoundName.AttackPlayer:
                aux = attackPlayerSound;
                break;

            case SoundName.DeadScorpio:
                aux = deadScorpioSound;
                break;

            case SoundName.DeadVulture:
                aux = deadVultureSound;
                break;

            default:
                aux = null;
                break;
            }
            _soundEffects.PlayOneShot(aux);
            return(aux.length);
        }
Ejemplo n.º 23
0
        public static Sound Find(SoundName soundName)
        {
            SoundManager soundMan = SoundManager.GetInstance();
            Sound        pSound   = (Sound)soundMan.BaseFind(new Sound {
                name = soundName
            });

            return(pSound);
        }
Ejemplo n.º 24
0
    public void PlayGoalBeat(SoundName name)
    {
        if (playMode != PlayMode.Goal)
        {
            return;
        }
        var sourceItem = soundBank.First(x => x.Name == name);

        sourceItem.Source.Play();
    }
Ejemplo n.º 25
0
    public void PlayClip(SoundName soundName)
    {
        AudioClip audioClip = FindClip(soundName);

        if (audioClip != null)
        {
            audioSource.clip = audioClip;
            audioSource.Play();
        }
    }
Ejemplo n.º 26
0
    // Looks for first specified sound-effect by enum name
    public void PlaySound(SoundName soundName)
    {
        SoundEffect soundCombo = soundEffects.FirstOrDefault(x => x.soundName == soundName);

        if (soundCombo == null)
        {
            return;
        }

        soundCombo.audioSource.Play();
    }
Ejemplo n.º 27
0
    public void Play(SoundName name)
    {
        if (playMode != PlayMode.Gameplay)
        {
            return;
        }
        var sourceItem = soundBank.First(x => x.Name == name);

        sourceItem.Source.Play();
        onDeckPlays.Add(name);
    }
Ejemplo n.º 28
0
 private AudioClip GetSound(SoundName soundName)
 {
     foreach (var sound in sounds)
     {
         if (sound.soundName == soundName)
         {
             return(sound.clip);
         }
     }
     return(null);
 }
Ejemplo n.º 29
0
 int GetIndex(SoundName name)
 {
     foreach (Sound item in sounds)
     {
         if (name == item.name)
         {
             return(sounds.IndexOf(item));
         }
     }
     return(sounds.Count);
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Play a sound effect
 /// </summary>
 /// <param name="son"></param>
 public void playSound(SoundName son)
 {
     try             // Catch exceptions in case the computer can't play songs (example: Travis)
     {
         if (!sfxmute)
         {
             sounds[(int)son].Play();
         }
     }
     catch { }
 }
Ejemplo n.º 31
0
    public void StopLooping(SoundName sn)
    {
        string p_YourLoopingSound = sn.ToString();

        foreach (AudioSource audio in audioSources)
        {
            if (audio.clip.name == p_YourLoopingSound)
            {
                audio.Stop();
            }
        }
    }
Ejemplo n.º 32
0
 public void RemoveCue(SoundName name)
 {
     foreach (Cues cue in cues)
     {
         if (cue.name == name)
         {
             cues.Remove(cue);
             Destroy(cue.cue.gameObject);
             return;
         }
     }
 }
Ejemplo n.º 33
0
    public void PlaySoundOneShot(SoundName soundName, AudioSource source)
    {
        int index = GetIndex(soundName);

        if (index == sounds.Count)
        {
            Debug.LogWarning("There is no sound with this name " + soundName + " on SoundsManger, please verify your typing.");
            return;
        }
        source.pitch = sounds[index].pitchs[Random.Range(0, sounds[index].pitchs.Count)];
        source.PlayOneShot(sounds[index].clips[Random.Range(0, sounds[index].clips.Count)], sounds[index].volume);
    }
Ejemplo n.º 34
0
 public void PlaySound(SoundName enumClip)
 {
     for (int i = 0; i < SoundsClipArray.Length; i++)
     {
         if (enumClip.ToString() == SoundsClipArray[i].name)
         {
             AudioSource soundSource = gameObject.AddComponent<AudioSource>();
             soundSource.PlayOneShot (SoundsClipArray[i]);
             Destroy (soundSource, SoundsClipArray[i].length);
         }
     }
 }
Ejemplo n.º 35
0
        private void RetrieveSoundAssetFromRepo(SoundName soundName, Asset asset)
        {
            //Console.WriteLine("Loaded sound: " + soundName.ToString());
            SoundAsset soundAsset = (SoundAsset)asset;

            soundAsset.AudioClip.name = soundName.ToString();
            if (soundAsset == null)
            {
                throw new Exception("asset returned from repo could not be cast as SoundAsset.");
            }
            AddSound(soundName, soundAsset.AudioClip);
        }
Ejemplo n.º 36
0
    public AudioClip Get(SoundName soundName)
    {
        Sound target = null;
        foreach (Sound sound in sounds)
        {
            if (sound.soundName == soundName)
            {
                target = sound;
                break;
            }
        }

        if (target == null)
        {
            Debug.Log("Couldnt find the sound file!");
        }

        return target.audioClip;
    }
Ejemplo n.º 37
0
 public void PlaySound(SoundName soundName)
 {
     _view.PlaySound(soundName);
 }
Ejemplo n.º 38
0
 //if soundName does not already exist, add it to dictionary
 //else do not add it!
 public void LoadSound(SoundName soundName, string soundPath)
 {
     Sound sound = new Sound(soundPath);
     if (!sounds.ContainsKey(soundName))
     {
         sounds.Add(soundName, sound);
     }
 }
Ejemplo n.º 39
0
 //public void PlaySound(SoundName soundName)
 //{
 //    if (sounds.ContainsKey(soundName))
 //    {
 //        int index = GetAvailableSoundIndex();
 //        if (index != -1)
 //        {
 //            soundInstances[index] = sounds[soundName].Effect.CreateInstance();
 //            if (soundInstances[index].State != SoundState.Playing)
 //            {
 //                soundInstances[index].Play();
 //            }
 //        }
 //    }
 //}
 //Play soundName only if it exists in dictionary
 public void PlaySound(SoundName soundName)
 {
     if (sounds.ContainsKey(soundName))
     {
         sounds[soundName].Play();
     }
 }
Ejemplo n.º 40
0
 public void PlaySound(SoundName soundName, bool bLoop)
 {
     if (sounds.ContainsKey(soundName))
     {
         sounds[soundName].Loop = bLoop;
         sounds[soundName].Play();
     }
 }
Ejemplo n.º 41
0
 public void PlaySound(SoundName soundName, Vector3 position, bool bLoop)
 {
     if (sounds.ContainsKey(soundName))
     {
         sounds[soundName].Position = position;
         sounds[soundName].Loop = bLoop;
         sounds[soundName].Apply3D();
         sounds[soundName].Play();
     }
 }
Ejemplo n.º 42
0
 public void PlaySound(SoundName soundName)
 {
     foreach (IBlock block in blocks)
     {
         block.PlaySound(soundName);
     }
 }
Ejemplo n.º 43
0
 public void PlaySound(SoundName soundName)
 {
 }
Ejemplo n.º 44
0
 public void PlaySound(SoundName soundName, bool bLoop, float fPitch, float fPan)
 {
     if (sounds.ContainsKey(soundName))
     {
         sounds[soundName].Loop = bLoop;
         sounds[soundName].Pitch = fPitch;
         sounds[soundName].Pan = fPan;
         sounds[soundName].Play();
     }
 }
Ejemplo n.º 45
0
    public void PlaySound(SoundName soundName)
    {
        if (GetComponent<AudioSource>() == null)
        {
            Debug.Log("No audiosource is attached!");
            return;
        }

        AudioClip clip = SoundRepository.Instance.Get(soundName);

        GetComponent<AudioSource>().clip = clip;
        GetComponent<AudioSource>().PlayDelayed(0.05f);
    }