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);
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);
}
return output;
}
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
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!196 &2
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
accuratePlacement: 0
m_NavMeshData: {fileID: 0}
--- !u!104 &13
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 7
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
m_AmbientEquatorColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
m_AmbientGroundColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
m_AmbientIntensity: 0.7
m_AmbientMode: 0
m_SkyboxMaterial: {fileID: 2100000, guid: ceb0a3ed2cb53a94fa21843cc958c52b, type: 2}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.09863312, g: 0.11881522, b: 0.14606401, a: 1}
--- !u!157 &17
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 7
m_GIWorkflowMode: 0
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_TemporalCoherenceThreshold: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 4
m_Resolution: 1
m_BakeResolution: 40
m_TextureWidth: 1024
m_TextureHeight: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_DirectLightInLightProbes: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_LightingDataAsset: {fileID: 0}
m_RuntimeCPUUsage: 25
--- !u!1001 &71872492
Prefab:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 4794239916332596, guid: bb97952d1445b40449dfcb823c3d4eec, type: 2}
propertyPath: m_LocalPosition.x
value: 0.34
objectReference: {fileID: 0}
- target: {fileID: 4794239916332596, guid: bb97952d1445b40449dfcb823c3d4eec, type: 2}
propertyPath: m_LocalPosition.y
value: 1.46
objectReference: {fileID: 0}
- target: {fileID: 4794239916332596, guid: bb97952d1445b40449dfcb823c3d4eec, type: 2}
propertyPath: m_LocalPosition.z
value: -0.9
objectReference: {fileID: 0}
- target: {fileID: 4794239916332596, guid: bb97952d1445b40449dfcb823c3d4eec, type: 2}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4794239916332596, guid: bb97952d1445b40449dfcb823c3d4eec, type: 2}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4794239916332596, guid: bb97952d1445b40449dfcb823c3d4eec, type: 2}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4794239916332596, guid: bb97952d1445b40449dfcb823c3d4eec, type: 2}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4794239916332596, guid: bb97952d1445b40449dfcb823c3d4eec, type: 2}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 108759151604776888, guid: bb97952d1445b40449dfcb823c3d4eec,
type: 2}
propertyPath: m_Range
value: 2.95
objectReference: {fileID: 0}
- target: {fileID: 114863510807630850, guid: bb97952d1445b40449dfcb823c3d4eec,
type: 2}
propertyPath: echo_speed
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 114863510807630850, guid: bb97952d1445b40449dfcb823c3d4eec,
type: 2}
propertyPath: echo_current_intensity
value: 4
objectReference: {fileID: 0}
- target: {fileID: 108759151604776888, guid: bb97952d1445b40449dfcb823c3d4eec,
type: 2}
propertyPath: m_Enabled
value: 0
objectReference: {fileID: 0}
- target: {fileID: 82012098038847686, guid: bb97952d1445b40449dfcb823c3d4eec,
type: 2}
propertyPath: panLevelCustomCurve.m_RotationOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 82012098038847686, guid: bb97952d1445b40449dfcb823c3d4eec,
type: 2}
propertyPath: spreadCustomCurve.m_RotationOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 82012098038847686, guid: bb97952d1445b40449dfcb823c3d4eec,
type: 2}
propertyPath: reverbZoneMixCustomCurve.m_RotationOrder
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: bb97952d1445b40449dfcb823c3d4eec, type: 2}
m_IsPrefabParent: 0
--- !u!1 &545831565
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 1085291655187690, guid: d4bd53f01c2f4c44f89fd28aa4ca29c9,
type: 2}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 545831566}
- component: {fileID: 545831569}
- component: {fileID: 545831568}
- component: {fileID: 545831567}
m_Layer: 0
m_Name: collision plane
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &545831566
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 4403276698753482, guid: d4bd53f01c2f4c44f89fd28aa4ca29c9,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 545831565}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 2, y: 1, z: 2}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &545831567
MeshRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 23495640269871906, guid: d4bd53f01c2f4c44f89fd28aa4ca29c9,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 545831565}
m_Enabled: 0
m_CastShadows: 1
m_ReceiveShadows: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 10302, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingOrder: 0
--- !u!64 &545831568
MeshCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 64071859940178228, guid: d4bd53f01c2f4c44f89fd28aa4ca29c9,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 545831565}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Convex: 0
m_InflateMesh: 0
m_SkinWidth: 0.01
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!33 &545831569
MeshFilter:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 33437110337189046, guid: d4bd53f01c2f4c44f89fd28aa4ca29c9,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 545831565}
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1001 &880300696
Prefab:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 4875193128555236, guid: 18aed937680cb7f499c839007b59f412, type: 2}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4875193128555236, guid: 18aed937680cb7f499c839007b59f412, type: 2}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4875193128555236, guid: 18aed937680cb7f499c839007b59f412, type: 2}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4875193128555236, guid: 18aed937680cb7f499c839007b59f412, type: 2}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4875193128555236, guid: 18aed937680cb7f499c839007b59f412, type: 2}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4875193128555236, guid: 18aed937680cb7f499c839007b59f412, type: 2}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4875193128555236, guid: 18aed937680cb7f499c839007b59f412, type: 2}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4875193128555236, guid: 18aed937680cb7f499c839007b59f412, type: 2}
propertyPath: m_RootOrder
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 18aed937680cb7f499c839007b59f412, type: 2}
m_IsPrefabParent: 0
--- !u!1 &977913493
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 977913494}
- component: {fileID: 977913497}
- component: {fileID: 977913496}
- component: {fileID: 977913495}
m_Layer: 0
m_Name: OSD
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &977913494
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 977913493}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_Children:
- {fileID: 1388914526}
- {fileID: 1744390929}
m_Father: {fileID: 1212969024}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!114 &977913495
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 977913493}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1301386320, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreReversedGraphics: 1
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &977913496
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 977913493}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1980459831, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 0
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
--- !u!223 &977913497
Canvas:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 977913493}
m_Enabled: 1
serializedVersion: 2
m_RenderMode: 0
m_Camera: {fileID: 0}
m_PlaneDistance: 100
m_PixelPerfect: 0
m_ReceivesEvents: 1
m_OverrideSorting: 0