Merge branch 'main' into SP3-20-UI-System

This commit is contained in:
maverickdgg 2023-03-04 13:09:06 +08:00
commit f3908d3afb
12 changed files with 205 additions and 26 deletions

View File

@ -277,7 +277,12 @@
Position Offset: {x: 0, y: 0.5, z: 0} Position Offset: {x: 0, y: 0.5, z: 0}
Rotation Offset: {x: 0, y: 0, z: 0} Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true IsActive: true
Scripts: ~ Scripts:
- Type: SHADE_Scripting.Audio.SoundLoopEmitter
Enabled: true
clipHandlerName: SFXWash65
clipPath: event:/Props/washing_machine_loop
volume: 0.300000012
- EID: 66 - EID: 66
Name: washingMachineDoor Name: washingMachineDoor
IsActive: true IsActive: true
@ -418,7 +423,12 @@
Position Offset: {x: 0, y: 0.5, z: 0} Position Offset: {x: 0, y: 0.5, z: 0}
Rotation Offset: {x: 0, y: 0, z: 0} Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true IsActive: true
Scripts: ~ Scripts:
- Type: SHADE_Scripting.Audio.SoundLoopEmitter
Enabled: true
clipHandlerName: SFXWash43
clipPath: event:/Props/washing_machine_loop
volume: 0.300000012
- EID: 44 - EID: 44
Name: washingMachineDoor Name: washingMachineDoor
IsActive: true IsActive: true
@ -460,7 +470,12 @@
Position Offset: {x: 0, y: 0.5, z: 0} Position Offset: {x: 0, y: 0.5, z: 0}
Rotation Offset: {x: 0, y: 0, z: 0} Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true IsActive: true
Scripts: ~ Scripts:
- Type: SHADE_Scripting.Audio.SoundLoopEmitter
Enabled: true
clipHandlerName: SFXWash42
clipPath: event:/Props/washing_machine_loop
volume: 0.300000012
- EID: 131081 - EID: 131081
Name: washingMachineDoor Name: washingMachineDoor
IsActive: true IsActive: true
@ -4171,6 +4186,7 @@
- Type: Homeowner1 - Type: Homeowner1
Enabled: true Enabled: true
waypointsPool: 234 waypointsPool: 234
startWaypoint: 233
patrolSpeed: 3 patrolSpeed: 3
chaseSpeed: 6 chaseSpeed: 6
turningSpeed: 5 turningSpeed: 5

View File

@ -464,6 +464,8 @@
Enabled: true Enabled: true
threshHold: 0.5 threshHold: 0.5
ignoreRaccoon: true ignoreRaccoon: true
breakClipHandlerName: SFXEggBreak144
breakClipPath: event:/Props/impact_egg
- Type: Item - Type: Item
Enabled: true Enabled: true
Score: 10 Score: 10
@ -1652,6 +1654,8 @@
Enabled: true Enabled: true
threshHold: 4 threshHold: 4
ignoreRaccoon: true ignoreRaccoon: true
breakClipHandlerName: SFXWatermelonBreak464
breakClipPath: event:/Props/impact_watermelon_break
- Type: Item - Type: Item
Enabled: true Enabled: true
Score: 500 Score: 500
@ -2064,6 +2068,8 @@
Enabled: true Enabled: true
threshHold: 4 threshHold: 4
ignoreRaccoon: true ignoreRaccoon: true
breakClipHandlerName: SFXWatermelonBreak522
breakClipPath: event:/Props/impact_watermelon_break
- Type: Item - Type: Item
Enabled: true Enabled: true
Score: 500 Score: 500
@ -2374,6 +2380,8 @@
Enabled: true Enabled: true
threshHold: 4 threshHold: 4
ignoreRaccoon: true ignoreRaccoon: true
breakClipHandlerName: SFXWatermelonBreak156
breakClipPath: event:/Props/impact_watermelon_break
- Type: Item - Type: Item
Enabled: true Enabled: true
Score: 500 Score: 500
@ -2684,6 +2692,8 @@
Enabled: true Enabled: true
threshHold: 0.5 threshHold: 0.5
ignoreRaccoon: true ignoreRaccoon: true
breakClipHandlerName: SFXEggBreak533
breakClipPath: event:/Props/impact_egg
- Type: Item - Type: Item
Enabled: true Enabled: true
Score: 10 Score: 10
@ -2903,6 +2913,8 @@
Enabled: true Enabled: true
threshHold: 0.5 threshHold: 0.5
ignoreRaccoon: true ignoreRaccoon: true
breakClipHandlerName: SFXEggBreak538
breakClipPath: event:/Props/impact_egg
- Type: Item - Type: Item
Enabled: true Enabled: true
Score: 10 Score: 10
@ -3122,6 +3134,8 @@
Enabled: true Enabled: true
threshHold: 0.5 threshHold: 0.5
ignoreRaccoon: true ignoreRaccoon: true
breakClipHandlerName: SFXEggBreak543
breakClipPath: event:/Props/impact_egg
- Type: Item - Type: Item
Enabled: true Enabled: true
Score: 10 Score: 10
@ -3826,6 +3840,8 @@
Enabled: true Enabled: true
threshHold: 0.100000001 threshHold: 0.100000001
ignoreRaccoon: false ignoreRaccoon: false
breakClipHandlerName: SFXBreak1
breakClipPath: event:/Props/impact_break
- EID: 196 - EID: 196
Name: Piece1 Name: Piece1
IsActive: false IsActive: false
@ -4035,6 +4051,8 @@
Enabled: true Enabled: true
threshHold: 0.100000001 threshHold: 0.100000001
ignoreRaccoon: false ignoreRaccoon: false
breakClipHandlerName: SFXBreak171
breakClipPath: event:/Props/impact_break
- EID: 65703 - EID: 65703
Name: Piece1 Name: Piece1
IsActive: false IsActive: false
@ -4244,6 +4262,8 @@
Enabled: true Enabled: true
threshHold: 0.100000001 threshHold: 0.100000001
ignoreRaccoon: false ignoreRaccoon: false
breakClipHandlerName: SFXBreak150
breakClipPath: event:/Props/impact_break
- EID: 149 - EID: 149
Name: Piece1 Name: Piece1
IsActive: false IsActive: false
@ -4453,6 +4473,8 @@
Enabled: true Enabled: true
threshHold: 0.100000001 threshHold: 0.100000001
ignoreRaccoon: false ignoreRaccoon: false
breakClipHandlerName: SFXBreak145
breakClipPath: event:/Props/impact_break
- EID: 488 - EID: 488
Name: Piece1 Name: Piece1
IsActive: false IsActive: false
@ -4662,6 +4684,8 @@
Enabled: true Enabled: true
threshHold: 0.100000001 threshHold: 0.100000001
ignoreRaccoon: false ignoreRaccoon: false
breakClipHandlerName: SFXBreak492
breakClipPath: event:/Props/impact_break
- EID: 493 - EID: 493
Name: Piece1 Name: Piece1
IsActive: false IsActive: false
@ -4871,6 +4895,8 @@
Enabled: true Enabled: true
threshHold: 0.100000001 threshHold: 0.100000001
ignoreRaccoon: false ignoreRaccoon: false
breakClipHandlerName: SFXBreak497
breakClipPath: event:/Props/impact_break
- EID: 498 - EID: 498
Name: Piece1 Name: Piece1
IsActive: false IsActive: false
@ -5080,6 +5106,8 @@
Enabled: true Enabled: true
threshHold: 0.100000001 threshHold: 0.100000001
ignoreRaccoon: false ignoreRaccoon: false
breakClipHandlerName: SFXBreak502
breakClipPath: event:/Props/impact_break
- EID: 503 - EID: 503
Name: Piece1 Name: Piece1
IsActive: false IsActive: false
@ -5289,6 +5317,8 @@
Enabled: true Enabled: true
threshHold: 0.100000001 threshHold: 0.100000001
ignoreRaccoon: false ignoreRaccoon: false
breakClipHandlerName: SFXBreak507
breakClipPath: event:/Props/impact_break
- EID: 508 - EID: 508
Name: Piece1 Name: Piece1
IsActive: false IsActive: false
@ -5498,6 +5528,8 @@
Enabled: true Enabled: true
threshHold: 0.100000001 threshHold: 0.100000001
ignoreRaccoon: false ignoreRaccoon: false
breakClipHandlerName: SFXBreak512
breakClipPath: event:/Props/impact_break
- EID: 513 - EID: 513
Name: Piece1 Name: Piece1
IsActive: false IsActive: false
@ -5707,6 +5739,8 @@
Enabled: true Enabled: true
threshHold: 0.100000001 threshHold: 0.100000001
ignoreRaccoon: false ignoreRaccoon: false
breakClipHandlerName: SFXBreak517
breakClipPath: event:/Props/impact_break
- EID: 518 - EID: 518
Name: Piece1 Name: Piece1
IsActive: false IsActive: false
@ -5878,7 +5912,7 @@
Components: ~ Components: ~
Scripts: ~ Scripts: ~
- EID: 165 - EID: 165
Name: 1 Name: 0
IsActive: true IsActive: true
NumberOfChildren: 0 NumberOfChildren: 0
Components: Components:
@ -5889,7 +5923,7 @@
IsActive: true IsActive: true
Scripts: ~ Scripts: ~
- EID: 164 - EID: 164
Name: 2 Name: 1
IsActive: true IsActive: true
NumberOfChildren: 0 NumberOfChildren: 0
Components: Components:
@ -5900,7 +5934,7 @@
IsActive: true IsActive: true
Scripts: ~ Scripts: ~
- EID: 163 - EID: 163
Name: 3 Name: 2
IsActive: true IsActive: true
NumberOfChildren: 0 NumberOfChildren: 0
Components: Components:
@ -5911,7 +5945,7 @@
IsActive: true IsActive: true
Scripts: ~ Scripts: ~
- EID: 162 - EID: 162
Name: 4 Name: 3
IsActive: true IsActive: true
NumberOfChildren: 0 NumberOfChildren: 0
Components: Components:
@ -5922,7 +5956,7 @@
IsActive: true IsActive: true
Scripts: ~ Scripts: ~
- EID: 161 - EID: 161
Name: 5 Name: 4
IsActive: true IsActive: true
NumberOfChildren: 0 NumberOfChildren: 0
Components: Components:
@ -5933,7 +5967,7 @@
IsActive: true IsActive: true
Scripts: ~ Scripts: ~
- EID: 160 - EID: 160
Name: 6 Name: 5
IsActive: true IsActive: true
NumberOfChildren: 0 NumberOfChildren: 0
Components: Components:
@ -5944,7 +5978,7 @@
IsActive: true IsActive: true
Scripts: ~ Scripts: ~
- EID: 159 - EID: 159
Name: 7 Name: 6
IsActive: true IsActive: true
NumberOfChildren: 0 NumberOfChildren: 0
Components: Components:
@ -5960,7 +5994,7 @@
NumberOfChildren: 0 NumberOfChildren: 0
Components: Components:
Transform Component: Transform Component:
Translate: {x: 0.0576689839, y: 0, z: -2.61272359} Translate: {x: -3.45969725, y: 0, z: -2.61272359}
Rotate: {x: -0, y: 0, z: -0} Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 1, y: 1, z: 1} Scale: {x: 1, y: 1, z: 1}
IsActive: true IsActive: true
@ -5998,12 +6032,13 @@
- Type: Homeowner1 - Type: Homeowner1
Enabled: true Enabled: true
waypointsPool: 166 waypointsPool: 166
startWaypoint: 162
patrolSpeed: 3 patrolSpeed: 3
chaseSpeed: 6 chaseSpeed: 6
turningSpeed: 5 turningSpeed: 5
sightDistance: 8 sightDistance: 8
eyeOffset: [0, 1.64999998, 0] eyeOffset: [0, 1.64999998, 0]
distanceToCapture: 0.5 distanceToCapture: 0.800000012
captureTime: 0.5 captureTime: 0.5
footstepSFXIntervalMultiplier: 0.5 footstepSFXIntervalMultiplier: 0.5
- EID: 12 - EID: 12
@ -6133,7 +6168,7 @@
Components: Components:
Transform Component: Transform Component:
Translate: {x: 0, y: -300, z: 0} Translate: {x: 0, y: -300, z: 0}
Rotate: {x: -4.5, y: 2, z: -2.5} Rotate: {x: 3.25, y: 0.5, z: 4.5}
Scale: {x: 400, y: 100, z: 500} Scale: {x: 400, y: 100, z: 500}
IsActive: true IsActive: true
Renderable Component: Renderable Component:

View File

@ -0,0 +1,32 @@
using SHADE;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SHADE_Scripting.Audio
{
public class SoundLoopEmitter : Script
{
[SerializeField]
private string clipHandlerName;
[SerializeField]
private string clipPath;
public float volume;
protected override void awake()
{
AudioHandler.audioClipHandlers[clipHandlerName] = SHADE.Audio.CreateAudioClip(clipPath);
}
protected override void start()
{
SHADE.Audio.AttachAudioClipToObject(AudioHandler.audioClipHandlers[clipHandlerName], GameObject.EntityId);
AudioHandler.audioClipHandlers[clipHandlerName].SetVolume(volume);
AudioHandler.audioClipHandlers[clipHandlerName].Play();
}
}
}

View File

@ -0,0 +1,3 @@
Name: CS_SoundLoopEmitter
ID: 154714630
Type: 9

View File

@ -37,6 +37,9 @@ public partial class Homeowner1 : BehaviourTree
private List<GameObject> waypoints; private List<GameObject> waypoints;
[SerializeField]
private GameObject startWaypoint;
[SerializeField] [SerializeField]
[Tooltip("The AI will patrol at this speed")] [Tooltip("The AI will patrol at this speed")]
private float patrolSpeed; private float patrolSpeed;
@ -112,8 +115,14 @@ public partial class Homeowner1 : BehaviourTree
AudioHandler.audioClipHandlers["BGMAdaptive"] = Audio.CreateAudioClip("event:/Music/bgm_adaptive"); AudioHandler.audioClipHandlers["BGMAdaptive"] = Audio.CreateAudioClip("event:/Music/bgm_adaptive");
AudioHandler.audioClipHandlers["SFXFootstep"] = Audio.CreateAudioClip("event:/Homeowner/homeowner_footsteps"); AudioHandler.audioClipHandlers["SFXFootstep"] = Audio.CreateAudioClip("event:/Homeowner/homeowner_footsteps");
Audio.AttachAudioClipToObject(AudioHandler.audioClipHandlers["SFXFootstep"], GameObject.EntityId);
AudioHandler.audioClipHandlers["SFXDetectAh"] = Audio.CreateAudioClip("event:/Homeowner/homeowner_detect_raccoon"); AudioHandler.audioClipHandlers["SFXDetectAh"] = Audio.CreateAudioClip("event:/Homeowner/homeowner_detect_raccoon");
Audio.AttachAudioClipToObject(AudioHandler.audioClipHandlers["SFXDetectAh"], GameObject.EntityId);
AudioHandler.audioClipHandlers["SFXDetectSting"] = Audio.CreateAudioClip("event:/Music/stingers/player_detected"); AudioHandler.audioClipHandlers["SFXDetectSting"] = Audio.CreateAudioClip("event:/Music/stingers/player_detected");
AudioHandler.audioClipHandlers["SFXHumming"] = Audio.CreateAudioClip("event:/Homeowner/homeowner_humming");
Audio.AttachAudioClipToObject(AudioHandler.audioClipHandlers["SFXHumming"], GameObject.EntityId);
AudioHandler.audioClipHandlers["SFXHumming"].SetVolume(0.15f);
AudioHandler.audioClipHandlers["SFXHumming"].Play();
if (aiInstance != null && aiInstance != this) if (aiInstance != null && aiInstance != this)
RemoveScript<Homeowner1>(); RemoveScript<Homeowner1>();
@ -151,6 +160,8 @@ public partial class Homeowner1 : BehaviourTree
SetData("distanceToCapture", distanceToCapture); SetData("distanceToCapture", distanceToCapture);
if (GetData("baseCaptureTime") == null || (float)GetData("baseCaptureTime") != captureTime) if (GetData("baseCaptureTime") == null || (float)GetData("baseCaptureTime") != captureTime)
SetData("baseCaptureTime", captureTime); SetData("baseCaptureTime", captureTime);
if (GetData("startWaypoint") == null || (GameObject)GetData("startWaypoint") != startWaypoint)
SetData("startWaypoint", startWaypoint);
events.Tick(); events.Tick();

View File

@ -12,6 +12,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;
@ -98,6 +99,35 @@ public partial class LeafAttack : BehaviourTreeNode
if (player.GetScript<PlayerController>().stateMachine && !player.GetScript<PlayerController>().stateMachine.IsState(typeof(PlayerCaughtState))) if (player.GetScript<PlayerController>().stateMachine && !player.GetScript<PlayerController>().stateMachine.IsState(typeof(PlayerCaughtState)))
player.GetScript<PlayerController>().stateMachine.SetState(typeof(PlayerCaughtState)); player.GetScript<PlayerController>().stateMachine.SetState(typeof(PlayerCaughtState));
//Teleport AI back to home waypoint
int homeIndex = 0;
GameObject? startWaypoint = null;
List<GameObject>? waypoints = (List<GameObject>)GetNodeData("waypoints");
if (GetNodeData("startWaypoint") != null)
startWaypoint = (GameObject)GetNodeData("startWaypoint");
if (startWaypoint != null)
{
for (int i = 0; i < waypoints.Count; ++i)
{
if (startWaypoint == waypoints[i])
{
homeIndex = i;
}
}
}
SetNodeData("currentWaypointIndex", homeIndex);
SetNodeData("playerLastSightedWaypointIndex", homeIndex);
SetNodeData("isAlert", false);
Audio.SetParameterWithLabel("PlayerDetection", "Undetected");
AudioHandler.audioClipHandlers["SFXHumming"].Play();
Transform? transform = (Transform)GetNodeData("transform");
if (waypoints != null && transform != null)
{
transform.GlobalPosition = waypoints[homeIndex].GetComponent<Transform>().GlobalPosition;
}
ClearNodeData("target");
status = BehaviourTreeNodeStatus.SUCCESS; status = BehaviourTreeNodeStatus.SUCCESS;
onExit(BehaviourTreeNodeStatus.SUCCESS); onExit(BehaviourTreeNodeStatus.SUCCESS);
return status; return status;

View File

@ -60,7 +60,7 @@ public partial class LeafChase : BehaviourTreeNode
} }
} }
//Debug.Log("Player is nearest " + nearestWaypointIndex); //Debug.Log("Player is nearest " + nearestWaypointIndex);
//Debug.Log("I'm at " + (int)GetNodeData("currentWaypointIndex")); //Debug.Log("AI going to " + (int)GetNodeData("currentWaypointIndex"));
SetNodeData("playerLastSightedWaypointIndex", nearestWaypointIndex); SetNodeData("playerLastSightedWaypointIndex", nearestWaypointIndex);
} }
@ -78,6 +78,7 @@ public partial class LeafChase : BehaviourTreeNode
GetNodeData("distanceToCapture") == null || GetNodeData("distanceToCapture") == null ||
GetNodeData("baseCaptureTime") == null) GetNodeData("baseCaptureTime") == null)
{ {
//Debug.Log("Chase Failure: null values");
status = BehaviourTreeNodeStatus.FAILURE; status = BehaviourTreeNodeStatus.FAILURE;
onExit(BehaviourTreeNodeStatus.FAILURE); onExit(BehaviourTreeNodeStatus.FAILURE);
return status; return status;

View File

@ -29,7 +29,7 @@ public partial class LeafPatrol : BehaviourTreeNode
private float chaseSpeed; private float chaseSpeed;
private float turningSpeed; private float turningSpeed;
private float retreatTimer = 0.0f; private float retreatTimer = 0.0f;
private int currentWaypointIndex = 0; private int currentWaypointIndex = -1;
private bool retreatState = false; private bool retreatState = false;
private bool goingForwards = true; private bool goingForwards = true;
@ -47,7 +47,7 @@ public partial class LeafPatrol : BehaviourTreeNode
//node, and hence we do not need to inherit its constructors //node, and hence we do not need to inherit its constructors
public LeafPatrol(string name) : base(name) public LeafPatrol(string name) : base(name)
{ {
currentWaypointIndex = 0; currentWaypointIndex = -1;
} }
//When it comes to evaluating, //When it comes to evaluating,
@ -57,6 +57,42 @@ public partial class LeafPatrol : BehaviourTreeNode
//Debug.LogWarning("LeafPatrol"); //Debug.LogWarning("LeafPatrol");
onEnter(BehaviourTreeNodeStatus.RUNNING); onEnter(BehaviourTreeNodeStatus.RUNNING);
//Initialise home waypoint
waypoints = (List<GameObject>)GetNodeData("waypoints");
if (currentWaypointIndex == -1)
{
if (waypoints != null)
{
//Debug.Log("Waypoints not null");
if (GetNodeData("startWaypoint") != null)
{
//Debug.Log("Getting start waypoint");
GameObject startWaypoint = (GameObject)(GetNodeData("startWaypoint"));
for (int i = 0; i < waypoints.Count; ++i)
{
if (startWaypoint == waypoints[i])
{
//Debug.Log("Leaf Patrol Constructor: Start Waypoint Index: " + i.ToString());
currentWaypointIndex = i;
SetNodeData("currentWaypointIndex", i);
}
}
}
else
{
status = BehaviourTreeNodeStatus.FAILURE;
onExit(BehaviourTreeNodeStatus.FAILURE);
return status;
}
}
else
{
status = BehaviourTreeNodeStatus.FAILURE;
onExit(BehaviourTreeNodeStatus.FAILURE);
return status;
}
}
//Get data //Get data
if (GetNodeData("transform") == null || if (GetNodeData("transform") == null ||
GetNodeData("patrolSpeed") == null || GetNodeData("patrolSpeed") == null ||
@ -104,12 +140,13 @@ public partial class LeafPatrol : BehaviourTreeNode
ClearNodeData("isWaiting"); ClearNodeData("isWaiting");
return; return;
} }
waypoints = (List<GameObject>)GetNodeData("waypoints"); if (GetNodeData("currentWaypointIndex") != null)
if (waypoints == null)
{ {
return; //2023 Mar 4, 0400, this is needed when the AI teleports back to the first spot after catching
currentWaypointIndex = (int)GetNodeData("currentWaypointIndex");
} }
Vector3 targetPosition = waypoints[currentWaypointIndex].GetComponent<Transform>().GlobalPosition; //Modulo operator to prevent out of range exceptions
Vector3 targetPosition = waypoints[(currentWaypointIndex % waypoints.Count)].GetComponent<Transform>().GlobalPosition;
//Reach waypoint by X and Z being near enough //Reach waypoint by X and Z being near enough
//Do not consider Y of waypoints yet //Do not consider Y of waypoints yet
Vector3 remainingDistance = targetPosition - transform.GlobalPosition; Vector3 remainingDistance = targetPosition - transform.GlobalPosition;
@ -195,6 +232,8 @@ public partial class LeafPatrol : BehaviourTreeNode
//Debug.Log("AI is at " + transform.GlobalPosition.x.ToString() + " " + transform.GlobalPosition.y.ToString() + " " + transform.GlobalPosition.z.ToString()); //Debug.Log("AI is at " + transform.GlobalPosition.x.ToString() + " " + transform.GlobalPosition.y.ToString() + " " + transform.GlobalPosition.z.ToString());
Vector3 normalisedDifference = targetPosition - transform.GlobalPosition; Vector3 normalisedDifference = targetPosition - transform.GlobalPosition;
normalisedDifference.y = 0.0f; //Do not move vertically normalisedDifference.y = 0.0f; //Do not move vertically
//Debug.Log("Leaf Patrol Current Waypoint Index: " + currentWaypointIndex.ToString());
//Debug.Log("True Difference x " + normalisedDifference.x.ToString() + " z " + normalisedDifference.z.ToString());
normalisedDifference /= normalisedDifference.GetMagnitude(); normalisedDifference /= normalisedDifference.GetMagnitude();
//Debug.Log("Normalised Difference x " + normalisedDifference.x.ToString() + " z " + normalisedDifference.z.ToString()); //Debug.Log("Normalised Difference x " + normalisedDifference.x.ToString() + " z " + normalisedDifference.z.ToString());

View File

@ -14,6 +14,12 @@ public class Breakable : Script
public bool isBreak { get; set; } public bool isBreak { get; set; }
private List<GameObject> itemPieces = new List<GameObject>(); private List<GameObject> itemPieces = new List<GameObject>();
[SerializeField]
private string breakClipHandlerName;
[SerializeField]
private string breakClipPath;
protected override void awake() protected override void awake()
{ {
rb = GetComponent<RigidBody>(); rb = GetComponent<RigidBody>();
@ -32,7 +38,7 @@ public class Breakable : Script
isBreak = false; isBreak = false;
AudioHandler.audioClipHandlers["SFXBreak"] = Audio.CreateAudioClip("event:/Props/impact_break"); AudioHandler.audioClipHandlers[breakClipHandlerName] = Audio.CreateAudioClip(breakClipPath);
} }
protected override void update() protected override void update()
@ -76,7 +82,9 @@ public class Breakable : Script
GameManager.Instance.itemShatter = false; GameManager.Instance.itemShatter = false;
isBreak = false; isBreak = false;
AudioHandler.audioClipHandlers["SFXBreak"].Play(); Audio.AttachAudioClipToObject(AudioHandler.audioClipHandlers[breakClipHandlerName], GameObject.EntityId);
AudioHandler.audioClipHandlers[breakClipHandlerName].Play();
//Audio.DetachAudioClipFromObject(AudioHandler.audioClipHandlers[breakClipHandlerName]);
GameObject.SetActive(false); GameObject.SetActive(false);
} }
} }

