Commit a5ee5efb authored by Nathan De Castro's avatar Nathan De Castro

added tutorial scene, Working on highest energy bin

parent 1c7bb5ea
......@@ -66,7 +66,9 @@
<Compile Include="Assets\Scripts\Tools\PlayerSound.cs" />
<Compile Include="Assets\Scripts\Tools\RippleEffect.cs" />
<Compile Include="Assets\Scripts\UI\Info.cs" />
<Compile Include="Assets\Scripts\UI\Instructions.cs" />
<Compile Include="Assets\Scripts\UI\LoadStart.cs" />
<Compile Include="Assets\Scripts\UI\LoadTuto.cs" />
<Compile Include="Assets\Scripts\UI\PickupText.cs" />
<Compile Include="Assets\Scripts\UI\RestartText.cs" />
<Compile Include="Assets\Scripts\UI\Status.cs" />
......
......@@ -4,18 +4,20 @@
public class AM : MonoBehaviour {
public static AM i;
//Global
private AudioSource mic_source;
//Globals
public float color_range_min = 3;
public float color_range_max = 40;
public bool linear_color_change = true;
public bool use_pitch = false;
public float light_angle_scaler = 20;
public float light_angle_max = 130;
public float splash_force_scaler = 100;
public int buffer_size = 32;
public int buffer_size = 64;
private float rms;
private float vol;
private int max_energy_bin = 0;
private float low_pitch = 0;
private float med_pitch = 0;
private float high_pitch = 0;
......@@ -61,6 +63,14 @@ public class AM : MonoBehaviour {
float[] spec_data = new float[buf_size];
mic_source.GetSpectrumData (spec_data, 0, FFTWindow.Rectangular);
//Attemps to isolate the bin with the Highest energy
for (int i = 1; i < buf_size; i++) {
if (spec_data[i] > spec_data[i - 1]) {
max_energy_bin = i;
}
}
//Seperates the array in 3 from lowest pitch to Highest
//Low Pitch
float low_pitch_sum = 0; //Inits a float to store the sum of all the index arrays
int low_cut = buf_size / 10;
......@@ -75,7 +85,7 @@ public class AM : MonoBehaviour {
mid_pitch_sum += Mathf.Abs (spec_data[low_cut + spec_index]); //Only grabs the second Third values of the array (so the "low" pitch values)
}
//High Pitch<
//High Pitch
float high_pitch_sum = 0; //Inits a float to store the sum of all the index arrays
int high_cut = buf_size - mid_cut;
for (int spec_index = mid_cut; spec_index < high_cut; spec_index++) {
......@@ -100,6 +110,10 @@ public class AM : MonoBehaviour {
return new Vector3 (low_pitch, med_pitch, high_pitch);
}
public int GetMaxEnergyBin () {
return max_energy_bin;
}
public float GetLightAngle () {
bool threshold_reached = PlayerSound.instance.GetComponentInChildren<Light> ().spotAngle > light_angle_max;
......@@ -114,22 +128,18 @@ public class AM : MonoBehaviour {
return (int) (rms * splash_force_scaler);
}
public Color GetLightColor_vol () {
public Color GetLightColor () {
Color output;
//Linear interpolation:
if (linear_color_change) {
if (!use_pitch) {
float r = Mathf.Abs ((rms - color_range_min) / color_range_max);
float b = Mathf.Abs (1 - r);
output = new Color (r, 0, b, 0.8f);
} else {
output = new Color (0, 0, 0, 1);
}
return output;
float r = Mathf.Abs ((max_energy_bin - color_range_min) / color_range_max);
float b = Mathf.Abs (1 - r);
output = new Color (r, 0, b, 0.8f);
}
public Color GetLightColor_pitch () {
Color output = new Color (0, 0, 0, 1);
return output;
}
}
\ No newline at end of file
......@@ -6,7 +6,6 @@ public class PlayerSound : MonoBehaviour {
//LIGHT
private Light light_self;
public bool use_mic = false;
public bool pitch_2_color = false;
// Use this for initialization
void Start () {
......@@ -18,10 +17,7 @@ public class PlayerSound : MonoBehaviour {
void Update () {
if (use_mic && this.gameObject.tag == "Player") {
light_self.spotAngle = AM.i.GetLightAngle ();
if (!pitch_2_color)
light_self.color = AM.i.GetLightColor_vol ();
else light_self.color = AM.i.GetLightColor_pitch ();
light_self.color = AM.i.GetLightColor ();
}
}
}
\ No newline at end of file
......@@ -56,17 +56,7 @@ public class RippleEffect : MonoBehaviour {
{
// initiates the values of each vertices according to their distance from the center such as the further you are from it the weak the force is.
int position = ((y * (cols + 1)) + x);
if (GhostSound.instance != null && GhostSound.instance.made_noise) {
buffer1[position] = splash_force;
buffer1[position - 1] = splash_force;
buffer1[position + 1] = splash_force;
buffer1[position + (cols + 1)] = splash_force;
buffer1[position + (cols + 1) + 1] = splash_force;
buffer1[position + (cols + 1) - 1] = splash_force;
buffer1[position - (cols + 1)] = splash_force;
buffer1[position - (cols + 1) + 1] = splash_force;
buffer1[position - (cols + 1) - 1] = splash_force;
} else if (PlayerSound.instance.use_mic) {
if (PlayerSound.instance.use_mic) {
buffer1[position] = splash_force_mic;
buffer1[position - 1] = splash_force_mic;
buffer1[position + 1] = splash_force_mic;
......@@ -92,9 +82,9 @@ public class RippleEffect : MonoBehaviour {
void Update () {
if (5 < update_rate)
update_rate = (int) (1 / AM.i.GetVolume()) * 10;
update_rate = (int) (1 / AM.i.GetVolume ()) * 10;
else update_rate = 5;
if (tick (update_rate) && PlayerSound.instance.use_mic == true && AM.i.GetRMS () >= 4f) {
if ((tick (update_rate) && PlayerSound.instance.use_mic == true && AM.i.GetRMS () >= 4f) || Input.GetKeyDown (KeyCode.Space)) {
splash_force_mic = AM.i.GetSplashForce ();
SplashDetect (); //Checks wether a splash has been initiated
}
......
......@@ -11,6 +11,5 @@ public class Info : MonoBehaviour {
void Update () {
info_text.text = "RMS: " + AM.i.GetRMS () + " dB: " + AM.i.GetVolume ();
}
}
\ No newline at end of file
using UnityEngine;
using UnityEngine.UI;
public class Instructions : MonoBehaviour {
private Text info_text;
void Start () {
info_text = GetComponent<Text> ();
info_text.text = "";
}
void Update () {
info_text.text = "Don't worry, you are safe here =)";
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: cadef5635d7108c4eb44dfb5afd3dac6
timeCreated: 1486916418
guid: fae0d039dd56e9649868086c4dc8ce7b
timeCreated: 1484769447
licenseType: Free
DefaultImporter:
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine.SceneManagement;
using UnityEngine;
public class LoadTuto : MonoBehaviour
{
public void Load_Tuto()
{
SceneManager.LoadScene("Tutorial");
}
}
fileFormatVersion: 2
guid: 03f21125d881ab94b9170d4bd457d37d
timeCreated: 1488643211
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -10,6 +10,6 @@ public class Visibility : MonoBehaviour {
}
void Update () {
info_text.text = "Pitch: " + AM.i.GetPitch ();
info_text.text = "Pitch: " + AM.i.GetPitch () + " Bin: " + AM.i.GetMaxEnergyBin ();
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -4789,7 +4789,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!4 &157629041
Transform:
m_ObjectHideFlags: 0
......@@ -28918,7 +28918,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
color_range_min: 3
color_range_max: 40
linear_color_change: 1
use_pitch: 0
light_angle_scaler: 5
light_angle_max: 130
splash_force_scaler: 5
......@@ -37327,7 +37327,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!108 &1549895649
Light:
m_ObjectHideFlags: 0
This diff is collapsed.
This diff is collapsed.
fileFormatVersion: 2
guid: 1c3b6dae14201a549871460d54030ee2
guid: 5d3f5ba575e3b0347958cc4baef3603e
timeCreated: 1485509989
licenseType: Free
DefaultImporter:
......
sceneSetups:
- path: Assets/_Scenes/Start.unity
- path: Assets/_Scenes/Tutorial.unity
isLoaded: 1
isActive: 1
0000.5837028e.0000
0000.583702a0.0000
\ No newline at end of file
No preview for this file type
No preview for this file type
Base path: C:/Program Files/Unity/Editor/Data
Cmd: getPlatforms
Cmd: compileSnippet
api=4 type=0 insize=1023 outsize=1874 kw=DIRECTIONAL SHADOWS_SCREEN _EMISSION _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A pd=UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING SHADER_API_DESKTOP ok=1
Cmd: compileSnippet
api=4 type=1 insize=1023 outsize=6210 kw=DIRECTIONAL SHADOWS_SCREEN _EMISSION _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A pd=UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING SHADER_API_DESKTOP ok=1
Cmd: compileSnippet
api=4 type=0 insize=949 outsize=1718 kw=SPOT _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A pd=UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING SHADER_API_DESKTOP ok=1
Cmd: compileSnippet
api=4 type=1 insize=949 outsize=3138 kw=SPOT _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A pd=UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING SHADER_API_DESKTOP ok=1
Cmd: compileSnippet
api=4 type=0 insize=1023 outsize=1698 kw=DIRECTIONAL _EMISSION _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A pd=UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING SHADER_API_DESKTOP ok=1
Cmd: compileSnippet
api=4 type=1 insize=1023 outsize=6058 kw=DIRECTIONAL _EMISSION _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A pd=UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING SHADER_API_DESKTOP ok=1
Cmd: compileSnippet
api=4 type=0 insize=949 outsize=1378 kw=DIRECTIONAL _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A pd=UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING SHADER_API_DESKTOP ok=1
Cmd: compileSnippet
api=4 type=1 insize=949 outsize=2666 kw=DIRECTIONAL _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A pd=UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING SHADER_API_DESKTOP ok=1
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment