mirror of
https://github.com/Ratstail91/Keep-It-Alive.git
synced 2025-11-29 02:24:27 +11:00
Added audio, it's finished
This commit is contained in:
8
Assets/Resources.meta
Normal file
8
Assets/Resources.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 65911971c649b6a879742f70d31d501f
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/Resources/Fire Cracks.ogg
Normal file
BIN
Assets/Resources/Fire Cracks.ogg
Normal file
Binary file not shown.
22
Assets/Resources/Fire Cracks.ogg.meta
Normal file
22
Assets/Resources/Fire Cracks.ogg.meta
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2ed31ce62ac0fd8b198268d252895d2f
|
||||||
|
AudioImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 6
|
||||||
|
defaultSettings:
|
||||||
|
loadType: 0
|
||||||
|
sampleRateSetting: 0
|
||||||
|
sampleRateOverride: 44100
|
||||||
|
compressionFormat: 1
|
||||||
|
quality: 1
|
||||||
|
conversionMode: 0
|
||||||
|
platformSettingOverrides: {}
|
||||||
|
forceToMono: 0
|
||||||
|
normalize: 1
|
||||||
|
preloadAudioData: 1
|
||||||
|
loadInBackground: 0
|
||||||
|
ambisonic: 0
|
||||||
|
3D: 1
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/Resources/Fire.ogg
Normal file
BIN
Assets/Resources/Fire.ogg
Normal file
Binary file not shown.
22
Assets/Resources/Fire.ogg.meta
Normal file
22
Assets/Resources/Fire.ogg.meta
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0b58c959db13665d0a948b9c284f2f79
|
||||||
|
AudioImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 6
|
||||||
|
defaultSettings:
|
||||||
|
loadType: 0
|
||||||
|
sampleRateSetting: 0
|
||||||
|
sampleRateOverride: 44100
|
||||||
|
compressionFormat: 1
|
||||||
|
quality: 1
|
||||||
|
conversionMode: 0
|
||||||
|
platformSettingOverrides: {}
|
||||||
|
forceToMono: 0
|
||||||
|
normalize: 1
|
||||||
|
preloadAudioData: 1
|
||||||
|
loadInBackground: 0
|
||||||
|
ambisonic: 0
|
||||||
|
3D: 1
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/Resources/Hunted.ogg
Normal file
BIN
Assets/Resources/Hunted.ogg
Normal file
Binary file not shown.
22
Assets/Resources/Hunted.ogg.meta
Normal file
22
Assets/Resources/Hunted.ogg.meta
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9c25236eb6c7d320584c7c90b1771990
|
||||||
|
AudioImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 6
|
||||||
|
defaultSettings:
|
||||||
|
loadType: 0
|
||||||
|
sampleRateSetting: 0
|
||||||
|
sampleRateOverride: 44100
|
||||||
|
compressionFormat: 1
|
||||||
|
quality: 1
|
||||||
|
conversionMode: 0
|
||||||
|
platformSettingOverrides: {}
|
||||||
|
forceToMono: 0
|
||||||
|
normalize: 1
|
||||||
|
preloadAudioData: 1
|
||||||
|
loadInBackground: 0
|
||||||
|
ambisonic: 0
|
||||||
|
3D: 1
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/Resources/Tree Cut.ogg
Normal file
BIN
Assets/Resources/Tree Cut.ogg
Normal file
Binary file not shown.
22
Assets/Resources/Tree Cut.ogg.meta
Normal file
22
Assets/Resources/Tree Cut.ogg.meta
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: af8c14d7d1d36749ab624a3aaf4bf012
|
||||||
|
AudioImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 6
|
||||||
|
defaultSettings:
|
||||||
|
loadType: 0
|
||||||
|
sampleRateSetting: 0
|
||||||
|
sampleRateOverride: 44100
|
||||||
|
compressionFormat: 1
|
||||||
|
quality: 1
|
||||||
|
conversionMode: 0
|
||||||
|
platformSettingOverrides: {}
|
||||||
|
forceToMono: 0
|
||||||
|
normalize: 1
|
||||||
|
preloadAudioData: 1
|
||||||
|
loadInBackground: 0
|
||||||
|
ambisonic: 0
|
||||||
|
3D: 1
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -236,6 +236,62 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: c8ef96580d66d15569418aaf508311d3, type: 3}
|
m_Script: {fileID: 11500000, guid: c8ef96580d66d15569418aaf508311d3, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
--- !u!1 &335870012
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 335870015}
|
||||||
|
- component: {fileID: 335870014}
|
||||||
|
- component: {fileID: 335870013}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: AudioController
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!114 &335870013
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 335870012}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: e9ef43588bdc8ffda9204b41ef5a58af, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
--- !u!114 &335870014
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 335870012}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 93eaa725ebfe1c77a8286d5fea05229a, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
--- !u!4 &335870015
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 335870012}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_RootOrder: 6
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &356894237
|
--- !u!1 &356894237
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -690,6 +746,7 @@ GameObject:
|
|||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 1628028771}
|
- component: {fileID: 1628028771}
|
||||||
- component: {fileID: 1628028770}
|
- component: {fileID: 1628028770}
|
||||||
|
- component: {fileID: 1628028772}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Level Controller
|
m_Name: Level Controller
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@@ -726,6 +783,18 @@ Transform:
|
|||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &1628028772
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1628028769}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 3d6a8f4dff66810239f482b0236a94d7, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
--- !u!1 &1629685493
|
--- !u!1 &1629685493
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -803,7 +872,7 @@ Canvas:
|
|||||||
m_SortingBucketNormalizedSize: 0
|
m_SortingBucketNormalizedSize: 0
|
||||||
m_AdditionalShaderChannelsFlag: 25
|
m_AdditionalShaderChannelsFlag: 25
|
||||||
m_SortingLayerID: 0
|
m_SortingLayerID: 0
|
||||||
m_SortingOrder: 0
|
m_SortingOrder: 32767
|
||||||
m_TargetDisplay: 0
|
m_TargetDisplay: 0
|
||||||
--- !u!224 &1629685497
|
--- !u!224 &1629685497
|
||||||
RectTransform:
|
RectTransform:
|
||||||
|
|||||||
212
Assets/Scripts/AudioController.cs
Normal file
212
Assets/Scripts/AudioController.cs
Normal file
@@ -0,0 +1,212 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class AudioController : MonoBehaviour {
|
||||||
|
//public structures
|
||||||
|
public enum Mode {
|
||||||
|
NONE,
|
||||||
|
ONCE,
|
||||||
|
LOOP,
|
||||||
|
JUMP
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct AudioContainer {
|
||||||
|
public AudioSource source;
|
||||||
|
public Mode mode;
|
||||||
|
public float jumpStart;
|
||||||
|
public float jumpEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
//internals
|
||||||
|
Dictionary<string, AudioContainer> audioDictionary = new Dictionary<string, AudioContainer>();
|
||||||
|
static bool initialized = false;
|
||||||
|
|
||||||
|
//monobehaviour methods
|
||||||
|
void Awake() {
|
||||||
|
if (initialized) {
|
||||||
|
Destroy(gameObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
initialized = true;
|
||||||
|
|
||||||
|
DontDestroyOnLoad(gameObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update() {
|
||||||
|
foreach(KeyValuePair<string, AudioContainer> iter in audioDictionary) {
|
||||||
|
//handle the jump points
|
||||||
|
if (iter.Value.mode == Mode.JUMP && iter.Value.jumpStart >= 0f && iter.Value.jumpEnd > 0f) {
|
||||||
|
if (iter.Value.source.time >= iter.Value.jumpEnd) {
|
||||||
|
iter.Value.source.time = iter.Value.jumpStart;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnDestroy() {
|
||||||
|
foreach(KeyValuePair<string, AudioContainer> iter in audioDictionary) {
|
||||||
|
Resources.UnloadAsset(iter.Value.source.clip);
|
||||||
|
Destroy(iter.Value.source);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//public access members
|
||||||
|
public void Load(string name, string filename) {
|
||||||
|
AudioContainer container = new AudioContainer();
|
||||||
|
|
||||||
|
container.source = gameObject.AddComponent(typeof(AudioSource)) as AudioSource;
|
||||||
|
container.source.clip = Resources.Load<AudioClip>(filename) as AudioClip;
|
||||||
|
container.source.volume = 0f;
|
||||||
|
container.mode = Mode.NONE;
|
||||||
|
|
||||||
|
audioDictionary[name] = container;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Unload(string name) {
|
||||||
|
if (!audioDictionary.ContainsKey(name)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
AudioContainer container = audioDictionary[name];
|
||||||
|
|
||||||
|
Resources.UnloadAsset(container.source.clip);
|
||||||
|
Destroy(container.source);
|
||||||
|
|
||||||
|
audioDictionary.Remove(name);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//controls
|
||||||
|
public void Play(string name, Mode mode = Mode.ONCE, float jumpStart = -1f, float jumpEnd = -1f) {
|
||||||
|
AudioContainer container = audioDictionary[name];
|
||||||
|
|
||||||
|
container.source.Play();
|
||||||
|
container.source.loop = mode == Mode.LOOP;
|
||||||
|
container.source.volume = 1f;
|
||||||
|
container.mode = mode;
|
||||||
|
container.jumpStart = jumpStart;
|
||||||
|
container.jumpEnd = jumpEnd;
|
||||||
|
audioDictionary[name] = container;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Pause(string name) {
|
||||||
|
AudioContainer container = audioDictionary[name];
|
||||||
|
|
||||||
|
container.source.Pause();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Unpause(string name, Mode mode = Mode.ONCE, float jumpStart = -1f, float jumpEnd = -1f) {
|
||||||
|
AudioContainer container = audioDictionary[name];
|
||||||
|
|
||||||
|
if (container.source.isPlaying) {
|
||||||
|
container.source.UnPause();
|
||||||
|
} else {
|
||||||
|
Play(name, mode, jumpStart, jumpEnd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Stop(string name) {
|
||||||
|
AudioContainer container = audioDictionary[name];
|
||||||
|
|
||||||
|
container.source.Stop();
|
||||||
|
container.mode = Mode.NONE;
|
||||||
|
|
||||||
|
audioDictionary[name] = container;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StopAll() {
|
||||||
|
List<string> names = new List<string>();
|
||||||
|
foreach(KeyValuePair<string, AudioContainer> iter in audioDictionary) {
|
||||||
|
names.Add(iter.Key);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach(string name in names) {
|
||||||
|
Stop(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//fade controls
|
||||||
|
public void FadeIn(string name, float seconds) {
|
||||||
|
StartCoroutine(FadeInCallback(audioDictionary[name].source, 1f/seconds));
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator FadeInCallback(AudioSource source, float amountPerSecond) {
|
||||||
|
source.volume = 0;
|
||||||
|
while (source.volume < 1f) {
|
||||||
|
yield return new WaitForSeconds(0.1f);
|
||||||
|
source.volume += amountPerSecond / 10f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void FadeOut(string name, float seconds) {
|
||||||
|
StartCoroutine(FadeOutCallback(audioDictionary[name].source, 1f/seconds));
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator FadeOutCallback(AudioSource source, float amountPerSecond) {
|
||||||
|
while (source.volume > 0f) {
|
||||||
|
yield return new WaitForSeconds(0.1f);
|
||||||
|
source.volume -= amountPerSecond / 10f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//hybrid controls
|
||||||
|
public void PlayFadeIn(string name, float seconds, Mode mode = Mode.ONCE, float jumpStart = -1f, float jumpEnd = -1f) {
|
||||||
|
FadeIn(name, seconds);
|
||||||
|
Play(name, mode, jumpStart, jumpEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PauseFadeOut(string name, float seconds) {
|
||||||
|
FadeOut(name, seconds);
|
||||||
|
StartCoroutine(PauseFadeOutCallback(name, seconds));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PauseFadeOutAll(float seconds, List<string> exclude = null) {
|
||||||
|
foreach(KeyValuePair<string, AudioContainer> iter in audioDictionary) {
|
||||||
|
if (exclude != null && exclude.Contains(iter.Key)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
FadeOut(iter.Key, seconds);
|
||||||
|
StartCoroutine(PauseFadeOutCallback(iter.Key, seconds));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator PauseFadeOutCallback(string name, float seconds) {
|
||||||
|
yield return new WaitForSeconds(seconds);
|
||||||
|
Pause(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UnpauseFadeIn(string name, float seconds, Mode mode = Mode.ONCE, float jumpStart = -1f, float jumpEnd = -1f) {
|
||||||
|
Unpause(name, mode, jumpStart, jumpEnd);
|
||||||
|
FadeIn(name, seconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StopFadeOut(string name, float seconds) {
|
||||||
|
FadeOut(name, seconds);
|
||||||
|
StartCoroutine(StopFadeOutCallback(name, seconds));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StopFadeOutAll(float seconds, List<string> exclude = null) {
|
||||||
|
foreach(KeyValuePair<string, AudioContainer> iter in audioDictionary) {
|
||||||
|
if (exclude != null && exclude.Contains(iter.Key)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
FadeOut(iter.Key, seconds);
|
||||||
|
StartCoroutine(StopFadeOutCallback(iter.Key, seconds));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator StopFadeOutCallback(string name, float seconds) {
|
||||||
|
yield return new WaitForSeconds(seconds);
|
||||||
|
Stop(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
//status
|
||||||
|
public bool GetPlaying(string name) {
|
||||||
|
return audioDictionary[name].source.isPlaying;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Mode GetMode(string name) {
|
||||||
|
return audioDictionary[name].mode;
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Scripts/AudioController.cs.meta
Normal file
11
Assets/Scripts/AudioController.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 93eaa725ebfe1c77a8286d5fea05229a
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
18
Assets/Scripts/AudioMainMenu.cs
Normal file
18
Assets/Scripts/AudioMainMenu.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class AudioMainMenu : MonoBehaviour {
|
||||||
|
AudioController controller;
|
||||||
|
|
||||||
|
void Start() {
|
||||||
|
controller = GameObject.Find("AudioController").GetComponent<AudioController>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update() {
|
||||||
|
//won't work in start, for some reason
|
||||||
|
if (controller.GetPlaying("fire") == false) {
|
||||||
|
controller.Play("fire", AudioController.Mode.LOOP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Scripts/AudioMainMenu.cs.meta
Normal file
11
Assets/Scripts/AudioMainMenu.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3d6a8f4dff66810239f482b0236a94d7
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
14
Assets/Scripts/AudioStartup.cs
Normal file
14
Assets/Scripts/AudioStartup.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class AudioStartup : MonoBehaviour {
|
||||||
|
AudioController controller;
|
||||||
|
void Awake() {
|
||||||
|
controller = GetComponent<AudioController>();
|
||||||
|
controller.Load("fire", "Fire");
|
||||||
|
controller.Load("crackle", "Fire Cracks");
|
||||||
|
controller.Load("cut", "Tree Cut");
|
||||||
|
controller.Load("hunted", "Hunted");
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Scripts/AudioStartup.cs.meta
Normal file
11
Assets/Scripts/AudioStartup.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e9ef43588bdc8ffda9204b41ef5a58af
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -5,12 +5,16 @@ using UnityEngine.SceneManagement;
|
|||||||
|
|
||||||
public class Claws : MonoBehaviour {
|
public class Claws : MonoBehaviour {
|
||||||
SpriteRenderer spriteRenderer;
|
SpriteRenderer spriteRenderer;
|
||||||
|
AudioController audioController;
|
||||||
|
|
||||||
void Awake() {
|
void Awake() {
|
||||||
spriteRenderer = GetComponent<SpriteRenderer>();
|
spriteRenderer = GetComponent<SpriteRenderer>();
|
||||||
|
audioController = GameObject.Find("AudioController").GetComponent<AudioController>();
|
||||||
|
|
||||||
StartCoroutine(FadeOverTime(2f));
|
StartCoroutine(FadeOverTime(2f));
|
||||||
StartCoroutine(SwitchScenesAfter("MainMenu", 5f));
|
StartCoroutine(SwitchScenesAfter("MainMenu", 5f));
|
||||||
|
|
||||||
|
audioController.StopAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerator FadeOverTime(float delay) {
|
IEnumerator FadeOverTime(float delay) {
|
||||||
|
|||||||
@@ -4,9 +4,14 @@ using UnityEngine;
|
|||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
public class FireGoesOut : MonoBehaviour {
|
public class FireGoesOut : MonoBehaviour {
|
||||||
|
AudioController audioController;
|
||||||
|
|
||||||
void Awake() {
|
void Awake() {
|
||||||
//TODO: play extinguished sound
|
audioController = GameObject.Find("AudioController").GetComponent<AudioController>();
|
||||||
|
|
||||||
StartCoroutine(SwitchScenesAfter("MainMenu", 3f));
|
StartCoroutine(SwitchScenesAfter("MainMenu", 3f));
|
||||||
|
|
||||||
|
audioController.StopAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerator SwitchScenesAfter(string sceneName, float delay) {
|
IEnumerator SwitchScenesAfter(string sceneName, float delay) {
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ using UnityEngine;
|
|||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
public class Character : MonoBehaviour {
|
public class Character : MonoBehaviour {
|
||||||
|
//references
|
||||||
|
AudioController audioController;
|
||||||
|
|
||||||
//components
|
//components
|
||||||
SpriteRenderer spriteRenderer;
|
SpriteRenderer spriteRenderer;
|
||||||
Rigidbody2D rb;
|
Rigidbody2D rb;
|
||||||
@@ -22,6 +25,8 @@ public class Character : MonoBehaviour {
|
|||||||
float huntingTime;
|
float huntingTime;
|
||||||
|
|
||||||
void Awake() {
|
void Awake() {
|
||||||
|
audioController = GameObject.Find("AudioController").GetComponent<AudioController>();
|
||||||
|
|
||||||
spriteRenderer = GetComponent<SpriteRenderer>();
|
spriteRenderer = GetComponent<SpriteRenderer>();
|
||||||
rb = GetComponent<Rigidbody2D>();
|
rb = GetComponent<Rigidbody2D>();
|
||||||
fadeToBlack = GetComponent<FadeToBlack>();
|
fadeToBlack = GetComponent<FadeToBlack>();
|
||||||
@@ -75,8 +80,13 @@ public class Character : MonoBehaviour {
|
|||||||
void HandleHunted() {
|
void HandleHunted() {
|
||||||
if (fadeToBlack.brightness < 0f) {
|
if (fadeToBlack.brightness < 0f) {
|
||||||
huntingTime -= Time.deltaTime;
|
huntingTime -= Time.deltaTime;
|
||||||
|
|
||||||
|
if (!audioController.GetPlaying("hunted")) {
|
||||||
|
audioController.Play("hunted");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
huntingTime = 3f;
|
huntingTime = 3f;
|
||||||
|
audioController.Stop("hunted");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (huntingTime <= 0f) {
|
if (huntingTime <= 0f) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using UnityEngine;
|
|||||||
public class Fire : MonoBehaviour {
|
public class Fire : MonoBehaviour {
|
||||||
Animator animator;
|
Animator animator;
|
||||||
LevelController levelController;
|
LevelController levelController;
|
||||||
|
AudioController audioController;
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
int size = 1;
|
int size = 1;
|
||||||
@@ -12,6 +13,7 @@ public class Fire : MonoBehaviour {
|
|||||||
void Awake() {
|
void Awake() {
|
||||||
animator = GetComponent<Animator>();
|
animator = GetComponent<Animator>();
|
||||||
levelController = GameObject.Find("Level Controller").GetComponent<LevelController>();
|
levelController = GameObject.Find("Level Controller").GetComponent<LevelController>();
|
||||||
|
audioController = GameObject.Find("AudioController").GetComponent<AudioController>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Start() {
|
void Start() {
|
||||||
@@ -38,6 +40,8 @@ public class Fire : MonoBehaviour {
|
|||||||
levelController.globalWood -= 1;
|
levelController.globalWood -= 1;
|
||||||
levelController.globalLightLevel += 0.2f;
|
levelController.globalLightLevel += 0.2f;
|
||||||
levelController.globalLightLevel = Mathf.Clamp(levelController.globalLightLevel, 0f, 1f);
|
levelController.globalLightLevel = Mathf.Clamp(levelController.globalLightLevel, 0f, 1f);
|
||||||
|
|
||||||
|
audioController.Play("crackle");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using UnityEngine;
|
|||||||
|
|
||||||
public class Tree : MonoBehaviour {
|
public class Tree : MonoBehaviour {
|
||||||
static LevelController levelController;
|
static LevelController levelController;
|
||||||
|
static AudioController audioController;
|
||||||
static GameObject character;
|
static GameObject character;
|
||||||
|
|
||||||
SpriteRenderer spriteRenderer;
|
SpriteRenderer spriteRenderer;
|
||||||
@@ -19,6 +20,10 @@ public class Tree : MonoBehaviour {
|
|||||||
levelController = GameObject.Find("Level Controller").GetComponent<LevelController>();
|
levelController = GameObject.Find("Level Controller").GetComponent<LevelController>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!audioController) {
|
||||||
|
audioController = GameObject.Find("AudioController").GetComponent<AudioController>();
|
||||||
|
}
|
||||||
|
|
||||||
if (!character) {
|
if (!character) {
|
||||||
character = GameObject.Find("Character");
|
character = GameObject.Find("Character");
|
||||||
}
|
}
|
||||||
@@ -28,6 +33,8 @@ public class Tree : MonoBehaviour {
|
|||||||
if (GamePad.GetState().Pressed(CButton.Y)) {
|
if (GamePad.GetState().Pressed(CButton.Y)) {
|
||||||
life -= 1;
|
life -= 1;
|
||||||
|
|
||||||
|
audioController.Play("cut");
|
||||||
|
|
||||||
//wiggle
|
//wiggle
|
||||||
StartCoroutine(Wiggle());
|
StartCoroutine(Wiggle());
|
||||||
|
|
||||||
|
|||||||
BIN
Audio/Fire Raw.aac
Normal file
BIN
Audio/Fire Raw.aac
Normal file
Binary file not shown.
BIN
Audio/cut_tree.wav
Normal file
BIN
Audio/cut_tree.wav
Normal file
Binary file not shown.
BIN
Audio/hunted.wav
Normal file
BIN
Audio/hunted.wav
Normal file
Binary file not shown.
@@ -12,7 +12,7 @@ PlayerSettings:
|
|||||||
targetDevice: 2
|
targetDevice: 2
|
||||||
useOnDemandResources: 0
|
useOnDemandResources: 0
|
||||||
accelerometerFrequency: 60
|
accelerometerFrequency: 60
|
||||||
companyName: DefaultCompany
|
companyName: KR Game Studios
|
||||||
productName: Keep It Alive
|
productName: Keep It Alive
|
||||||
defaultCursor: {fileID: 0}
|
defaultCursor: {fileID: 0}
|
||||||
cursorHotspot: {x: 0, y: 0}
|
cursorHotspot: {x: 0, y: 0}
|
||||||
@@ -119,7 +119,7 @@ PlayerSettings:
|
|||||||
16:10: 1
|
16:10: 1
|
||||||
16:9: 1
|
16:9: 1
|
||||||
Others: 1
|
Others: 1
|
||||||
bundleVersion: 0.1
|
bundleVersion: 1.0
|
||||||
preloadedAssets: []
|
preloadedAssets: []
|
||||||
metroInputSource: 0
|
metroInputSource: 0
|
||||||
wsaTransparentSwapchain: 0
|
wsaTransparentSwapchain: 0
|
||||||
|
|||||||
Reference in New Issue
Block a user