Add simple audio system
This commit is contained in:
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 45c7677c1cf47f10aa135ad774e6d392
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,23 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8e32ddd55d6efe6e383b392b08cbe107
|
||||||
|
AudioImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 8
|
||||||
|
defaultSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
loadType: 0
|
||||||
|
sampleRateSetting: 0
|
||||||
|
sampleRateOverride: 44100
|
||||||
|
compressionFormat: 1
|
||||||
|
quality: 1
|
||||||
|
conversionMode: 0
|
||||||
|
preloadAudioData: 0
|
||||||
|
platformSettingOverrides: {}
|
||||||
|
forceToMono: 0
|
||||||
|
normalize: 1
|
||||||
|
loadInBackground: 0
|
||||||
|
ambisonic: 0
|
||||||
|
3D: 1
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,23 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8031864ce1c982d53913a027ea97577f
|
||||||
|
AudioImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 8
|
||||||
|
defaultSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
loadType: 0
|
||||||
|
sampleRateSetting: 0
|
||||||
|
sampleRateOverride: 44100
|
||||||
|
compressionFormat: 1
|
||||||
|
quality: 1
|
||||||
|
conversionMode: 0
|
||||||
|
preloadAudioData: 0
|
||||||
|
platformSettingOverrides: {}
|
||||||
|
forceToMono: 0
|
||||||
|
normalize: 1
|
||||||
|
loadInBackground: 0
|
||||||
|
ambisonic: 0
|
||||||
|
3D: 1
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,23 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 06e03c52b213e965ab19f5ee87a7c02a
|
||||||
|
AudioImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 8
|
||||||
|
defaultSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
loadType: 0
|
||||||
|
sampleRateSetting: 0
|
||||||
|
sampleRateOverride: 44100
|
||||||
|
compressionFormat: 1
|
||||||
|
quality: 1
|
||||||
|
conversionMode: 0
|
||||||
|
preloadAudioData: 0
|
||||||
|
platformSettingOverrides: {}
|
||||||
|
forceToMono: 0
|
||||||
|
normalize: 1
|
||||||
|
loadInBackground: 0
|
||||||
|
ambisonic: 0
|
||||||
|
3D: 1
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,23 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 750d18f95edb138389d25fa240d4bebe
|
||||||
|
AudioImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 8
|
||||||
|
defaultSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
loadType: 0
|
||||||
|
sampleRateSetting: 0
|
||||||
|
sampleRateOverride: 44100
|
||||||
|
compressionFormat: 1
|
||||||
|
quality: 1
|
||||||
|
conversionMode: 0
|
||||||
|
preloadAudioData: 0
|
||||||
|
platformSettingOverrides: {}
|
||||||
|
forceToMono: 0
|
||||||
|
normalize: 1
|
||||||
|
loadInBackground: 0
|
||||||
|
ambisonic: 0
|
||||||
|
3D: 1
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,23 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b14c103790e60da69ae477940a6f3951
|
||||||
|
AudioImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 8
|
||||||
|
defaultSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
loadType: 0
|
||||||
|
sampleRateSetting: 0
|
||||||
|
sampleRateOverride: 44100
|
||||||
|
compressionFormat: 1
|
||||||
|
quality: 1
|
||||||
|
conversionMode: 0
|
||||||
|
preloadAudioData: 0
|
||||||
|
platformSettingOverrides: {}
|
||||||
|
forceToMono: 0
|
||||||
|
normalize: 1
|
||||||
|
loadInBackground: 0
|
||||||
|
ambisonic: 0
|
||||||
|
3D: 1
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,23 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 519cfc8632246818cb25372742c8fd8f
|
||||||
|
AudioImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 8
|
||||||
|
defaultSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
loadType: 0
|
||||||
|
sampleRateSetting: 0
|
||||||
|
sampleRateOverride: 44100
|
||||||
|
compressionFormat: 1
|
||||||
|
quality: 1
|
||||||
|
conversionMode: 0
|
||||||
|
preloadAudioData: 0
|
||||||
|
platformSettingOverrides: {}
|
||||||
|
forceToMono: 0
|
||||||
|
normalize: 1
|
||||||
|
loadInBackground: 0
|
||||||
|
ambisonic: 0
|
||||||
|
3D: 1
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -946,6 +946,8 @@ GameObject:
|
|||||||
- component: {fileID: 330585545}
|
- component: {fileID: 330585545}
|
||||||
- component: {fileID: 330585544}
|
- component: {fileID: 330585544}
|
||||||
- component: {fileID: 330585547}
|
- component: {fileID: 330585547}
|
||||||
|
- component: {fileID: 330585549}
|
||||||
|
- component: {fileID: 330585548}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Main Camera
|
m_Name: Main Camera
|
||||||
m_TagString: MainCamera
|
m_TagString: MainCamera
|
||||||
@@ -1071,6 +1073,126 @@ MonoBehaviour:
|
|||||||
m_VarianceClampScale: 0.9
|
m_VarianceClampScale: 0.9
|
||||||
m_ContrastAdaptiveSharpening: 0
|
m_ContrastAdaptiveSharpening: 0
|
||||||
m_Version: 2
|
m_Version: 2
|
||||||
|
--- !u!114 &330585548
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 330585543}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 083c97d5b5c3da8408586386bf771491, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: '::'
|
||||||
|
clips:
|
||||||
|
- key: WordAdd
|
||||||
|
value: {fileID: 8300000, guid: b14c103790e60da69ae477940a6f3951, type: 3}
|
||||||
|
- key: WordRemove
|
||||||
|
value: {fileID: 8300000, guid: 519cfc8632246818cb25372742c8fd8f, type: 3}
|
||||||
|
- key: Select
|
||||||
|
value: {fileID: 8300000, guid: 8e32ddd55d6efe6e383b392b08cbe107, type: 3}
|
||||||
|
speech:
|
||||||
|
- {fileID: 8300000, guid: 8031864ce1c982d53913a027ea97577f, type: 3}
|
||||||
|
- {fileID: 8300000, guid: 06e03c52b213e965ab19f5ee87a7c02a, type: 3}
|
||||||
|
- {fileID: 8300000, guid: 750d18f95edb138389d25fa240d4bebe, type: 3}
|
||||||
|
--- !u!82 &330585549
|
||||||
|
AudioSource:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 330585543}
|
||||||
|
m_Enabled: 1
|
||||||
|
serializedVersion: 4
|
||||||
|
OutputAudioMixerGroup: {fileID: 0}
|
||||||
|
m_audioClip: {fileID: 0}
|
||||||
|
m_Resource: {fileID: 0}
|
||||||
|
m_PlayOnAwake: 1
|
||||||
|
m_Volume: 1
|
||||||
|
m_Pitch: 1
|
||||||
|
Loop: 0
|
||||||
|
Mute: 0
|
||||||
|
Spatialize: 0
|
||||||
|
SpatializePostEffects: 0
|
||||||
|
Priority: 128
|
||||||
|
DopplerLevel: 1
|
||||||
|
MinDistance: 1
|
||||||
|
MaxDistance: 500
|
||||||
|
Pan2D: 0
|
||||||
|
rolloffMode: 0
|
||||||
|
BypassEffects: 0
|
||||||
|
BypassListenerEffects: 0
|
||||||
|
BypassReverbZones: 0
|
||||||
|
rolloffCustomCurve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 1
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
panLevelCustomCurve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
spreadCustomCurve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
reverbZoneMixCustomCurve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 1
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
--- !u!1 &400817401
|
--- !u!1 &400817401
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using Utils;
|
||||||
|
using Utils.Utils;
|
||||||
|
|
||||||
|
public class AudioManager : Singleton<AudioManager>
|
||||||
|
{
|
||||||
|
private AudioSource audioSource;
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
private List<GameEntry<AudioClip>> clips = new List<GameEntry<AudioClip>>();
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
private List<AudioClip> speech = new List<AudioClip>();
|
||||||
|
|
||||||
|
private
|
||||||
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
audioSource = GetComponent<AudioSource>();
|
||||||
|
audioSource.pitch = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PlaySound(string type)
|
||||||
|
{
|
||||||
|
audioSource.pitch = 1f;
|
||||||
|
audioSource.PlayOneShot(clips.ByKey(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void PlaySpeechSound(bool pitchDown)
|
||||||
|
{
|
||||||
|
int index = Random.Range(0, speech.Count);
|
||||||
|
audioSource.pitch = pitchDown ? 0.5f:1f;
|
||||||
|
audioSource.PlayOneShot(speech[index], 1.5f);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 083c97d5b5c3da8408586386bf771491
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using DefaultNamespace;
|
using DefaultNamespace;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
@@ -133,11 +134,11 @@ public class DialogManager : Singleton<DialogManager>
|
|||||||
|
|
||||||
option.GetComponent<Button>().onClick.AddListener(() =>
|
option.GetComponent<Button>().onClick.AddListener(() =>
|
||||||
{
|
{
|
||||||
|
AudioManager.Instance.PlaySound("WordAdd");
|
||||||
if (kvp.Value is JValue)
|
if (kvp.Value is JValue)
|
||||||
{
|
{
|
||||||
AddQuestionInfill(currentItem, kvp.Key + "?");
|
AddQuestionInfill(currentItem, kvp.Key + "?");
|
||||||
Debug.LogError("ready");
|
|
||||||
currentItem = null;
|
currentItem = null;
|
||||||
AskButton.SetActive(true);
|
AskButton.SetActive(true);
|
||||||
FullQuestion = kvp.Value.ToString();
|
FullQuestion = kvp.Value.ToString();
|
||||||
@@ -161,6 +162,7 @@ public class DialogManager : Singleton<DialogManager>
|
|||||||
|
|
||||||
public void BackButtonPress()
|
public void BackButtonPress()
|
||||||
{
|
{
|
||||||
|
AudioManager.Instance.PlaySound("WordRemove");
|
||||||
if (questionStack.Count == 0)
|
if (questionStack.Count == 0)
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
@@ -173,9 +175,9 @@ public class DialogManager : Singleton<DialogManager>
|
|||||||
Destroy(infil);
|
Destroy(infil);
|
||||||
|
|
||||||
|
|
||||||
//this might be buggy, or might miraculuisly work
|
//aaaaaaaaaaaaaaaaaaaaaaaa
|
||||||
//if options start dissapearing randomly, look here
|
//aaaaaaaaaaaaaaaaaaaaaaaa
|
||||||
if (item.StartsWith("NOREC_"))
|
if (parent.ContainsKey(item) && parent[item] is JObject && (parent[item] as JObject).ContainsKey("QUESTION"))
|
||||||
{
|
{
|
||||||
recursiveDepth--;
|
recursiveDepth--;
|
||||||
FullQuestionPrefixes.Pop();
|
FullQuestionPrefixes.Pop();
|
||||||
@@ -186,6 +188,7 @@ public class DialogManager : Singleton<DialogManager>
|
|||||||
|
|
||||||
public void SubmitButtonPress()
|
public void SubmitButtonPress()
|
||||||
{
|
{
|
||||||
|
AudioManager.Instance.PlaySound("Select");
|
||||||
//formulate query string in format PERPSECTIVE%ITEM#PROPERTY
|
//formulate query string in format PERPSECTIVE%ITEM#PROPERTY
|
||||||
//slightly wack way of doing it, hoping it is future proof
|
//slightly wack way of doing it, hoping it is future proof
|
||||||
while (FullQuestionPrefixes.Count > 0)
|
while (FullQuestionPrefixes.Count > 0)
|
||||||
|
|||||||
@@ -2,14 +2,15 @@ using UnityEngine;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using Utils;
|
using Utils;
|
||||||
|
using Utils.Utils;
|
||||||
|
|
||||||
public class LevelLoader : Singleton<LevelLoader>
|
public class LevelLoader : Singleton<LevelLoader>
|
||||||
{
|
{
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private List<GameObjectEntry> DoorPrefabs;
|
private List<GameEntry<GameObject>> DoorPrefabs;
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private List<GameObjectEntry> GuardPrefabs;
|
private List<GameEntry<GameObject>> GuardPrefabs;
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private List<TextAsset> levels;
|
private List<TextAsset> levels;
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ public class SpeechManager : Singleton<SpeechManager>
|
|||||||
[CanBeNull] private string fulltext;
|
[CanBeNull] private string fulltext;
|
||||||
private Coroutine ccoroutine;
|
private Coroutine ccoroutine;
|
||||||
|
|
||||||
|
private string speaker;
|
||||||
|
|
||||||
|
|
||||||
public string Status = "TALKING";
|
public string Status = "TALKING";
|
||||||
|
|
||||||
@@ -67,10 +69,11 @@ public class SpeechManager : Singleton<SpeechManager>
|
|||||||
|
|
||||||
private void NextText()
|
private void NextText()
|
||||||
{
|
{
|
||||||
|
AudioManager.Instance.PlaySound("Select");
|
||||||
var item = textBuffer.Dequeue();
|
var item = textBuffer.Dequeue();
|
||||||
ccoroutine = StartCoroutine(TypeTextUncapped(item.Key));
|
ccoroutine = StartCoroutine(TypeTextUncapped(item.Key));
|
||||||
|
|
||||||
var speaker = item.Value;
|
speaker = item.Value;
|
||||||
|
|
||||||
if (speaker == "PLAYER")
|
if (speaker == "PLAYER")
|
||||||
{
|
{
|
||||||
@@ -99,10 +102,12 @@ public class SpeechManager : Singleton<SpeechManager>
|
|||||||
char[] chars = line.ToCharArray();
|
char[] chars = line.ToCharArray();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
|
||||||
while (i < chars.Length)
|
while (i < chars.Length)
|
||||||
{
|
{
|
||||||
if (timer < Time.deltaTime)
|
if (timer < Time.deltaTime)
|
||||||
{
|
{
|
||||||
|
AudioManager.Instance.PlaySpeechSound(speaker != "PLAYER");
|
||||||
textBuffer += chars[i];
|
textBuffer += chars[i];
|
||||||
mainText.text = textBuffer;
|
mainText.text = textBuffer;
|
||||||
timer += interval;
|
timer += interval;
|
||||||
|
|||||||
@@ -4,16 +4,21 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace Utils
|
namespace Utils
|
||||||
{
|
{
|
||||||
|
namespace Utils
|
||||||
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class GameObjectEntry
|
public class GameEntry<T>
|
||||||
{
|
{
|
||||||
public string key;
|
public string key;
|
||||||
public GameObject value;
|
public T value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class GameObjectEntryListExtensions
|
public static class GameObjectEntryListExtensions
|
||||||
{
|
{
|
||||||
public static GameObject ByKey(this List<GameObjectEntry> entries, string key)
|
public static T ByKey<T>(
|
||||||
|
this List<GameEntry<T>> entries,
|
||||||
|
string key
|
||||||
|
) where T : class
|
||||||
{
|
{
|
||||||
foreach (var entry in entries)
|
foreach (var entry in entries)
|
||||||
{
|
{
|
||||||
@@ -24,5 +29,6 @@ namespace Utils
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user