Marc-Olivier
4 年前
当前提交
45cb9412
共有 10 个文件被更改,包括 301 次插入 和 20 次删除
-
26UOP1_Project/Assets/Scripts/Audio/AudioCue.cs
-
84UOP1_Project/Assets/Scripts/Audio/AudioManager.cs
-
15UOP1_Project/Assets/Scripts/Audio/SoundEmitters/SoundEmitter.cs
-
6UOP1_Project/Assets/Scripts/Characters/ProtagonistAudio.cs
-
2UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/PlayAudioCueActionSO.cs
-
57UOP1_Project/Assets/Scripts/Events/ScriptableObjects/AudioCueEventChannelSO.cs
-
36UOP1_Project/Assets/Scripts/Audio/AudioData/AudioCueKey.cs
-
11UOP1_Project/Assets/Scripts/Audio/AudioData/AudioCueKey.cs.meta
-
73UOP1_Project/Assets/Scripts/Audio/SoundEmitters/SoundEmitterList.cs
-
11UOP1_Project/Assets/Scripts/Audio/SoundEmitters/SoundEmitterList.cs.meta
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
public struct AudioCueKey |
|||
{ |
|||
public static AudioCueKey Invalid = new AudioCueKey(-1, null); |
|||
|
|||
internal int Value; |
|||
internal AudioCueSO AudioCue; |
|||
|
|||
internal AudioCueKey(int value, AudioCueSO audioCue) |
|||
{ |
|||
Value = value; |
|||
AudioCue = audioCue; |
|||
} |
|||
|
|||
public override bool Equals(Object obj) |
|||
{ |
|||
return obj is AudioCueKey x && Value == x.Value && AudioCue == x.AudioCue; |
|||
} |
|||
public override int GetHashCode() |
|||
{ |
|||
return Value.GetHashCode() ^ AudioCue.GetHashCode(); |
|||
} |
|||
public static bool operator ==(AudioCueKey x, AudioCueKey y) |
|||
{ |
|||
return x.Value == y.Value && x.AudioCue == y.AudioCue; |
|||
} |
|||
public static bool operator !=(AudioCueKey x, AudioCueKey y) |
|||
{ |
|||
return !(x == y); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 325f637f904634344bb44ab93b38e81e |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using UnityEngine.Assertions; |
|||
|
|||
public class SoundEmitterList |
|||
{ |
|||
private int _nextUniqueKey = 0; |
|||
private List<AudioCueKey> _emittersKey; |
|||
private List<SoundEmitter[]> _emittersList; |
|||
|
|||
public SoundEmitterList() |
|||
{ |
|||
_emittersKey = new List<AudioCueKey>(); |
|||
_emittersList = new List<SoundEmitter[]>(); |
|||
} |
|||
|
|||
public AudioCueKey GetKey(AudioCueSO cue) |
|||
{ |
|||
return new AudioCueKey(_nextUniqueKey++, cue); |
|||
} |
|||
|
|||
public void Add(AudioCueKey key, SoundEmitter[] emitter) |
|||
{ |
|||
_emittersKey.Add(key); |
|||
_emittersList.Add(emitter); |
|||
} |
|||
|
|||
public AudioCueKey Add(AudioCueSO cue, SoundEmitter[] emitter) |
|||
{ |
|||
AudioCueKey emitterKey = GetKey(cue); |
|||
|
|||
_emittersKey.Add(emitterKey); |
|||
_emittersList.Add(emitter); |
|||
|
|||
return emitterKey; |
|||
} |
|||
|
|||
public bool Get(AudioCueKey key, out SoundEmitter[] emitter) |
|||
{ |
|||
int index = _emittersKey.FindIndex(x => x == key); |
|||
|
|||
if (index < 0) |
|||
{ |
|||
emitter = null; |
|||
return false; |
|||
} |
|||
|
|||
emitter = _emittersList[index]; |
|||
return true; |
|||
} |
|||
|
|||
public bool Remove(AudioCueKey key) |
|||
{ |
|||
int index = _emittersKey.FindIndex(x => x == key); |
|||
return RemoveAt(index); |
|||
} |
|||
|
|||
private bool RemoveAt(int index) |
|||
{ |
|||
if (index < 0) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
_emittersKey.RemoveAt(index); |
|||
_emittersList.RemoveAt(index); |
|||
|
|||
return true; |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 9d1a0455c3126ea4a991e9fd36520393 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue