コード例 #1
0
        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;
            }
        }
コード例 #2
0
 public Sound(SoundName inName, string AssetName)
 {
     Name      = inName;
     Asset     = AssetName;
     maxSound  = 0;
     currSound = 0;
 }
コード例 #3
0
    private IEnumerator DropSound(SoundName sound)
    {
        AudioManager.instance.PlaySound(sound);
        yield return(null);

        soundCoroutine = null;
    }
コード例 #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;
        }
コード例 #5
0
 public void PlaySound(SoundName soundName)
 {
     foreach (IBlock block in blocks)
     {
         block.PlaySound(soundName);
     }
 }
コード例 #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);
    }
コード例 #7
0
ファイル: SoundManager.cs プロジェクト: outscal/hitman
 public void PlayAudioOneShot(SoundName audioName)
 {
     if (gameInstaller != null)
     {
         gameInstaller.fxSource.PlayOneShot(ReturnAudio(audioName));
     }
 }
コード例 #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();
    }
コード例 #9
0
 public Sound(SoundName name, AudioClip clip, float volume = 1.0f, float pitch = 1.0f)
 {
     Name   = name;
     Clip   = clip;
     Volume = volume;
     Pitch  = pitch;
 }
コード例 #10
0
	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
	}
コード例 #11
0
ファイル: Sound.cs プロジェクト: Simsso/Crusades
        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();
            }
        }
コード例 #12
0
        public static Sound Add(SoundName soundName)
        {
            SoundManager soundMan = SoundManager.GetInstance();
            Sound        pSound   = (Sound)soundMan.BaseAdd();

            pSound.Set(soundName);
            return(pSound);
        }
コード例 #13
0
    async ValueTask play(SoundName soundName)
    {
        throwIfNotLoaded();

        SoundEffect audio = _loader.GetSoundEffect(soundName);

        await audio.Play();
    }
コード例 #14
0
 public static SoundBuffer GetSound(SoundName soundName)
 {
     if (sounds.Count == 0)
     {
         LoadSound();
     }
     return(sounds[soundName]);
 }
コード例 #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);
 }
コード例 #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;
 }
コード例 #17
0
 public void PlaySound(SoundName name)
 {
     if (_loadedEffects.TryGetValue(name, out SoundEffect effect))
     {
         var volume = (float)_volume / 100;
         effect.Play(volume, 0f, 0f);
     }
 }
コード例 #18
0
ファイル: AssetManager.cs プロジェクト: Gnaarf/UnicycleSheep
 public static Sound getSound(SoundName soundName)
 {
     if (sounds.Count == 0)
     {
         LoadSounds();
     }
     return sounds[soundName];
 }
コード例 #19
0
	public void InspectorAdapt(SoundName sn,bool isiid,float iidcoe,bool isitd,bool issim)
	{
		soundName = sn;
		isIid = isiid;
		iidCoefficient = iidcoe;
		isItd = isitd;
		isSimulation = issim;
	}
コード例 #20
0
 public void playSound(SoundName soundName, float volume)
 {
     if (volume > 1)
     {
         volume = 1f;
     }
     sounds[(int)soundName].volume = volume;
     sounds[(int)soundName].Play();
 }
コード例 #21
0
ファイル: SoundManager.cs プロジェクト: Kimsanggu/SpaceBlock
    public void StopEffect(SoundName effect)
    {
        Transform audio = transform.Find("(Audio) " + effect.ToString());

        if (audio != null)
        {
            BlockTools.Destroy(audio.gameObject);
        }
    }
コード例 #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);
        }
コード例 #23
0
        public static Sound Find(SoundName soundName)
        {
            SoundManager soundMan = SoundManager.GetInstance();
            Sound        pSound   = (Sound)soundMan.BaseFind(new Sound {
                name = soundName
            });

            return(pSound);
        }
コード例 #24
0
    public void PlayGoalBeat(SoundName name)
    {
        if (playMode != PlayMode.Goal)
        {
            return;
        }
        var sourceItem = soundBank.First(x => x.Name == name);

        sourceItem.Source.Play();
    }
コード例 #25
0
    public void PlayClip(SoundName soundName)
    {
        AudioClip audioClip = FindClip(soundName);

        if (audioClip != null)
        {
            audioSource.clip = audioClip;
            audioSource.Play();
        }
    }
コード例 #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();
    }
コード例 #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);
    }
コード例 #28
0
 private AudioClip GetSound(SoundName soundName)
 {
     foreach (var sound in sounds)
     {
         if (sound.soundName == soundName)
         {
             return(sound.clip);
         }
     }
     return(null);
 }
コード例 #29
0
ファイル: SoundsManager.cs プロジェクト: Nylash/LD47
 int GetIndex(SoundName name)
 {
     foreach (Sound item in sounds)
     {
         if (name == item.name)
         {
             return(sounds.IndexOf(item));
         }
     }
     return(sounds.Count);
 }
コード例 #30
0
ファイル: Sound.cs プロジェクト: Mathux/tim-dodge
 /// <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 { }
 }
コード例 #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();
            }
        }
    }
コード例 #32
0
 public void RemoveCue(SoundName name)
 {
     foreach (Cues cue in cues)
     {
         if (cue.name == name)
         {
             cues.Remove(cue);
             Destroy(cue.cue.gameObject);
             return;
         }
     }
 }
コード例 #33
0
ファイル: SoundsManager.cs プロジェクト: Nylash/LD47
    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);
    }
コード例 #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);
         }
     }
 }
コード例 #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);
        }
コード例 #36
0
ファイル: SoundRepository.cs プロジェクト: Mojopon/ThreeSeven
    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;
    }
コード例 #37
0
ファイル: Block.cs プロジェクト: Mojopon/ThreeSeven
 public void PlaySound(SoundName soundName)
 {
     _view.PlaySound(soundName);
 }
コード例 #38
0
ファイル: mAudio.cs プロジェクト: apolaskey/Inkwell
 //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);
     }
 }
コード例 #39
0
ファイル: mAudio.cs プロジェクト: apolaskey/Inkwell
 //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();
     }
 }
コード例 #40
0
ファイル: mAudio.cs プロジェクト: apolaskey/Inkwell
 public void PlaySound(SoundName soundName, bool bLoop)
 {
     if (sounds.ContainsKey(soundName))
     {
         sounds[soundName].Loop = bLoop;
         sounds[soundName].Play();
     }
 }
コード例 #41
0
ファイル: mAudio.cs プロジェクト: apolaskey/Inkwell
 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();
     }
 }
コード例 #42
0
ファイル: Group.cs プロジェクト: Mojopon/ThreeSeven
 public void PlaySound(SoundName soundName)
 {
     foreach (IBlock block in blocks)
     {
         block.PlaySound(soundName);
     }
 }
コード例 #43
0
ファイル: NullBlockView.cs プロジェクト: Mojopon/ThreeSeven
 public void PlaySound(SoundName soundName)
 {
 }
コード例 #44
0
ファイル: mAudio.cs プロジェクト: apolaskey/Inkwell
 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();
     }
 }
コード例 #45
0
ファイル: BlockView.cs プロジェクト: Mojopon/ThreeSeven
    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);
    }