diff --git a/Assets/Scripts/Earthquake.cs b/Assets/Scripts/Earthquake.cs index 2a8829c..74d8a45 100644 --- a/Assets/Scripts/Earthquake.cs +++ b/Assets/Scripts/Earthquake.cs @@ -2,44 +2,57 @@ using UnityEngine; using System.Collections; -public class Earthquake : MonoBehaviour { - int gaugeLevel; - public int gaugeMax=100; +public class Earthquake : MonoBehaviour { + + public float CriticalMin; + public float CriticalMax; + //public float testValue; + + //public float gaugeLevel; + //public int gaugeMax=100; + private SpriteRenderer core; + PlanetManager pmgr; + // Use this for initialization - public void Start() - { - gaugeLevel = 0; - InvokeRepeating("FillGauge", 1, 1F); + public void Start() + { + pmgr = FindObjectOfType(); + //gaugeLevel = 0; + core = this.GetComponent(); + //InvokeRepeating("FillGauge", 1, 1F); } // Update is called once per frame - public void Update () { - + public void Update () { + float disbalance = pmgr.GetDisbalance(); + float val = Mathf.Clamp((disbalance-CriticalMin) / (CriticalMax-CriticalMin),0,1); + + float val2 = Mathf.Clamp((val - 0.6f) / 0.4f, 0, 1); + pmgr.setColor(val2); + + core.color = new Color(1f, 1f - val, 1f - val); + } /// /// Actualiser l'affichage de la gauge /// - public void UpdateFixed() - { - - - - + public void UpdateFixed() + { } /// /// à être Appelé à chaque fois qu'on enfonce un plateau, le gage se remplis plus vite. (et par le temps) /// - public void FillGauge() + public void Fill4Gauge() { - if (gaugeLevel < gaugeMax) + + /*if (gaugeLevel < gaugeMax) { gaugeLevel += 1; - //anim state [0-90] normale, rotation //color hue de plus en plus vers le rouge @@ -59,7 +72,7 @@ public class Earthquake : MonoBehaviour { gaugeLevel = 0; } - print("gauge is at: " + gaugeLevel); + print("gauge is at: " + gaugeLevel);*/ } diff --git a/Assets/Scripts/PlanetManager.cs b/Assets/Scripts/PlanetManager.cs index 0d56be4..9f38c02 100644 --- a/Assets/Scripts/PlanetManager.cs +++ b/Assets/Scripts/PlanetManager.cs @@ -14,12 +14,15 @@ public class PlanetManager : MonoBehaviour public float CartierMinRatio = 0.4f; public float CartierMaxRatio = 2.0f; public float CartierStepSize = 0.25f; + public float balanceValue; + private float disbalance = 0f; public GameObject WedgePrefab = null; public List wedges = new List(); // Use this for initialization public void Awake () { TailleCartiersEnDegres = 360.0f / NbCartiers; + balanceValue = (CartierMaxRatio + CartierMinRatio) / 2; for(int i = 0; i < NbCartiers; i++) { @@ -39,8 +42,31 @@ public class PlanetManager : MonoBehaviour // Update is called once per frame public void Update () { - + + } + public void setColor(float val) + { + foreach (Wedge w in wedges) { + //w = new Color(1f, 1f - val, 1f - val); + w.sprite.GetComponentInChildren().color = new Color(1f, (1-val), (1-val)); + } + + //TODO make planet red + //TODO screen shake + //TODO controller shake? + } + + public float GetDisbalance() + { + disbalance = 0; + foreach (var w in wedges) + { + var temp = Math.Abs((w.offset - balanceValue) / (CartierMaxRatio - balanceValue)); + disbalance += temp; + } + disbalance /= NbCartiers; + return disbalance; } public void FixedUpdate() @@ -84,29 +110,28 @@ public class PlanetManager : MonoBehaviour public void PushWedge(float thetaPlayerX) { - var index = GetWedgeIndex(thetaPlayerX); - var w = wedges[index]; + var index = GetWedgeIndex(thetaPlayerX); + var w = wedges[index]; - w.offset = w.offset - CartierStepSize; - if (w.offset < CartierMinRatio) - w.offset = CartierMinRatio; + w.offset = w.offset - CartierStepSize; + if (w.offset < CartierMinRatio) + w.offset = CartierMinRatio; + + w.sprite.transform.localScale = new Vector3(w.offset, w.offset, 1); + //push back l'opposée + var indexOppose = GetWedgeOpposé(index); + var v = wedges[indexOppose]; - w.sprite.transform.localScale = new Vector3(w.offset, w.offset, 1); + v.offset = v.offset + CartierStepSize; + if (v.offset > CartierMaxRatio) + v.offset = CartierMaxRatio; - //push back l'opposée - var indexOppose = GetWedgeOpposé(index); - var v = wedges[indexOppose]; + v.sprite.transform.localScale = new Vector3(v.offset, v.offset, 1); - v.offset = v.offset + CartierStepSize; - if (v.offset > CartierMaxRatio) - v.offset = CartierMaxRatio; - - v.sprite.transform.localScale = new Vector3(v.offset, v.offset, 1); - - // call fill gauge after every hit. - var earthQuakeGauge = FindObjectOfType(); - earthQuakeGauge.FillGauge(); + // call fill gauge after every hit. + var earthQuakeGauge = FindObjectOfType(); + earthQuakeGauge.Fill4Gauge(); } @@ -118,8 +143,10 @@ public class PlanetManager : MonoBehaviour foreach (var w in wedges) { w.offset = w.offset + CartierStepSize; - if (w.offset > CartierMaxRatio) - w.offset = CartierMaxRatio; + if (w.offset > CartierMaxRatio) + { + w.offset = CartierMaxRatio; + } } } diff --git a/Assets/_Scenes/sophieMain.unity b/Assets/_Scenes/sophieMain.unity new file mode 100644 index 0000000..650a3fa --- /dev/null +++ b/Assets/_Scenes/sophieMain.unity @@ -0,0 +1,430 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + 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.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 3 + m_SkyboxMaterial: {fileID: 0} + 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} +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_GIWorkflowMode: 1 + m_LightmapsMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 0 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 3 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AOMaxDistance: 1 + m_Padding: 2 + m_CompAOExponent: 0 + m_LightmapParameters: {fileID: 0} + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherRayCount: 1024 + m_ReflectionCompression: 2 + m_LightingDataAsset: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: 0.16666667 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!114 &1027139440 stripped +MonoBehaviour: + m_PrefabParentObject: {fileID: 11471614, guid: 198e988adacced646a19f757f6237ae1, + type: 2} + m_PrefabInternal: {fileID: 1469146136} + m_Script: {fileID: 11500000, guid: 43d953650863ce04d8918939e0248654, type: 3} +--- !u!1001 &1072533353 +Prefab: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 498212, guid: 158e745881137e04ca2086294f44d74c, type: 2} + propertyPath: m_LocalPosition.x + value: -0.6692338 + objectReference: {fileID: 0} + - target: {fileID: 498212, guid: 158e745881137e04ca2086294f44d74c, type: 2} + propertyPath: m_LocalPosition.y + value: 1.7862048 + objectReference: {fileID: 0} + - target: {fileID: 498212, guid: 158e745881137e04ca2086294f44d74c, type: 2} + propertyPath: m_LocalPosition.z + value: -0.045327663 + objectReference: {fileID: 0} + - target: {fileID: 498212, guid: 158e745881137e04ca2086294f44d74c, type: 2} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 498212, guid: 158e745881137e04ca2086294f44d74c, type: 2} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 498212, guid: 158e745881137e04ca2086294f44d74c, type: 2} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 498212, guid: 158e745881137e04ca2086294f44d74c, type: 2} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 498212, guid: 158e745881137e04ca2086294f44d74c, type: 2} + propertyPath: m_RootOrder + value: 4 + objectReference: {fileID: 0} + - target: {fileID: 11450178, guid: 158e745881137e04ca2086294f44d74c, type: 2} + propertyPath: InputMapperAsset + value: + objectReference: {fileID: 11400000, guid: ba52e0f13249c9e46bb162622e61904f, + type: 2} + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 100100000, guid: 158e745881137e04ca2086294f44d74c, type: 2} + m_IsPrefabParent: 0 +--- !u!1001 &1223268487 +Prefab: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 456206, guid: e86e27c7b6d9c824cb76115e90a15cac, type: 2} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 456206, guid: e86e27c7b6d9c824cb76115e90a15cac, type: 2} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 456206, guid: e86e27c7b6d9c824cb76115e90a15cac, type: 2} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 456206, guid: e86e27c7b6d9c824cb76115e90a15cac, type: 2} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 456206, guid: e86e27c7b6d9c824cb76115e90a15cac, type: 2} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 456206, guid: e86e27c7b6d9c824cb76115e90a15cac, type: 2} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 456206, guid: e86e27c7b6d9c824cb76115e90a15cac, type: 2} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 456206, guid: e86e27c7b6d9c824cb76115e90a15cac, type: 2} + propertyPath: m_RootOrder + value: 1 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 100100000, guid: e86e27c7b6d9c824cb76115e90a15cac, type: 2} + m_IsPrefabParent: 0 +--- !u!1001 &1469146136 +Prefab: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 421424, guid: 198e988adacced646a19f757f6237ae1, type: 2} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 421424, guid: 198e988adacced646a19f757f6237ae1, type: 2} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 421424, guid: 198e988adacced646a19f757f6237ae1, type: 2} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 421424, guid: 198e988adacced646a19f757f6237ae1, type: 2} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 421424, guid: 198e988adacced646a19f757f6237ae1, type: 2} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 421424, guid: 198e988adacced646a19f757f6237ae1, type: 2} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 421424, guid: 198e988adacced646a19f757f6237ae1, type: 2} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 421424, guid: 198e988adacced646a19f757f6237ae1, type: 2} + propertyPath: m_RootOrder + value: 2 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 100100000, guid: 198e988adacced646a19f757f6237ae1, type: 2} + m_IsPrefabParent: 0 +--- !u!1001 &1660116367 +Prefab: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 494126, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 494126, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 494126, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} + propertyPath: m_LocalPosition.z + value: 0.11 + objectReference: {fileID: 0} + - target: {fileID: 494126, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 494126, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 494126, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 494126, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 494126, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} + propertyPath: m_RootOrder + value: 3 + objectReference: {fileID: 0} + - target: {fileID: 11494368, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} + propertyPath: planet + value: + objectReference: {fileID: 1027139440} + - target: {fileID: 154602, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} + propertyPath: m_Name + value: Astronaut_1 + objectReference: {fileID: 0} + - target: {fileID: 5402556, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} + propertyPath: m_AngularDrag + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5402556, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} + propertyPath: m_IsKinematic + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5402556, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} + propertyPath: m_UseGravity + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5402556, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} + propertyPath: m_Mass + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 13683032, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} + propertyPath: m_Center.y + value: 1.31 + objectReference: {fileID: 0} + - target: {fileID: 13683032, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} + propertyPath: m_Height + value: 1.59 + objectReference: {fileID: 0} + - target: {fileID: 13683032, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} + propertyPath: m_Radius + value: 0.76 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 100100000, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} + m_IsPrefabParent: 0 +--- !u!1001 &1867085521 +Prefab: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 483280, guid: 8347d06db0c264442891d12282c4a4dd, type: 2} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 483280, guid: 8347d06db0c264442891d12282c4a4dd, type: 2} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 483280, guid: 8347d06db0c264442891d12282c4a4dd, type: 2} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 483280, guid: 8347d06db0c264442891d12282c4a4dd, type: 2} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 483280, guid: 8347d06db0c264442891d12282c4a4dd, type: 2} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 483280, guid: 8347d06db0c264442891d12282c4a4dd, type: 2} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 483280, guid: 8347d06db0c264442891d12282c4a4dd, type: 2} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 483280, guid: 8347d06db0c264442891d12282c4a4dd, type: 2} + propertyPath: m_RootOrder + value: 5 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 100100000, guid: 8347d06db0c264442891d12282c4a4dd, type: 2} + m_IsPrefabParent: 0 +--- !u!1 &1945693977 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1945693982} + - 20: {fileID: 1945693981} + - 92: {fileID: 1945693980} + - 124: {fileID: 1945693979} + - 81: {fileID: 1945693978} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &1945693978 +AudioListener: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1945693977} + m_Enabled: 1 +--- !u!124 &1945693979 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1945693977} + m_Enabled: 1 +--- !u!92 &1945693980 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1945693977} + m_Enabled: 1 +--- !u!20 &1945693981 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1945693977} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0.019607844} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 1 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 + m_StereoMirrorMode: 0 +--- !u!4 &1945693982 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1945693977} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 diff --git a/Assets/_Scenes/sophieMain.unity.meta b/Assets/_Scenes/sophieMain.unity.meta new file mode 100644 index 0000000..119c3d0 --- /dev/null +++ b/Assets/_Scenes/sophieMain.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 82fa8de0062e32d4ca4a526524a750db +timeCreated: 1460168735 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: