public SoundEvent(SoundType soundType, FxSoundCode fxSoundCode, Vector3 fxSoundPosition) { this.soundType = soundType; this.bgmSoundCode = BgmSoundCode.None; this.fxSoundCode = fxSoundCode; this.fxSoundWorldPosition = fxSoundPosition; }
public SoundEvent(SoundType soundType, BgmSoundCode bgmSoundCode) { this.soundType = soundType; this.bgmSoundCode = bgmSoundCode; this.fxSoundCode = FxSoundCode.None; fxSoundWorldPosition = Vector3.zero; }
private void PlayFxSound(FxSoundCode fxSoundCode, Vector3 worldPosition) { if ((int)fxSoundCode >= fxSounds.Count || fxSounds[(int)fxSoundCode] == null) { return; } if (fxSoundCode != FxSoundCode.None) { GameObject goFxSpeaker = new GameObject("fxSpeaker"); AudioSource asFxSpeaker = goFxSpeaker.AddComponent <AudioSource>(); goFxSpeaker.transform.SetParent(transform); goFxSpeaker.transform.position = worldPosition; asFxSpeaker.clip = fxSounds[(int)fxSoundCode]; asFxSpeaker.spatialBlend = 0.5f; asFxSpeaker.Play(); Destroy(goFxSpeaker, asFxSpeaker.clip.length); } }