Commit b18cc59f authored by Nathan De Castro's avatar Nathan De Castro
Browse files

fixed audio source output, random switch, light angle and color

parent a3416545
...@@ -98,6 +98,7 @@ ...@@ -98,6 +98,7 @@
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\frag_ao.cginc" /> <None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\frag_ao.cginc" />
<None Include="Assets\Materials\Monster\shaders\bumpSpecmap.shader" /> <None Include="Assets\Materials\Monster\shaders\bumpSpecmap.shader" />
<None Include="Assets\UCLAGameLab\Wireframe\Shaders\UCLA GameLab Wireframe.shader" /> <None Include="Assets\UCLAGameLab\Wireframe\Shaders\UCLA GameLab Wireframe.shader" />
<None Include="Assets\Data\SessionData.txt" />
<None Include="Assets\Materials\Monster\shaders\metalA.shader" /> <None Include="Assets\Materials\Monster\shaders\metalA.shader" />
<None Include="Assets\Standard Assets\Effects\ToonShading\Shaders\ToonBasicOutline.shader" /> <None Include="Assets\Standard Assets\Effects\ToonShading\Shaders\ToonBasicOutline.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_DepthOfField\DepthOfField34.shader" /> <None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_DepthOfField\DepthOfField34.shader" />
......
...@@ -93,6 +93,7 @@ ...@@ -93,6 +93,7 @@
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\frag_ao.cginc" /> <None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\frag_ao.cginc" />
<None Include="Assets\Materials\Monster\shaders\bumpSpecmap.shader" /> <None Include="Assets\Materials\Monster\shaders\bumpSpecmap.shader" />
<None Include="Assets\UCLAGameLab\Wireframe\Shaders\UCLA GameLab Wireframe.shader" /> <None Include="Assets\UCLAGameLab\Wireframe\Shaders\UCLA GameLab Wireframe.shader" />
<None Include="Assets\Data\SessionData.txt" />
<None Include="Assets\Materials\Monster\shaders\metalA.shader" /> <None Include="Assets\Materials\Monster\shaders\metalA.shader" />
<None Include="Assets\Standard Assets\Effects\ToonShading\Shaders\ToonBasicOutline.shader" /> <None Include="Assets\Standard Assets\Effects\ToonShading\Shaders\ToonBasicOutline.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_DepthOfField\DepthOfField34.shader" /> <None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_DepthOfField\DepthOfField34.shader" />
......
...@@ -161,6 +161,7 @@ ...@@ -161,6 +161,7 @@
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\frag_ao.cginc" /> <None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\frag_ao.cginc" />
<None Include="Assets\Materials\Monster\shaders\bumpSpecmap.shader" /> <None Include="Assets\Materials\Monster\shaders\bumpSpecmap.shader" />
<None Include="Assets\UCLAGameLab\Wireframe\Shaders\UCLA GameLab Wireframe.shader" /> <None Include="Assets\UCLAGameLab\Wireframe\Shaders\UCLA GameLab Wireframe.shader" />
<None Include="Assets\Data\SessionData.txt" />
<None Include="Assets\Materials\Monster\shaders\metalA.shader" /> <None Include="Assets\Materials\Monster\shaders\metalA.shader" />
<None Include="Assets\Standard Assets\Effects\ToonShading\Shaders\ToonBasicOutline.shader" /> <None Include="Assets\Standard Assets\Effects\ToonShading\Shaders\ToonBasicOutline.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_DepthOfField\DepthOfField34.shader" /> <None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_DepthOfField\DepthOfField34.shader" />
......
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
<Compile Include="Assets\Scripts\Effects\MediumEnabler.cs" /> <Compile Include="Assets\Scripts\Effects\MediumEnabler.cs" />
<Compile Include="Assets\Scripts\Effects\Rotator.cs" /> <Compile Include="Assets\Scripts\Effects\Rotator.cs" />
<Compile Include="Assets\Scripts\Effects\SmallEnabler.cs" /> <Compile Include="Assets\Scripts\Effects\SmallEnabler.cs" />
<Compile Include="Assets\Scripts\Effects\SoundScaler.cs" />
<Compile Include="Assets\Scripts\Effects\SwitchStart.cs" /> <Compile Include="Assets\Scripts\Effects\SwitchStart.cs" />
<Compile Include="Assets\Scripts\Effects\SwitchState.cs" /> <Compile Include="Assets\Scripts\Effects\SwitchState.cs" />
<Compile Include="Assets\Scripts\Tools\AM.cs" /> <Compile Include="Assets\Scripts\Tools\AM.cs" />
...@@ -64,18 +65,21 @@ ...@@ -64,18 +65,21 @@
<Compile Include="Assets\Scripts\Tools\GhostSound.cs" /> <Compile Include="Assets\Scripts\Tools\GhostSound.cs" />
<Compile Include="Assets\Scripts\Tools\LightScript.cs" /> <Compile Include="Assets\Scripts\Tools\LightScript.cs" />
<Compile Include="Assets\Scripts\Tools\PlayerSound.cs" /> <Compile Include="Assets\Scripts\Tools\PlayerSound.cs" />
<Compile Include="Assets\Scripts\Tools\RandSwitch.cs" />
<Compile Include="Assets\Scripts\Tools\RippleEffect.cs" /> <Compile Include="Assets\Scripts\Tools\RippleEffect.cs" />
<Compile Include="Assets\Scripts\Tools\Timer.cs" /> <Compile Include="Assets\Scripts\Tools\Timer.cs" />
<Compile Include="Assets\Scripts\UI\GameSettings.cs" /> <Compile Include="Assets\Scripts\UI\GS.cs" />
<Compile Include="Assets\Scripts\UI\Info.cs" /> <Compile Include="Assets\Scripts\UI\Info.cs" />
<Compile Include="Assets\Scripts\UI\Instructions.cs" /> <Compile Include="Assets\Scripts\UI\Instructions.cs" />
<Compile Include="Assets\Scripts\UI\LoadStart.cs" /> <Compile Include="Assets\Scripts\UI\LoadStart.cs" />
<Compile Include="Assets\Scripts\UI\LoadTuto.cs" /> <Compile Include="Assets\Scripts\UI\LoadTuto.cs" />
<Compile Include="Assets\Scripts\UI\SessionRecorder.cs" />
<Compile Include="Assets\Scripts\UI\Visibility.cs" /> <Compile Include="Assets\Scripts\UI\Visibility.cs" />
<Compile Include="Assets\Scripts\VR\InteractableItem.cs" /> <Compile Include="Assets\Scripts\VR\InteractableItem.cs" />
<Compile Include="Assets\Scripts\VR\Tutorial.cs" /> <Compile Include="Assets\Scripts\VR\Tutorial.cs" />
<Compile Include="Assets\Scripts\VR\WandButtons.cs" /> <Compile Include="Assets\Scripts\VR\WandButtons.cs" />
<Compile Include="Assets\Scripts\VR\WandController.cs" /> <Compile Include="Assets\Scripts\VR\WandController.cs" />
<Compile Include="Assets\Scripts\VR\lightfollow.cs" />
<Compile Include="Assets\SteamVR\Extras\SteamVR_GazeTracker.cs" /> <Compile Include="Assets\SteamVR\Extras\SteamVR_GazeTracker.cs" />
<Compile Include="Assets\SteamVR\Extras\SteamVR_LaserPointer.cs" /> <Compile Include="Assets\SteamVR\Extras\SteamVR_LaserPointer.cs" />
<Compile Include="Assets\SteamVR\Extras\SteamVR_Teleporter.cs" /> <Compile Include="Assets\SteamVR\Extras\SteamVR_Teleporter.cs" />
...@@ -199,6 +203,7 @@ ...@@ -199,6 +203,7 @@
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\frag_ao.cginc" /> <None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\frag_ao.cginc" />
<None Include="Assets\Materials\Monster\shaders\bumpSpecmap.shader" /> <None Include="Assets\Materials\Monster\shaders\bumpSpecmap.shader" />
<None Include="Assets\UCLAGameLab\Wireframe\Shaders\UCLA GameLab Wireframe.shader" /> <None Include="Assets\UCLAGameLab\Wireframe\Shaders\UCLA GameLab Wireframe.shader" />
<None Include="Assets\Data\SessionData.txt" />
<None Include="Assets\Materials\Monster\shaders\metalA.shader" /> <None Include="Assets\Materials\Monster\shaders\metalA.shader" />
<None Include="Assets\Standard Assets\Effects\ToonShading\Shaders\ToonBasicOutline.shader" /> <None Include="Assets\Standard Assets\Effects\ToonShading\Shaders\ToonBasicOutline.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_DepthOfField\DepthOfField34.shader" /> <None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_DepthOfField\DepthOfField34.shader" />
......
fileFormatVersion: 2
guid: 048cc16df3124f14ca433f616f3f7c60
folderAsset: yes
timeCreated: 1492092619
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
4/17/2017 2:08:58 PM | Player stopped after: 5 seconds
4/17/2017 2:09:39 PM | Player stopped after: 3 seconds
4/17/2017 2:09:54 PM | Player stopped after: 1 seconds
4/17/2017 2:11:32 PM | Player lost after: 7 seconds
4/17/2017 2:11:32 PM | Player lost after: 7 seconds
4/17/2017 2:11:32 PM | Player lost after: 7 seconds
4/17/2017 2:11:32 PM | Player lost after: 7 seconds
4/17/2017 2:11:32 PM | Player lost after: 7 seconds
4/17/2017 2:11:32 PM | Player lost after: 7 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:32 PM | Player lost after: 8 seconds
4/17/2017 2:11:33 PM | Player lost after: 8 seconds
4/17/2017 2:11:33 PM | Player lost after: 8 seconds
4/17/2017 2:11:33 PM | Player lost after: 8 seconds
4/17/2017 2:11:33 PM | Player lost after: 8 seconds
4/17/2017 2:11:33 PM | Player lost after: 8 seconds
4/17/2017 2:11:33 PM | Player lost after: 8 seconds
4/17/2017 2:11:33 PM | Player lost after: 8 seconds
4/17/2017 2:11:33 PM | Player lost after: 8 seconds
4/17/2017 2:11:33 PM | Player lost after: 8 seconds
4/17/2017 2:11:33 PM | Player lost after: 8 seconds
4/17/2017 2:11:33 PM | Player lost after: 9 seconds
4/17/2017 2:11:33 PM | Player lost after: 9 seconds
4/17/2017 2:11:33 PM | Player lost after: 9 seconds
4/17/2017 2:11:33 PM | Player lost after: 9 seconds
4/17/2017 2:11:33 PM | Player lost after: 9 seconds
4/17/2017 2:11:33 PM | Player lost after: 9 seconds
4/17/2017 2:11:33 PM | Player lost after: 9 seconds
4/17/2017 2:11:33 PM | Player lost after: 9 seconds
4/17/2017 2:11:33 PM | Player lost after: 9 seconds
4/17/2017 2:11:33 PM | Player lost after: 9 seconds
4/17/2017 2:11:33 PM | Player lost after: 9 seconds
4/17/2017 2:11:33 PM | Player lost after: 9 seconds
4/17/2017 2:11:33 PM | Player lost after: 9 seconds
4/17/2017 2:11:33 PM | Player lost after: 9 seconds
4/17/2017 2:11:33 PM | Player lost after: 9 seconds
4/17/2017 2:11:33 PM | Player lost after: 9 seconds
4/17/2017 2:11:33 PM | Player lost after: 9 seconds
4/17/2017 2:11:33 PM | Player lost after: 9 seconds
4/17/2017 2:11:33 PM | Player lost after: 9 seconds
4/17/2017 2:11:33 PM | Player lost after: 9 seconds
4/17/2017 2:11:33 PM | Player lost after: 9 seconds
4/17/2017 2:11:33 PM | Player lost after: 9 seconds
4/17/2017 2:11:33 PM | Player lost after: 9 seconds
4/17/2017 2:11:33 PM | Player lost after: 9 seconds
4/17/2017 2:11:33 PM | Player lost after: 9 seconds
4/17/2017 2:11:33 PM | Player lost after: 9 seconds
4/17/2017 2:12:32 PM | Player stopped after: 55 seconds
4/17/2017 2:16:33 PM | Player lost after: 16 seconds
4/17/2017 2:16:33 PM | Player lost after: 16 seconds
4/17/2017 2:16:33 PM | Player lost after: 16 seconds
4/17/2017 2:16:33 PM | Player lost after: 16 seconds
4/17/2017 2:16:33 PM | Player lost after: 16 seconds
4/17/2017 2:16:33 PM | Player lost after: 16 seconds
4/17/2017 2:16:33 PM | Player lost after: 16 seconds
4/17/2017 2:16:33 PM | Player lost after: 16 seconds
4/17/2017 2:16:33 PM | Player lost after: 16 seconds
4/17/2017 2:16:33 PM | Player lost after: 16 seconds
4/17/2017 2:16:33 PM | Player lost after: 16 seconds
4/17/2017 2:16:33 PM | Player lost after: 16 seconds
4/17/2017 2:16:33 PM | Player lost after: 16 seconds
4/17/2017 2:16:33 PM | Player lost after: 16 seconds
4/17/2017 2:16:34 PM | Player lost after: 16 seconds
4/17/2017 2:16:34 PM | Player lost after: 16 seconds
4/17/2017 2:16:34 PM | Player lost after: 16 seconds
4/17/2017 2:16:34 PM | Player lost after: 16 seconds
4/17/2017 2:16:34 PM | Player lost after: 16 seconds
4/17/2017 2:16:34 PM | Player lost after: 16 seconds
4/17/2017 2:16:34 PM | Player lost after: 16 seconds
4/17/2017 2:16:34 PM | Player lost after: 16 seconds
4/17/2017 2:16:34 PM | Player lost after: 16 seconds
4/17/2017 2:16:34 PM | Player lost after: 16 seconds
4/17/2017 2:16:34 PM | Player lost after: 16 seconds
4/17/2017 2:16:34 PM | Player lost after: 16 seconds
4/17/2017 2:16:34 PM | Player lost after: 16 seconds
4/17/2017 2:16:34 PM | Player lost after: 16 seconds
4/17/2017 2:16:34 PM | Player lost after: 16 seconds
4/17/2017 2:16:34 PM | Player lost after: 16 seconds
4/17/2017 2:16:34 PM | Player lost after: 16 seconds
4/17/2017 2:16:34 PM | Player lost after: 16 seconds
4/17/2017 2:16:34 PM | Player lost after: 16 seconds
4/17/2017 2:16:34 PM | Player lost after: 17 seconds
4/17/2017 2:16:34 PM | Player lost after: 17 seconds
4/17/2017 2:16:34 PM | Player lost after: 17 seconds
4/17/2017 2:16:34 PM | Player lost after: 17 seconds
4/17/2017 2:16:34 PM | Player lost after: 17 seconds
4/17/2017 2:16:34 PM | Player lost after: 17 seconds
4/17/2017 2:16:34 PM | Player lost after: 17 seconds
4/17/2017 2:16:34 PM | Player lost after: 17 seconds
4/17/2017 2:16:34 PM | Player lost after: 17 seconds
4/17/2017 2:16:34 PM | Player lost after: 17 seconds
4/17/2017 2:16:34 PM | Player lost after: 17 seconds
4/17/2017 2:16:34 PM | Player lost after: 17 seconds
4/17/2017 2:16:34 PM | Player lost after: 17 seconds
4/17/2017 2:16:34 PM | Player lost after: 17 seconds
4/17/2017 2:16:34 PM | Player lost after: 17 seconds
4/17/2017 2:16:34 PM | Player lost after: 17 seconds
4/17/2017 2:16:34 PM | Player lost after: 17 seconds
4/17/2017 2:16:34 PM | Player lost after: 17 seconds
4/17/2017 2:16:34 PM | Player lost after: 17 seconds
fileFormatVersion: 2
guid: baa441b68c1b71843b2fefb338e91d6a
timeCreated: 1492431006
licenseType: Free
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:
...@@ -18,6 +18,7 @@ public class AI : MonoBehaviour { ...@@ -18,6 +18,7 @@ public class AI : MonoBehaviour {
public GameObject waypoints; //All waypoints public GameObject waypoints; //All waypoints
protected Transform[] wayPos; //Array to store each waypoint's transform protected Transform[] wayPos; //Array to store each waypoint's transform
private int dest_point = 0; //Init the destination private int dest_point = 0; //Init the destination
private bool reset_seen = false;
//RAYCAST RELATED VARIABLE //RAYCAST RELATED VARIABLE
private float ray_magnitude = 0; //Essentially the detection distance (length of the ray) private float ray_magnitude = 0; //Essentially the detection distance (length of the ray)
...@@ -32,11 +33,12 @@ public class AI : MonoBehaviour { ...@@ -32,11 +33,12 @@ public class AI : MonoBehaviour {
// Use this for initialization // Use this for initialization
void Start () { void Start () {
if (target == null) target = GameObject.FindGameObjectWithTag("Player");
agent = GetComponent<UnityEngine.AI.NavMeshAgent> (); agent = GetComponent<UnityEngine.AI.NavMeshAgent> ();
wayPos = new Transform[waypoints.GetComponentsInChildren<Transform> ().Length]; wayPos = new Transform[waypoints.GetComponentsInChildren<Transform> ().Length];
for (int i = 1; i<waypoints.GetComponentsInChildren<Transform> ().Length; i++) //i is set to 1 because GetComponentsInChildren also takes the parent once. We don't want that for (int i = 1; i < waypoints.GetComponentsInChildren<Transform> ().Length; i++) //i is set to 1 because GetComponentsInChildren also takes the parent once. We don't want that
{ {
wayPos[i] = waypoints.GetComponentsInChildren<Transform> () [i]; wayPos[i] = waypoints.GetComponentsInChildren<Transform> ()[i];
} }
AudioSource[] samples = GetComponents<AudioSource> (); //Neat way to have multiple samples with a single audio source! AudioSource[] samples = GetComponents<AudioSource> (); //Neat way to have multiple samples with a single audio source!
...@@ -46,8 +48,8 @@ public class AI : MonoBehaviour { ...@@ -46,8 +48,8 @@ public class AI : MonoBehaviour {
} }
void FixedUpdate () { void FixedUpdate () {
ray_magnitude = AM.i.GetSpotAngle() / ghost_awarness; ray_magnitude = AM.i.GetSpotAngle () / ghost_awarness;
if (GameSettings.instance.lose_state == false && GameSettings.instance.win_state == false) //IF you die, these won't be called anymore. if (GS.i.lose_state == false && GS.i.win_state == false) //IF you die, these won't be called anymore.
{ {
state_manager (); //Manages the AI's different states state_manager (); //Manages the AI's different states
ray_casting (); //Draws the ray ray_casting (); //Draws the ray
...@@ -91,23 +93,31 @@ public class AI : MonoBehaviour { ...@@ -91,23 +93,31 @@ public class AI : MonoBehaviour {
transform.LookAt (target.transform.position); transform.LookAt (target.transform.position);
delta = Vector3.Distance (transform.position, target.transform.position); delta = Vector3.Distance (transform.position, target.transform.position);
if (delta > proximity) { if (delta > proximity) {
reset_seen = false;
transform.Translate (Vector3.forward * chase_speed * Time.deltaTime); transform.Translate (Vector3.forward * chase_speed * Time.deltaTime);
} else {
if (!reset_seen) {
wayPos[0] = target.transform; //Sets the first waypoint to be the last player's location (Adding does not seem to work...)
reset_seen = true;
}
} }
if (Vector3.Distance (transform.position, target.transform.position) < proximity) //If agent is to close: play death sound, destroy the player, sets the state to "lost" if (Vector3.Distance (transform.position, target.transform.position) < proximity) //If agent is to close: play death sound, destroy the player, sets the state to "lost"
{ {
bool harm_only = false;
if (harm_only) { death.Play (); transform.position.Set (8, 5.6f, 9); return; }
last_player_T = target.transform.position; last_player_T = target.transform.position;
death.Play (); death.Play ();
// target.GetComponent<playerActions>().ReleaseCamera(); // I chose to have 2 cameras instead of moving the fps one.
Camera.main.GetComponent<AudioListener> ().enabled = false; Camera.main.GetComponent<AudioListener> ().enabled = false;
GameSettings.instance.death_cam.SetActive (true); GS.i.death_cam.SetActive (true);
GameSettings.instance.death_cam.GetComponent<AudioListener> ().enabled = true; GS.i.death_cam.GetComponent<AudioListener> ().enabled = true;
GameSettings.instance.death_cam.transform.LookAt (AI.last_player_T); GS.i.death_cam.transform.LookAt (AI.last_player_T);
GameSettings.instance.death_cam.transform.Translate (Vector3.right * Time.deltaTime); GS.i.death_cam.transform.Translate (Vector3.right * Time.deltaTime);
target.SetActive (false); target.SetActive (false);
print ("You died."); print ("You died.");
GameSettings.instance.lose_state = true; GS.i.lose_state = true;
agent.speed = patrol_speed - 2; agent.speed = patrol_speed - 2;
} }
} }
......
...@@ -4,19 +4,7 @@ ...@@ -4,19 +4,7 @@
public class CurrentPlayer : MonoBehaviour { public class CurrentPlayer : MonoBehaviour {
public static CurrentPlayer instance; public static CurrentPlayer instance;
public GameObject player;
void Awake () {
instance = this;
// print("PlayerSettings initialized");
player = this.gameObject;
}
void Start () { void Start () {
instance = this;
}
void Update () {
} }
} }
\ No newline at end of file
using UnityEngine;
public class SoundScaler : MonoBehaviour {
// Update is called once per frame
void Update () {
this.gameObject.transform.lossyScale.Set (1 + AM.i.GetComplexPitch ().x, 1 + AM.i.GetComplexPitch ().y, 1 + AM.i.GetComplexPitch ().z);
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 47d5fa4f8e84c584e99815999289a9c5
timeCreated: 1492085592
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -5,21 +5,15 @@ public class SwitchStart : MonoBehaviour { ...@@ -5,21 +5,15 @@ public class SwitchStart : MonoBehaviour {
public GameObject switch_on; public GameObject switch_on;
public GameObject switch_off; public GameObject switch_off;
static public bool player_near_switch; private bool player_near_switch;
// Use this for initialization
void Start () {
}
// Update is called once per frame // Update is called once per frame
void Update () { void Update () {
player_near_switch = Vector3.Distance (CurrentPlayer.instance.transform.position, this.transform.position) < 7; player_near_switch = Vector3.Distance (CurrentPlayer.instance.transform.position, transform.position) < 7;
//Turns on the light when the button is pressed //Turns on the light when the button is pressed
if (Input.GetKeyDown (KeyCode.Return) && player_near_switch) { if (Input.GetKeyDown (KeyCode.Return) && player_near_switch) {
SceneManager.LoadScene ("Start"); SceneManager.LoadScene ("Game");
switch_off.SetActive (!switch_off.activeSelf); switch_off.SetActive (!switch_off.activeSelf);
switch_on.SetActive (!switch_off.activeSelf); switch_on.SetActive (!switch_off.activeSelf);
} }
......
...@@ -5,8 +5,8 @@ public class SwitchState : MonoBehaviour { ...@@ -5,8 +5,8 @@ public class SwitchState : MonoBehaviour {
public Light main_light; public Light main_light;
public GameObject switch_on; public GameObject switch_on;
public GameObject switch_off; public GameObject switch_off;
static public bool switch_status; static public bool switch_status = false;
static public bool player_near_switch; static public bool player_near_switch = false;
public bool start_with_light = true; public bool start_with_light = true;
// Use this for initialization // Use this for initialization
...@@ -19,7 +19,7 @@ public class SwitchState : MonoBehaviour { ...@@ -19,7 +19,7 @@ public class SwitchState : MonoBehaviour {
// Update is called once per frame // Update is called once per frame
void Update () { void Update () {
player_near_switch = Vector3.Distance (CurrentPlayer.instance.transform.position, this.transform.position) < 7; player_near_switch = Vector3.Distance (CurrentPlayer.instance.transform.position, transform.position) < 7;
//Turns on the light when the button is pressed //Turns on the light when the button is pressed
if ((Input.GetKeyDown (KeyCode.Return) && player_near_switch) || Input.GetKeyDown (KeyCode.L)) { if ((Input.GetKeyDown (KeyCode.Return) && player_near_switch) || Input.GetKeyDown (KeyCode.L)) {
......
...@@ -7,23 +7,23 @@ public class AM : MonoBehaviour { ...@@ -7,23 +7,23 @@ public class AM : MonoBehaviour {
private AudioSource mic_source; private AudioSource mic_source;
//Globals //Globals
public bool pitch_based = true; public bool pitch_based = true; //Wether or not to use pitch rather then amplitude for calculations
public float color_range_min = 3; public float color_range_min = 3; //Sets how low can the light color go
public float color_range_max = 40; public float color_range_max = 40;
public float spot_fading_speed = 2; public float spot_fading_speed = 0.5f; //How fast should the light angle fade back to the center
public float splash_force_scaler = 100; public float splash_force_scaler = 100; //How powerful can a splash be
public float audio_update_rate = 40.0f; public float audio_update_rate = 40.0f; //How fast do you want to calculate the audio (Drastically affects FPS on low end computers)
public float pitch_precision = 0.1f; //How precise do you want the check to be
private float[] spec_data;
private float[] samp_data; private float[] spec_data; //Will contain the spectrum information from the microphone
private float[] samp_data; //Will contain sample amplitude from the microphone
private int spec_size = 1024;
private int samp_size = 1024; private int spec_size = 1024; //Size of the spectrum buffer
private int buffer_size = 44100; private int samp_size = 64; //Size of the sample buffer (this can be low since we are just averaging the volume)
private int fmax = 24000; private int buffer_size = 24000; // Half of the actual buffer size (from 0 until the Nyquist rate)
private float rms; private float rms = 0; //Will store the RMS values
private float vol; private float vol = 0; //Will store the volume in dB
private float spot_angle = 1; private float spot_angle = 1; //The spot angle at start
private float average_pitch_low = 0; private float average_pitch_low = 0;
private float average_pitch_mid = 0; private float average_pitch_mid = 0;
private float average_pitch_high = 0; private float average_pitch_high = 0;
...@@ -45,8 +45,7 @@ public class AM : MonoBehaviour { ...@@ -45,8 +45,7 @@ public class AM : MonoBehaviour {
void Start () { void Start () {
i = this; i = this;
buffer_size = AudioSettings.outputSampleRate; buffer_size = AudioSettings.outputSampleRate / 2;
fmax = AudioSettings.outputSampleRate / 2;
spec_data = new float[spec_size]; spec_data = new float[spec_size];
samp_data = new float[samp_size]; samp_data = new float[samp_size];
...@@ -56,28 +55,37 @@ public class AM : MonoBehaviour { ...@@ -56,28 +55,37 @@ public class AM : MonoBehaviour {
mic_source.pitch = 0.95f; //slightly slower to avoid stuttering mic_source.pitch = 0.95f; //slightly slower to avoid stuttering
mic_source.loop = true; //loops the second of audio mic_source.loop = true; //loops the second of audio
mic_source.Play (); //starts the playback mic_source.Play (); //starts the playback
mic_source.volume = 0.5f; //Mutes the audiosource mic_source.volume = 0.0000001f; //Mutes the audiosource
set_low = false; set_low = false;
set_mid = false; set_mid = false;
set_high = false; set_high = false;
InvokeRepeating ("BufferPopulator", 0, 1.0f / audio_update_rate); //Begins another thread InvokeRepeating ("BufferPopulator", 0, 1.0f / audio_update_rate); //Begins another thread
InvokeRepeating ("AmplitudeAnalysis", 0, 1.0f / audio_update_rate); //Begins another thread InvokeRepeating ("AmplitudeAnalysis", 1, 1.0f / audio_update_rate); //Begins another thread
InvokeRepeating ("ComplexPitchAnalysis", 0, 1.0f / audio_update_rate); //Begins another thread InvokeRepeating ("ComplexPitchAnalysis", 2, 1.0f / audio_update_rate); //Begins another thread
} }
public void BufferPopulator () { void BufferPopulator () {
mic_source.GetSpectrumData (spec_data, 0, FFTWindow.BlackmanHarris); mic_source.GetSpectrumData (spec_data, 0, FFTWindow.BlackmanHarris);
mic_source.clip.GetData (samp_data, 0); mic_source.clip.GetData (samp_data, 0);
} }
//Anaylsis function: //Anaylsis function:
public void AmplitudeAnalysis () { int eter = 0;
float rms_sum = 0;
void AmplitudeAnalysis () {
float vol_sum = 0; float vol_sum = 0;
for (int i = 0; i < samp_size; i++) { for (int i = 0; i < samp_size; i++) {
vol_sum += Mathf.Abs (samp_data[i] * samp_data[i]); //Calculates the square sum of all the data vol_sum += Mathf.Abs (samp_data[i] * samp_data[i]); //Calculates the square sum of all the data
} }
rms = Mathf.Sqrt (vol_sum / samp_size) * 100; //RMS value if (eter < 5) {
eter++;
rms_sum += Mathf.Sqrt (vol_sum / samp_size) * 100; //RMS sum value to average
} else {
rms = rms_sum / eter; //Final averaged RMS value
rms_sum = 0;
eter = 0;
}
vol = 0; vol = 0;
if (!(vol < 0)) if (!(vol < 0))
...@@ -85,7 +93,7 @@ public class AM : MonoBehaviour { ...@@ -85,7 +93,7 @@ public class AM : MonoBehaviour {
else vol = 0; else vol = 0;
} }
public void ComplexPitchAnalysis () { void ComplexPitchAnalysis () {
//Low - Around 84Hz //Low - Around 84Hz
float Low = (spec_data[low_range] + spec_data[low_range + 1] + spec_data[