added more audio and tidy up folder
tidy up scripts folder added more audio (cause burden randall cant make up his mind) adjusted main scene abit
This commit is contained in:
parent
128f07030b
commit
81978a90b6
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -8562,7 +8562,7 @@
|
|||
NumberOfChildren: 0
|
||||
Components:
|
||||
Transform Component:
|
||||
Translate: {x: 2.47664404, y: 0.904378593, z: -4.45292473}
|
||||
Translate: {x: 0.00604016334, y: 1.34554219, z: -4.45292473}
|
||||
Rotate: {x: -0, y: 0, z: -0}
|
||||
Scale: {x: 1, y: 1, z: 1}
|
||||
IsActive: true
|
||||
|
|
|
@ -1,183 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SHADE;
|
||||
|
||||
public class AIPrototype : Script
|
||||
{
|
||||
//This object's relevant components
|
||||
private Transform transform;
|
||||
private RigidBody rb;
|
||||
|
||||
/*[SerializeField]
|
||||
[Tooltip("The list of waypoints that the object will move around on")]
|
||||
private Vector3[] waypoints;*/
|
||||
|
||||
private Vector3[] waypoints = { new Vector3(-8.0f, -2.0f, 3.5f), new Vector3(-8.0f, -2.0f, -13.0f), new Vector3(8.0f, -2.0f, -13.0f), new Vector3(8.0f, -2.0f, 3.5f) };
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("How much force is applied in movement")]
|
||||
private float movementForceMultiplier = 100.0f;
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("How fast the object moves about waypoints")]
|
||||
private float patrolSpeed = 0.4f;
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("How fast the object moves while chasing")]
|
||||
private float chaseSpeed = 0.8f;
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("How near the player must be to the AI for capture")]
|
||||
private float distanceToCapture = 1.2f;
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("How near the player must be for the chase to begin. Should be less than distanceToEndChase")]
|
||||
private float distanceToStartChase = 2.0f;
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("How far the player must be for the chase to end. Should be greater than distanceToStartChase")]
|
||||
private float distanceToEndChase = 2.5f;
|
||||
|
||||
//Whether the AI is chasing or not
|
||||
private bool chaseMode;
|
||||
|
||||
//To cycle depending on the length of waypoints
|
||||
private int currentTargetWaypointIndex;
|
||||
|
||||
private GameObject? player;
|
||||
|
||||
|
||||
protected override void awake()
|
||||
{
|
||||
transform = GetComponent<Transform>();
|
||||
if (transform == null)
|
||||
{
|
||||
Debug.LogError("Transform is NULL!");
|
||||
}
|
||||
|
||||
rb = GetComponent<RigidBody>();
|
||||
if (rb == null)
|
||||
{
|
||||
Debug.LogError("Rigidbody is NULL!");
|
||||
}
|
||||
|
||||
currentTargetWaypointIndex = 0;
|
||||
|
||||
player = GameObject.Find("Player");
|
||||
if (player == null)
|
||||
{
|
||||
Debug.LogError("Player is NULL!");
|
||||
}
|
||||
|
||||
chaseMode = false;
|
||||
}
|
||||
|
||||
protected override void fixedUpdate()
|
||||
{
|
||||
//Patrolling
|
||||
if (!chaseMode)
|
||||
{
|
||||
//Head towards the next target
|
||||
Vector3 normalisedDifference = waypoints[currentTargetWaypointIndex] - transform.GlobalPosition;
|
||||
normalisedDifference /= normalisedDifference.GetMagnitude();
|
||||
|
||||
//transform.GlobalPosition += normalisedDifference * moveSpeed * (float)Time.DeltaTime;
|
||||
//rb.LinearVelocity = normalisedDifference * patrolSpeed;
|
||||
|
||||
//ORIGINAL INTENDED CODE
|
||||
/*rb.AddForce(new Vector3(normalisedDifference.x, 0.0f, normalisedDifference.z) * movementForceMultiplier);
|
||||
float currentSpeed = MathF.Sqrt(rb.LinearVelocity.x * rb.LinearVelocity.x + rb.LinearVelocity.z * rb.LinearVelocity.z);
|
||||
if (currentSpeed > patrolSpeed)
|
||||
{
|
||||
float adjustmentFactor = patrolSpeed / currentSpeed;
|
||||
Vector3 adjustedVelocity = rb.LinearVelocity;
|
||||
//adjustedVelocity *= adjustmentFactor;
|
||||
adjustedVelocity.x = patrolSpeed;
|
||||
adjustedVelocity.z = patrolSpeed;
|
||||
rb.LinearVelocity = adjustedVelocity;
|
||||
}*/
|
||||
|
||||
//TODO delete this when original intended code above works with velocity being limited correctly
|
||||
rb.LinearVelocity = normalisedDifference * patrolSpeed;
|
||||
|
||||
//transform.GlobalRotation.SetLookRotation(waypoints[currentTargetWaypointIndex], Vector3.Up);
|
||||
|
||||
//Cycle to next waypoint if near enough current waypoint
|
||||
if ((waypoints[currentTargetWaypointIndex] - transform.GlobalPosition).GetSqrMagnitude() <= 0.5f)
|
||||
{
|
||||
++currentTargetWaypointIndex;
|
||||
if (currentTargetWaypointIndex >= waypoints.Length)
|
||||
{
|
||||
currentTargetWaypointIndex = 0; //Recycle
|
||||
}
|
||||
}
|
||||
|
||||
//Go chase if near enough to player
|
||||
if (player != null)
|
||||
{
|
||||
Transform pTransform = player.GetValueOrDefault().GetComponent<Transform>();
|
||||
if ((pTransform.GlobalPosition - transform.GlobalPosition).GetMagnitude() <= distanceToStartChase)
|
||||
{
|
||||
//Start the chase
|
||||
chaseMode = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else //Chasing
|
||||
{
|
||||
if (player != null)
|
||||
{
|
||||
Transform pTransform = player.GetValueOrDefault().GetComponent<Transform>();
|
||||
|
||||
//Chase the player
|
||||
Vector3 normalisedDifference = pTransform.GlobalPosition - transform.GlobalPosition;
|
||||
normalisedDifference /= normalisedDifference.GetMagnitude();
|
||||
|
||||
//transform.GlobalPosition += normalisedDifference * moveSpeed * (float)Time.DeltaTime;
|
||||
|
||||
//ORIGINAL INTENDED CODE
|
||||
/*rb.AddForce(new Vector3(normalisedDifference.x, 0.0f, normalisedDifference.z) * movementForceMultiplier);
|
||||
float currentSpeed = MathF.Sqrt(rb.LinearVelocity.x * rb.LinearVelocity.x + rb.LinearVelocity.z * rb.LinearVelocity.z);
|
||||
if (currentSpeed > chaseSpeed)
|
||||
{
|
||||
float adjustmentFactor = chaseSpeed / currentSpeed;
|
||||
Vector3 adjustedVelocity = rb.LinearVelocity;
|
||||
adjustedVelocity *= adjustmentFactor;
|
||||
rb.LinearVelocity = adjustedVelocity;
|
||||
}*/
|
||||
|
||||
//TODO delete this when original intended code above works with velocity being limited correctly
|
||||
rb.LinearVelocity = normalisedDifference * chaseSpeed;
|
||||
|
||||
//Capture player if near enough
|
||||
if ((pTransform.GlobalPosition - transform.GlobalPosition).GetMagnitude() <= distanceToCapture)
|
||||
{
|
||||
player.GetValueOrDefault().GetScript<PlayerController>().currentState = PlayerController.RaccoonStates.CAUGHT;
|
||||
}
|
||||
|
||||
//End chase if too far
|
||||
if ((pTransform.GlobalPosition - transform.GlobalPosition).GetMagnitude() >= distanceToEndChase)
|
||||
{
|
||||
//Stop the chase
|
||||
chaseMode = false;
|
||||
|
||||
//Find the nearest waypoint to go instead
|
||||
float nearestWaypointDistance = 99999999999999.9f;
|
||||
for (int i = 0; i < waypoints.Length; ++i)
|
||||
{
|
||||
if ((waypoints[i] - transform.GlobalPosition).GetSqrMagnitude() < nearestWaypointDistance)
|
||||
{
|
||||
nearestWaypointDistance = waypoints[i].GetSqrMagnitude();
|
||||
currentTargetWaypointIndex = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
Name: AIPrototype
|
||||
ID: 163215061
|
||||
Type: 9
|
|
@ -1,3 +0,0 @@
|
|||
Name: Breakable
|
||||
ID: 154790613
|
||||
Type: 9
|
|
@ -0,0 +1,3 @@
|
|||
Name: SC_Breakable
|
||||
ID: 161935110
|
||||
Type: 9
|
|
@ -0,0 +1,3 @@
|
|||
Name: SC_ThirdPersonCamera
|
||||
ID: 166247489
|
||||
Type: 9
|
|
@ -1,3 +0,0 @@
|
|||
Name: ThirdPersonCamera
|
||||
ID: 154161201
|
||||
Type: 9
|
|
@ -38,6 +38,7 @@ public class GameManager : Script
|
|||
protected override void awake()
|
||||
{
|
||||
Audio.PlayBGMOnce2D("event:/Music/player_undetected");
|
||||
Audio.PlayBGMOnce2D("event:/Ambience/roomtone_kitchen");
|
||||
totalItemCount = 0;
|
||||
Score = 0;
|
||||
currGameState = GameState.START;
|
||||
|
|
|
@ -11,16 +11,24 @@ public class EndScene : Script
|
|||
}
|
||||
protected override void update()
|
||||
{
|
||||
if (Input.GetKey(Input.KeyCode.R))
|
||||
if (Input.GetKeyDown(Input.KeyCode.R))
|
||||
{
|
||||
Audio.PlaySFXOnce2D("event:/UI/mouse_down_element");
|
||||
}
|
||||
if (Input.GetKeyUp(Input.KeyCode.R))
|
||||
{
|
||||
Audio.PlaySFXOnce2D("event:/UI/success");
|
||||
Audio.StopAllSounds();
|
||||
SceneManager.ChangeScene(mainGameScene);
|
||||
}
|
||||
|
||||
if (Input.GetKey(Input.KeyCode.M))
|
||||
if (Input.GetKeyDown(Input.KeyCode.M))
|
||||
{
|
||||
Audio.PlaySFXOnce2D("event:/UI/mouse_down_element");
|
||||
}
|
||||
if (Input.GetKeyUp(Input.KeyCode.M))
|
||||
{
|
||||
Audio.PlaySFXOnce2D("event:/UI/success");
|
||||
Audio.StopAllSounds();
|
||||
SceneManager.ChangeScene(mainMainScene);
|
||||
}
|
|
@ -12,6 +12,11 @@ public class MainMenu : Script
|
|||
if (Input.GetKeyDown(Input.KeyCode.Space))
|
||||
{
|
||||
Audio.PlaySFXOnce2D("event:/UI/mouse_down_element");
|
||||
}
|
||||
|
||||
if (Input.GetKeyUp(Input.KeyCode.Space))
|
||||
{
|
||||
Audio.PlaySFXOnce2D("event:/UI/success");
|
||||
SceneManager.ChangeScene(86098106);
|
||||
Audio.StopAllSounds();
|
||||
}
|
Loading…
Reference in New Issue