Commit 44344a15 authored by Nathan De Castro's avatar Nathan De Castro

Added colors, testing pitch detection, dynamic enableing

parent bcfcecc2
...@@ -50,8 +50,12 @@ ...@@ -50,8 +50,12 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Assets\Scripts\AI\AI.cs" /> <Compile Include="Assets\Scripts\AI\AI.cs" />
<Compile Include="Assets\Scripts\Effects\CurrentPlayer.cs" /> <Compile Include="Assets\Scripts\AI\CurrentPlayer.cs" />
<Compile Include="Assets\Scripts\Effects\BigEnabler.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\SwitchState.cs" />
<Compile Include="Assets\Scripts\Tools\AudioManager.cs" /> <Compile Include="Assets\Scripts\Tools\AudioManager.cs" />
<Compile Include="Assets\Scripts\Tools\FPS_Camera.cs" /> <Compile Include="Assets\Scripts\Tools\FPS_Camera.cs" />
<Compile Include="Assets\Scripts\Tools\FPS_Control.cs" /> <Compile Include="Assets\Scripts\Tools\FPS_Control.cs" />
...@@ -66,6 +70,7 @@ ...@@ -66,6 +70,7 @@
<Compile Include="Assets\Scripts\UI\PickupText.cs" /> <Compile Include="Assets\Scripts\UI\PickupText.cs" />
<Compile Include="Assets\Scripts\UI\RestartText.cs" /> <Compile Include="Assets\Scripts\UI\RestartText.cs" />
<Compile Include="Assets\Scripts\UI\Status.cs" /> <Compile Include="Assets\Scripts\UI\Status.cs" />
<Compile Include="Assets\Scripts\UI\Visibility.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" />
......
...@@ -7,9 +7,9 @@ Material: ...@@ -7,9 +7,9 @@ Material:
m_PrefabParentObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0} m_PrefabInternal: {fileID: 0}
m_Name: Coin m_Name: Coin
m_Shader: {fileID: 10755, guid: 0000000000000000f000000000000000, type: 0} m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: _EMISSION m_ShaderKeywords: _EMISSION
m_LightmapFlags: 1 m_LightmapFlags: 0
m_CustomRenderQueue: -1 m_CustomRenderQueue: -1
stringTagMap: {} stringTagMap: {}
m_SavedProperties: m_SavedProperties:
...@@ -69,6 +69,12 @@ Material: ...@@ -69,6 +69,12 @@ Material:
m_Texture: {fileID: 0} m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1} m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0} m_Offset: {x: 0, y: 0}
- first:
name: _SpecGlossMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats: m_Floats:
- first: - first:
name: _BumpScale name: _BumpScale
...@@ -121,7 +127,10 @@ Material: ...@@ -121,7 +127,10 @@ Material:
m_Colors: m_Colors:
- first: - first:
name: _Color name: _Color
second: {r: 0.74264705, g: 0.66069984, b: 0, a: 0} second: {r: 0, g: 0, b: 0, a: 1}
- first: - first:
name: _EmissionColor name: _EmissionColor
second: {r: 0.3118154, g: 0.31617647, b: 0, a: 1} second: {r: 7.454077, g: 8.64673, b: 0, a: 1}
- first:
name: _SpecColor
second: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
...@@ -6,13 +6,12 @@ Material: ...@@ -6,13 +6,12 @@ Material:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0} m_PrefabInternal: {fileID: 0}
m_Name: Exclamation m_Name: Switch
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: _ALPHAPREMULTIPLY_ON _EMISSION m_ShaderKeywords: _EMISSION
m_LightmapFlags: 1 m_LightmapFlags: 1
m_CustomRenderQueue: 3000 m_CustomRenderQueue: -1
stringTagMap: stringTagMap: {}
RenderType: Transparent
m_SavedProperties: m_SavedProperties:
serializedVersion: 2 serializedVersion: 2
m_TexEnvs: m_TexEnvs:
...@@ -82,7 +81,7 @@ Material: ...@@ -82,7 +81,7 @@ Material:
second: 1 second: 1
- first: - first:
name: _DstBlend name: _DstBlend
second: 10 second: 0
- first: - first:
name: _GlossMapScale name: _GlossMapScale
second: 1 second: 1
...@@ -97,7 +96,7 @@ Material: ...@@ -97,7 +96,7 @@ Material:
second: 0 second: 0
- first: - first:
name: _Mode name: _Mode
second: 3 second: 0
- first: - first:
name: _OcclusionStrength name: _OcclusionStrength
second: 1 second: 1
...@@ -118,11 +117,11 @@ Material: ...@@ -118,11 +117,11 @@ Material:
second: 0 second: 0
- first: - first:
name: _ZWrite name: _ZWrite
second: 0 second: 1
m_Colors: m_Colors:
- first: - first:
name: _Color name: _Color
second: {r: 0.9191176, g: 0.03379107, b: 0.03379107, a: 1} second: {r: 0.9191176, g: 0.03379107, b: 0.03379107, a: 1}
- first: - first:
name: _EmissionColor name: _EmissionColor
second: {r: 0.802, g: 0.047176465, b: 0.047176465, a: 1} second: {r: 0, g: 0, b: 0, a: 1}
This diff is collapsed.
fileFormatVersion: 2
guid: 97e634f2d7c5fd44b945eccdb578e60a
timeCreated: 1489666582
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
...@@ -51,7 +51,7 @@ Transform: ...@@ -51,7 +51,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000010081106018} m_GameObject: {fileID: 1000010081106018}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 62.52, y: 3.85, z: 28.31} m_LocalPosition: {x: 24.5, y: 3.687, z: 13.8}
m_LocalScale: {x: 0.5357632, y: 0.53576386, z: 0.53576386} m_LocalScale: {x: 0.5357632, y: 0.53576386, z: 0.53576386}
m_Children: [] m_Children: []
m_Father: {fileID: 4000013667792572} m_Father: {fileID: 4000013667792572}
......
...@@ -46,7 +46,7 @@ public class AI : MonoBehaviour { ...@@ -46,7 +46,7 @@ public class AI : MonoBehaviour {
} }
void FixedUpdate () { void FixedUpdate () {
ray_magnitude = AudioManager.instance.GetLightRange() / ghost_awarness; ray_magnitude = AudioManager.instance.GetLightAngle() / ghost_awarness;
if (GameSettings.instance.lose_state == false && GameSettings.instance.win_state == false) //IF you die, these won't be called anymore. if (GameSettings.instance.lose_state == false && GameSettings.instance.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
......
using UnityEngine; using UnityEngine;
//Another singleton that stores all player relevant information. //Another singleton that stores all player relevant information.
public class CurrentPlayer : MonoBehaviour public class CurrentPlayer : MonoBehaviour {
{
public static CurrentPlayer instance; public static CurrentPlayer instance;
public GameObject player; public GameObject player;
public bool walking = false; void Awake () {
void Awake()
{
instance = this; instance = this;
print("PlayerSettings initialized"); // print("PlayerSettings initialized");
player = this.gameObject; player = this.gameObject;
} }
void Start() void Start () {
{
} }
void Update() void Update () {
{
} }
} }
\ No newline at end of file
fileFormatVersion: 2 fileFormatVersion: 2
guid: 5ae009a233e5930428d03c07d819d7c8 guid: 502dc647dd3b62745b69ffe781c937ed
timeCreated: 1486901373 timeCreated: 1489764984
licenseType: Free licenseType: Free
MonoImporter: MonoImporter:
serializedVersion: 2 serializedVersion: 2
......
using UnityEngine;
// A simple rotating script for the walls of the player area
public class BigEnabler : MonoBehaviour {
public bool Activated = false;
Renderer[] rendererComponents;
void Start () {
rendererComponents = GetComponentsInChildren<Renderer> ();
}
// Update is called once per frame
void Update () {
if (AudioManager.instance.GetPitchValue () == 1) {
Activated = true;
} else {
Activated = false;
}
foreach (Renderer component in rendererComponents) {
component.enabled = Activated;
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: decc41780f1c3ce47831fdc2ba166dc8
timeCreated: 1489764984
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
// A simple rotating script for the walls of the player area
public class MediumEnabler : MonoBehaviour {
public bool Activated = false;
Renderer[] rendererComponents;
void Start () {
rendererComponents = GetComponentsInChildren<Renderer> ();
}
// Update is called once per frame
void Update () {
if (AudioManager.instance.GetPitchValue () == 1) {
Activated = true;
} else {
Activated = false;
}
foreach (Renderer component in rendererComponents) {
component.enabled = Activated;
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 3a884741abaa75949860f5870a7b50f4
timeCreated: 1489764984
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
// A simple rotating script for the walls of the player area
public class SmallEnabler : MonoBehaviour {
public bool Activated = false;
Renderer[] rendererComponents;
void Start () {
rendererComponents = GetComponentsInChildren<Renderer> ();
}
// Update is called once per frame
void Update () {
if (AudioManager.instance.GetPitchValue () == 0) {
Activated = true;
} else {
Activated = false;
}
foreach (Renderer component in rendererComponents) {
component.enabled = Activated;
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: ebc134e75b88094448b9317c1484dede
timeCreated: 1489764984
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
public class SwitchState : MonoBehaviour {
public Light main_light;
public GameObject switch_on;
public GameObject switch_off;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
bool player_near_by = Vector3.Distance (CurrentPlayer.instance.transform.position, this.transform.position) < 5;
//Turns on the light when the button is pressed
if (Input.GetKeyDown (KeyCode.Return) && player_near_by) {
main_light.gameObject.SetActive (switch_off.activeSelf);
switch_off.SetActive (!switch_off.activeSelf);
switch_on.SetActive (!switch_off.activeSelf);
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 70d3447759e9d63479797beb15dbf4fd
timeCreated: 1489764984
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -7,29 +7,24 @@ public class AudioManager : MonoBehaviour { ...@@ -7,29 +7,24 @@ public class AudioManager : MonoBehaviour {
//Global //Global
private AudioClip mic; private AudioClip mic;
public float intensity = 80; private AudioSource mic_source;
public float volume_range_min = 30; public float volume_range_min;
public float volume_range_max = 200; public float volume_range_max;
public bool linear = true; public bool linear = true;
public int buffer_size = 44100; public int buffer_size;
public float light_range_value = 11; public float light_angle_value;
public float splash_force_value = 2; public float light_angle_max;
public float splash_force_value;
void Start () { void Start () {
instance = this; instance = this;
print ("AudioManager initialized"); // print ("AudioManager initialized");
mic = Microphone.Start ("Built-in Microphone", true, 1, 44100); //Microphone setup (null will select the default Microphone) mic = Microphone.Start ("Built-in Microphone", true, 1, buffer_size); //Microphone setup (null will select the default Microphone)
mic_source.clip = mic;
} }
void Update () { public Vector3 GetSpecEnergy () {
//GetSpeqData (); float[] spec_data = new float[buffer_size]; //Creates an array pre-allocated (We want it quite small to reduce latency, I made it tweakable from the inspector)
GetLightColor ();
GetLightRange ();
}
public Vector3 GetFreqSpec () {
float[] spec_data = new float[44100]; //Creates an array pre-allocated (We want it quite small to reduce latency, I made it tweakable from the inspector)
mic.GetData (spec_data, 0); //Stores all the output data into the array I pre-allocated mic.GetData (spec_data, 0); //Stores all the output data into the array I pre-allocated
//Low Pitch //Low Pitch
...@@ -49,44 +44,60 @@ public class AudioManager : MonoBehaviour { ...@@ -49,44 +44,60 @@ public class AudioManager : MonoBehaviour {
for (int spec_index = 0; spec_index < spec_data.Length / 3; spec_index++) { for (int spec_index = 0; spec_index < spec_data.Length / 3; spec_index++) {
high_pitch_sum += Mathf.Abs (spec_data[spec_index + ((spec_data.Length / 3) * 2)]); //Only grabs the third Third values of the array (so the "low" pitch values) high_pitch_sum += Mathf.Abs (spec_data[spec_index + ((spec_data.Length / 3) * 2)]); //Only grabs the third Third values of the array (so the "low" pitch values)
} }
return new Vector3 ((low_pitch_sum / (spec_data.Length / 3) * intensity), (mid_pitch_sum / (spec_data.Length / 3) * intensity), (high_pitch_sum / (spec_data.Length / 3) * intensity)); //Populates a Final vectore with the average of the sums of the all three parts of the buffer return new Vector3 ((low_pitch_sum / (spec_data.Length / 3) * 30), (mid_pitch_sum / (spec_data.Length / 3) * 30), (high_pitch_sum / (spec_data.Length / 3) * 30)); //Populates a Final vectore with the average of the sums of the all three parts of the buffer
} }
public float GetAverageVolume () { public float GetAverageVolume () {
return ((GetFreqSpec () [0]) + (GetFreqSpec () [1]) + (GetFreqSpec () [2] / 3)); //Grouping all 3 arrays into 1 to get average of all values (global volume) return ((GetSpecEnergy ()[0] + GetSpecEnergy ()[1] + GetSpecEnergy ()[2]) / 3); //Grouping all 3 arrays into 1 to get average of all values (global volume)
} }
public float GetLightRange () { public Vector4 GetPitchData () {
return GetAverageVolume () * light_range_value; float[] spec_data = new float[1024];
mic_source.GetSpectrumData (spec_data, 0, FFTWindow.Rectangular);
float Bin_1 = (spec_data[0] + spec_data[2] + spec_data[4]) / 3;
float Bin_2 = (spec_data[10] + spec_data[11] + spec_data[12]) / 3;
float Bin_3 = (spec_data[20] + spec_data[21] + spec_data[22]) / 3;
float Bin_4 = (spec_data[40] + spec_data[41] + spec_data[42] + spec_data[43]) / 4;
float Bin_5 = (spec_data[80] + spec_data[81] + spec_data[82] + spec_data[83]) / 4;
float Bin_6 = (spec_data[160] + spec_data[161] + spec_data[162] + spec_data[163]) / 5;
float Bin_7 = (spec_data[320] + spec_data[321] + spec_data[322] + spec_data[323]) / 5;
return new Vector4(Bin_1, Bin_3, Bin_5, Bin_7);
}
public float GetLightAngle () {
bool threshold_reached = PlayerSound.instance.GetComponentInChildren<Light> ().spotAngle > light_angle_max;
if (!threshold_reached) {
return GetAverageVolume () * light_angle_value;
} else {
return light_angle_max;
}
} }
public float GetSplashForce () { public int GetSplashForce () {
print("1"); return (int) (GetAverageVolume () * splash_force_value);
return GetLightRange () * splash_force_value;
} }
public Color GetLightColor () { public Color GetLightColor () {
Color output; Color output;
//Linear interpolation: //Linear interpolation:
if (linear) { if (linear) {
float r = Mathf.Abs ((GetLightRange () - volume_range_min) / volume_range_max); float r = Mathf.Abs ((GetAverageVolume () - volume_range_min) / volume_range_max);
float b = 1 - r; float b = Mathf.Abs (1 - r);
output = new Color (r, 0, b, 0.8f); output = new Color (r, 0, b, 0.8f);
} else { } else {
output = new Color (0, 0, 0, 1); output = new Color (0, 0, 0, 1);
} }
return output; return output;
} }
public void GetSpeqData () { public int GetPitchValue () {
// float[] spectrum = new float[256]; int output = 0;
if (GetAverageVolume () > volume_range_max - (volume_range_max / 3)) {
// for (int i = 1; i < spectrum.Length - 1; i++) { return output = 2;
// Debug.DrawLine (new Vector3 (i - 1, spectrum[i] + 10, 0), new Vector3 (i, spectrum[i + 1] + 10, 0), Color.red); } else if (GetAverageVolume () > volume_range_max / 3) {
// Debug.DrawLine (new Vector3 (i - 1, Mathf.Log (spectrum[i - 1]) + 10, 2), new Vector3 (i, Mathf.Log (spectrum[i]) + 10, 2), Color.cyan); return output = 1;
// Debug.DrawLine (new Vector3 (Mathf.Log (i - 1), spectrum[i - 1] - 10, 1), new Vector3 (Mathf.Log (i), spectrum[i] - 10, 1), Color.green); }
// Debug.DrawLine (new Vector3 (Mathf.Log (i - 1), Mathf.Log (spectrum[i - 1]), 3), new Vector3 (Mathf.Log (i), Mathf.Log (spectrum[i]), 3), Color.blue); return output;
// }
} }
} }
\ No newline at end of file
...@@ -4,8 +4,7 @@ using UnityEngine.SceneManagement; ...@@ -4,8 +4,7 @@ using UnityEngine.SceneManagement;
//This is a big singleton class containing all the game settings information. //This is a big singleton class containing all the game settings information.
//Most variables are straightfoward //Most variables are straightfoward
public class GameSettings : MonoBehaviour public class GameSettings : MonoBehaviour {
{
static public GameSettings instance; //Singleton static public GameSettings instance; //Singleton
public GameObject death_cam_set; public GameObject death_cam_set;
static public GameObject death_cam; static public GameObject death_cam;
...@@ -25,33 +24,29 @@ public class GameSettings : MonoBehaviour ...@@ -25,33 +24,29 @@ public class GameSettings : MonoBehaviour