View File

@ -121,11 +121,15 @@ public class Item : Script
if (playSound) if (playSound)
{ {
Audio.AttachAudioClipToObject(AudioHandler.audioClipHandlers["SFXImpactElastic"], GameObject.EntityId);
Audio.AttachAudioClipToObject(AudioHandler.audioClipHandlers["SFXImpactHard"], GameObject.EntityId);
if (currCategory == ItemCategory.LIGHT) if (currCategory == ItemCategory.LIGHT)
AudioHandler.audioClipHandlers["SFXImpactElastic"].Play(); AudioHandler.audioClipHandlers["SFXImpactElastic"].Play();
else if (currCategory == ItemCategory.MEDIUM || currCategory == ItemCategory.HEAVY) else if (currCategory == ItemCategory.MEDIUM || currCategory == ItemCategory.HEAVY)
AudioHandler.audioClipHandlers["SFXImpactHard"].Play(); AudioHandler.audioClipHandlers["SFXImpactHard"].Play();
playSound = false; playSound = false;
Audio.DetachAudioClipFromObject(AudioHandler.audioClipHandlers["SFXImpactElastic"]);
Audio.DetachAudioClipFromObject(AudioHandler.audioClipHandlers["SFXImpactHard"]);
} }
if (info.GameObject.GetScript<Homeowner1>() && !returnBack) if (info.GameObject.GetScript<Homeowner1>() && !returnBack)

View File

@ -91,10 +91,6 @@ public class GameManager : Script
AudioHandler.audioClipHandlers["KitchenAmbience"] = Audio.CreateAudioClip("event:/Ambience/roomtone_kitchen"); AudioHandler.audioClipHandlers["KitchenAmbience"] = Audio.CreateAudioClip("event:/Ambience/roomtone_kitchen");
AudioHandler.audioClipHandlers["KitchenAmbience"].Play(); AudioHandler.audioClipHandlers["KitchenAmbience"].Play();
AudioHandler.audioClipHandlers["SFXHumming"] = Audio.CreateAudioClip("event:/Homeowner/homeowner_humming");
AudioHandler.audioClipHandlers["SFXHumming"].SetVolume(0.15f);
AudioHandler.audioClipHandlers["SFXHumming"].Play();
if (SceneFadeInOut.Instance != null) if (SceneFadeInOut.Instance != null)
SceneFadeInOut.Instance.CallFadeOut(); SceneFadeInOut.Instance.CallFadeOut();
Application.IsCursorVisible = false; Application.IsCursorVisible = false;

View File

@ -1,10 +1,12 @@
using SHADE; using SHADE;
using SHADE_Scripting.Audio;
using System; using System;
public class JumpPad : Script public class JumpPad : Script
{ {
protected override void awake() protected override void awake()
{ {
AudioHandler.audioClipHandlers["SFXJumpPad"] = Audio.CreateAudioClip("event:/Props/jumppad_boing");
} }
protected override void update() protected override void update()
@ -15,6 +17,8 @@ public class JumpPad : Script
{ {
if (info.GameObject.GetScript<PlayerController>() && info.GameObject.GetScript<PlayerController>().currentState == PlayerController.RaccoonStates.FALLING) if (info.GameObject.GetScript<PlayerController>() && info.GameObject.GetScript<PlayerController>().currentState == PlayerController.RaccoonStates.FALLING)
{ {
Audio.AttachAudioClipToObject(AudioHandler.audioClipHandlers["SFXJumpPad"], GameObject.EntityId);
AudioHandler.audioClipHandlers["SFXJumpPad"].Play();
info.GameObject.GetScript<PlayerController>().landedOnJumpPad = true; info.GameObject.GetScript<PlayerController>().landedOnJumpPad = true;
} }
} }