Audio Implementation for AI
This commit is contained in:
parent
e5479c31c5
commit
1d0522e334
|
@ -0,0 +1,16 @@
|
||||||
|
using SHADE;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SHADE_Scripting.Audio
|
||||||
|
{
|
||||||
|
public static class AudioHandler
|
||||||
|
{
|
||||||
|
public static Dictionary<string, AudioClipHandler> audioClipHandlers = new Dictionary<string, AudioClipHandler>();
|
||||||
|
|
||||||
|
//Functions here, maybe
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
Name: AudioHandler
|
||||||
|
ID: 159235425
|
||||||
|
Type: 9
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
using SHADE;
|
using SHADE;
|
||||||
using SHADE_Scripting.AIBehaviour.BehaviourTree;
|
using SHADE_Scripting.AIBehaviour.BehaviourTree;
|
||||||
|
using SHADE_Scripting.Audio;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -99,6 +100,23 @@ public partial class Homeowner1 : BehaviourTree
|
||||||
SetData("turningSpeed", turningSpeed);
|
SetData("turningSpeed", turningSpeed);
|
||||||
SetData("distanceToCapture", distanceToCapture);
|
SetData("distanceToCapture", distanceToCapture);
|
||||||
SetData("baseCaptureTime", captureTime);*/
|
SetData("baseCaptureTime", captureTime);*/
|
||||||
|
|
||||||
|
|
||||||
|
//These should be somewhere else
|
||||||
|
AudioHandler.audioClipHandlers["BGMUnalert"] = Audio.CreateAudioClip("event:/Music/player_undetected");
|
||||||
|
Audio.AddAudioClipToBGMChannelGroup(AudioHandler.audioClipHandlers["BGMUnalert"]);
|
||||||
|
AudioHandler.audioClipHandlers["BGMAlert"] = Audio.CreateAudioClip("event:/Music/player_detected");
|
||||||
|
Audio.AddAudioClipToBGMChannelGroup(AudioHandler.audioClipHandlers["BGMAlert"]);
|
||||||
|
|
||||||
|
AudioHandler.audioClipHandlers["SFXHumming"] = Audio.CreateAudioClip("event:/Homeowner/homeowner_humming");
|
||||||
|
Audio.AddAudioClipToSFXChannelGroup(AudioHandler.audioClipHandlers["SFXHumming"]);
|
||||||
|
AudioHandler.audioClipHandlers["SFXFootstep"] = Audio.CreateAudioClip("event:/Homeowner/homeowner_footsteps");
|
||||||
|
Audio.AddAudioClipToSFXChannelGroup(AudioHandler.audioClipHandlers["SFXFootstep"]);
|
||||||
|
AudioHandler.audioClipHandlers["SFXDetectAh"] = Audio.CreateAudioClip("event:/Homeowner/homeowner_detect_raccoon");
|
||||||
|
Audio.AddAudioClipToSFXChannelGroup(AudioHandler.audioClipHandlers["SFXDetectAh"]);
|
||||||
|
AudioHandler.audioClipHandlers["SFXDetectSting"] = Audio.CreateAudioClip("event:/Music/stingers/player_detected");
|
||||||
|
Audio.AddAudioClipToSFXChannelGroup(AudioHandler.audioClipHandlers["SFXDetectSting"]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Called every tick
|
//Called every tick
|
||||||
|
@ -132,7 +150,6 @@ public partial class Homeowner1 : BehaviourTree
|
||||||
if (GetData("baseCaptureTime") == null || (float)GetData("baseCaptureTime") != captureTime)
|
if (GetData("baseCaptureTime") == null || (float)GetData("baseCaptureTime") != captureTime)
|
||||||
SetData("baseCaptureTime", captureTime);
|
SetData("baseCaptureTime", captureTime);
|
||||||
|
|
||||||
|
|
||||||
events.Tick();
|
events.Tick();
|
||||||
|
|
||||||
//Footsteps SFX, move them somewhere else soon
|
//Footsteps SFX, move them somewhere else soon
|
||||||
|
@ -142,6 +159,7 @@ public partial class Homeowner1 : BehaviourTree
|
||||||
if (footstepTimeRemaining < 0.0f)
|
if (footstepTimeRemaining < 0.0f)
|
||||||
{
|
{
|
||||||
Audio.PlaySFXOnce2D("event:/Homeowner/homeowner_footsteps");
|
Audio.PlaySFXOnce2D("event:/Homeowner/homeowner_footsteps");
|
||||||
|
AudioHandler.audioClipHandlers["SFXFootstep"].Play();
|
||||||
footstepTimeRemaining = footstepSFXIntervalMultiplier;
|
footstepTimeRemaining = footstepSFXIntervalMultiplier;
|
||||||
}
|
}
|
||||||
//Debug.Log("Ticked");
|
//Debug.Log("Ticked");
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
using SHADE;
|
using SHADE;
|
||||||
using SHADE_Scripting.AIBehaviour.BehaviourTree;
|
using SHADE_Scripting.AIBehaviour.BehaviourTree;
|
||||||
|
using SHADE_Scripting.Audio;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -111,7 +112,7 @@ public partial class LeafChase : BehaviourTreeNode
|
||||||
|
|
||||||
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert") == true)
|
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert") == true)
|
||||||
{
|
{
|
||||||
Audio.PlaySFXOnce2D("event:/Homeowner/humming");
|
AudioHandler.audioClipHandlers["SFXHumming"].Play();
|
||||||
}
|
}
|
||||||
SetNodeData("isAlert", false);
|
SetNodeData("isAlert", false);
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
using SHADE;
|
using SHADE;
|
||||||
using SHADE_Scripting.AIBehaviour.BehaviourTree;
|
using SHADE_Scripting.AIBehaviour.BehaviourTree;
|
||||||
|
using SHADE_Scripting.Audio;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -239,9 +240,10 @@ public partial class LeafPatrol : BehaviourTreeNode
|
||||||
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert"))
|
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert"))
|
||||||
{
|
{
|
||||||
//Debug.Log("Unalert");
|
//Debug.Log("Unalert");
|
||||||
Audio.PlaySFXOnce2D("event:/Homeowner/humming");
|
AudioHandler.audioClipHandlers["BGMAlert"].Stop(true);
|
||||||
Audio.StopAllSounds();
|
//Audio.PlaySFXOnce2D("event:/Homeowner/humming");
|
||||||
Audio.PlayBGMOnce2D("event:/Music/player_undetected");
|
AudioHandler.audioClipHandlers["SFXHumming"].Play();
|
||||||
|
AudioHandler.audioClipHandlers["BGMUnalert"].Play();
|
||||||
}
|
}
|
||||||
SetNodeData("isAlert", false);
|
SetNodeData("isAlert", false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
using SHADE;
|
using SHADE;
|
||||||
using SHADE_Scripting.AIBehaviour.BehaviourTree;
|
using SHADE_Scripting.AIBehaviour.BehaviourTree;
|
||||||
|
using SHADE_Scripting.Audio;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -65,7 +66,7 @@ public partial class LeafSearch : BehaviourTreeNode
|
||||||
{
|
{
|
||||||
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert") == true)
|
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert") == true)
|
||||||
{
|
{
|
||||||
Audio.PlaySFXOnce2D("event:/Homeowner/humming");
|
AudioHandler.audioClipHandlers["SFXHumming"].Play();
|
||||||
reevaluateWaypoint();
|
reevaluateWaypoint();
|
||||||
}
|
}
|
||||||
SetNodeData("isAlert", false);
|
SetNodeData("isAlert", false);
|
||||||
|
@ -185,19 +186,23 @@ public partial class LeafSearch : BehaviourTreeNode
|
||||||
if (GetNodeData("isAlert") == null)
|
if (GetNodeData("isAlert") == null)
|
||||||
{
|
{
|
||||||
SetNodeData("isAlert", true);
|
SetNodeData("isAlert", true);
|
||||||
Audio.PlaySFXOnce2D("event:/Homeowner/homeowner_detect_raccoon");
|
|
||||||
Audio.PlaySFXOnce2D("event:/Music/stingers/player_detected");
|
|
||||||
Audio.StopAllSounds();
|
Audio.StopAllSounds();
|
||||||
Audio.PlayBGMOnce2D("event:/Music/player_detected");
|
AudioHandler.audioClipHandlers["SFXDetectAh"].Play();
|
||||||
|
AudioHandler.audioClipHandlers["SFXDetectSting"].Play();
|
||||||
|
AudioHandler.audioClipHandlers["BGMAlert"].Play();
|
||||||
|
AudioHandler.audioClipHandlers["SFXHumming"].Stop(false);
|
||||||
|
AudioHandler.audioClipHandlers["BGMUnalert"].Stop(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert") == false)
|
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert") == false)
|
||||||
{
|
{
|
||||||
Audio.PlaySFXOnce2D("event:/Homeowner/homeowner_detect_raccoon");
|
|
||||||
Audio.PlaySFXOnce2D("event:/Music/stingers/player_detected");
|
|
||||||
Audio.StopAllSounds();
|
Audio.StopAllSounds();
|
||||||
Audio.PlayBGMOnce2D("event:/Music/player_detected");
|
AudioHandler.audioClipHandlers["SFXDetectAh"].Play();
|
||||||
|
AudioHandler.audioClipHandlers["SFXDetectSting"].Play();
|
||||||
|
AudioHandler.audioClipHandlers["BGMAlert"].Play();
|
||||||
|
AudioHandler.audioClipHandlers["SFXHumming"].Stop(false);
|
||||||
|
AudioHandler.audioClipHandlers["BGMUnalert"].Stop(true);
|
||||||
}
|
}
|
||||||
SetNodeData("isAlert", true);
|
SetNodeData("isAlert", true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue