public GameObject PlayEffectSound(EffectSoundType ef, Transform obj) { GameObject madeObj = Instantiate(effectAudioClips[(int)ef], obj.position, Quaternion.identity, obj); madeObj.GetComponent <SoundObject>().Play(); return(madeObj); }
public void Play(EffectSoundType type) { AudioSource.PlayClipAtPoint(effectMap[type], Vector3.zero); }
/// <summary> /// Play sound effect, adds 3d sound effect depending on the position. /// </summary> /// <param name="soundType">Sound type</param> public static void PlaySoundEffect(EffectSoundType soundType) { Sound.Play(soundType.ToString()); }
private EffectAudioSourceItem _PlaySFX(string audioName, AudioType aType, Transform point, Vector3 pos, int sortId, EffectSoundType type) { if (string.IsNullOrEmpty(audioName)) { return(null); } if (_IsEffectAudioEnabled) { CheckAudioListener(); SafeInitSFX(); EffectAudioSourceItem item_arranged = GetUsableItem(aType, sortId, pos, type); if (item_arranged != null) { item_arranged.audioName = audioName; if (item_arranged.id != -1 && item_arranged.attachedObj != null) { if (type == EffectSoundType.Effect3D || type == EffectSoundType.AttachEffect3D || type == EffectSoundType.Effect2D || type == EffectSoundType.FootStep3D) { if (item_arranged.IsPlaying()) { item_arranged.Stop(); } } else { item_arranged.Stop(); } GetProperSettingOfItem(item_arranged, aType, audioName, sortId); if (aType == AudioType.AttS3D) { item_arranged.attachedPos = point; item_arranged.attachedObj.transform.position = point.position; } if (aType == AudioType.S3D) { item_arranged.attachedObj.transform.position = pos; } if (item_arranged.attachedObj != null) { item_arranged.Play(audioName); } return(item_arranged); } } } return(null); }
private EffectAudioSourceItem GetUsableItem(AudioType aType, int priority, Vector3 pos, EffectSoundType type) { List <EffectAudioSourceItem> soundList = null; bool bSkipCompare = false; switch (type) { case EffectSoundType.Effect3D: soundList = _effect3DAudioSourceList; break; case EffectSoundType.AttachEffect3D: soundList = _attachedEffect3DAudioSourceList; break; case EffectSoundType.Effect2D: soundList = _effect2DAudioSourceList; break; case EffectSoundType.Static3D: soundList = _static3DAudioSourceList; break; case EffectSoundType.FootStep3D: soundList = _footStep3DAudioSourceList; break; case EffectSoundType.NpcVoice3D: soundList = _npcVoice3DAudioSourceList; bSkipCompare = true; break; case EffectSoundType.NpcShout3D: soundList = _npcShout3DAndioSourceList; bSkipCompare = true; break; case EffectSoundType.Heartbeat2D: soundList = _heartbeat2DAudioSourceList; bSkipCompare = true; break; default: break; } if (soundList != null && soundList.Count > 0) { EffectAudioSourceItem item = GetFirstItem(soundList, aType != AudioType.S2D); if (item != null && item.attachedObj != null) { if (bSkipCompare) { return(item); } else if (item.IsPlaying()) { if (item.priority > priority) { return(null); } else if (item.priority == priority && aType != AudioType.S2D) { if (DistanceComparison(item.attachedObj.transform.position, pos) > 0) { return(null); } } } } return(item); } return(null); }