diff --git a/Assets/Art/T_Planet_Atmosphere_01.png b/Assets/Art/T_Planet_Atmosphere_01.png new file mode 100644 index 0000000..62d3787 Binary files /dev/null and b/Assets/Art/T_Planet_Atmosphere_01.png differ diff --git a/Assets/Art/T_Planet_Atmosphere_01.png.meta b/Assets/Art/T_Planet_Atmosphere_01.png.meta new file mode 100644 index 0000000..3f0df4e --- /dev/null +++ b/Assets/Art/T_Planet_Atmosphere_01.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 8d3ba69018238ee4f9629282ea7d9fcf +timeCreated: 1460214709 +licenseType: Pro +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Art/T_Space_Background_02.png b/Assets/Art/T_Space_Background_02.png new file mode 100644 index 0000000..35911c8 Binary files /dev/null and b/Assets/Art/T_Space_Background_02.png differ diff --git a/Assets/Art/T_Space_Background_02.png.meta b/Assets/Art/T_Space_Background_02.png.meta new file mode 100644 index 0000000..52ccf1d --- /dev/null +++ b/Assets/Art/T_Space_Background_02.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 7443ae7f877013a42941481b83fee96b +timeCreated: 1460214707 +licenseType: Pro +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Astronaut.prefab b/Assets/Prefabs/Astronaut.prefab index df5704a..3dfd265 100644 --- a/Assets/Prefabs/Astronaut.prefab +++ b/Assets/Prefabs/Astronaut.prefab @@ -145,7 +145,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: ab270b0cb2475114ab8eb45661af0df1, type: 3} m_Name: m_EditorClassIdentifier: - PlayerNumber: 1 + PlayerNumber: 0 --- !u!114 &11491252 MonoBehaviour: m_ObjectHideFlags: 1 @@ -158,8 +158,8 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: aspi: {fileID: 0} - WalkAnimSpeed: 0 - WalkAnimAngle: 0 + WalkAnimSpeed: 4 + WalkAnimAngle: 15 EjectSpinSpeed: 80 DustParticlesEmitter: {fileID: 138982, guid: 6233079c5a9a756458811f283fdca112, type: 2} --- !u!114 &11494368 diff --git a/Assets/Prefabs/Planet.prefab b/Assets/Prefabs/Planet.prefab index ca103ce..af19b05 100644 --- a/Assets/Prefabs/Planet.prefab +++ b/Assets/Prefabs/Planet.prefab @@ -106,6 +106,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: c11fa6fea03561044843359e6d9d23a6, type: 3} m_Name: m_EditorClassIdentifier: + CriticalMin: 0.2 + CriticalMax: 0.9 --- !u!114 &11401780 MonoBehaviour: m_ObjectHideFlags: 1 @@ -139,6 +141,8 @@ MonoBehaviour: CartierMinRatio: 0.75 CartierMaxRatio: 1.25 CartierStepSize: 0.25 + CartierWaitBeforeRaise: 0.6 + balanceValue: 0 WedgePrefab: {fileID: 170328, guid: 0b78da08dfa398840862539a74cc2377, type: 2} --- !u!135 &13593906 SphereCollider: diff --git a/Assets/Scripts/Astronaut.cs b/Assets/Scripts/Astronaut.cs index 82cd84c..7a9b098 100644 --- a/Assets/Scripts/Astronaut.cs +++ b/Assets/Scripts/Astronaut.cs @@ -56,11 +56,10 @@ public class Astronaut : MonoBehaviour { SpriteDash.gameObject.SetActive(false); }*/ - /*if (_state == AstronautState.Walking) + if (State == AstronautState.Walking) { - //StartCoroutine(WalkingStance()); - _astronautAnimator.Walk(); - }*/ + _astronautAnimator.Walk(walkRight); + } } } @@ -68,6 +67,7 @@ public class Astronaut : MonoBehaviour { private float height = 0; private float vSpeed = 0; private bool grounded = false; + private bool walkRight = false; private float walkTime = 0; private int nextStep = 1; @@ -127,6 +127,7 @@ public class Astronaut : MonoBehaviour { private float Repeat(float num, float limit) { + //This is a modulus return Mathf.Repeat(num + limit, limit); } @@ -200,17 +201,28 @@ public class Astronaut : MonoBehaviour { public void Move(float x, float y) { + float playerX, playerY; + PlanetUtilities.Spheric2Cartesian(theta - 108, height, out playerX, out playerY); + + Vector3 pos = new Vector3(playerX, playerY); + + Vector3 dirV = Vector3.Cross(pos, Vector3.forward).normalized; + float proj = Vector3.Dot(new Vector3(x, y, 0), dirV); + + float move = proj; + if (State >= AstronautState.Ejecting ) return; if (State < AstronautState.Jumping) { - if (Mathf.Approximately(x, 0)) + if (Mathf.Approximately(move, 0)) { State = AstronautState.Idle; } else { + walkRight = move > 0; State = AstronautState.Walking; walkTime = 0f; } @@ -218,17 +230,16 @@ public class Astronaut : MonoBehaviour { if (State < AstronautState.Dashing) { - if (-0.2 < x && x < 0.2) return; - //Debug.Log(x + " " + Speed + " " + height); - float movement = PlanetUtilities.GetDisplacementAngle(Speed * -x, height) * Time.deltaTime; - //Debug.Log("Moving! - " + height); - //Debug.Log("Daaa - " + movement); - float newTheta = (360 + theta + movement) % 360; // angle positif + if (-0.2 < move && move < 0.2) return; + + float movement = PlanetUtilities.GetDisplacementAngle(Speed * -move, height) * Time.deltaTime; + + float newTheta = Repeat(theta + movement, 360); float newHeight = GetGroundRadius(newTheta); if (newHeight > height) { - Debug.Log("Blocked by wall"); + //Debug.Log("Blocked by wall"); return; // Blocked by wall } @@ -239,15 +250,10 @@ public class Astronaut : MonoBehaviour { //TODO arreter mouvement lateral State=AstronautState.Idle; } - } public void Jump() { - Debug.Log("Jump!"); - - - if (State == AstronautState.Jumping) { Dash(); @@ -260,9 +266,10 @@ public class Astronaut : MonoBehaviour { else if (State >= AstronautState.Ejecting) return; + if (!grounded) return; + _astronautAnimator.Jump(); // deja dans le property get/set - if (!grounded) return; vSpeed = JumpSpeed; grounded = false; State = AstronautState.Jumping; @@ -308,7 +315,14 @@ public class Astronaut : MonoBehaviour { if (GUI.Button(new Rect(10, 10, 150, 50), State.ToString())) { Debug.Log("Clicked the button with an image"); - Eject(); - } + //_astronautAnimator.Walk(); + //Eject(); + } + /* if (GUI.Button(new Rect(60, 10, 150, 50), "Stop")) + { + Debug.Log("Clicked the button with an image"); + _astronautAnimator.StopWalk(); + //Eject(); + }*/ } } diff --git a/Assets/Scripts/AstronautAnimator.cs b/Assets/Scripts/AstronautAnimator.cs index c2dc410..979d237 100644 --- a/Assets/Scripts/AstronautAnimator.cs +++ b/Assets/Scripts/AstronautAnimator.cs @@ -39,9 +39,10 @@ public class AstronautAnimator : MonoBehaviour { aspi.SpriteDash.gameObject.SetActive(false); } - public void Walk() + public void Walk(bool right) { - StartCoroutine(Rotate()); + Debug.Log("Walking!"); + StartCoroutine(Rotate(right? -1 : 1)); } public void Eject() @@ -58,9 +59,9 @@ public class AstronautAnimator : MonoBehaviour { } } - IEnumerator Rotate() + IEnumerator Rotate(float side) { - for (float i = 0.5f; i < 2.5f; i+= Time.deltaTime*WalkAnimSpeed) + for (float i = 0.5f; i < 1.5f; i+= Time.deltaTime*WalkAnimSpeed) { /*int roundDown = 10; //0.5, 1.5 et 2.5 @@ -70,15 +71,18 @@ public class AstronautAnimator : MonoBehaviour { aspi.SpriteWalk.flipX = !aspi.SpriteWalk.flipX; }*/ float position = Mathf.PingPong(i, 1f); - transform.rotation = Quaternion.Euler(0, 0, (position - 0.5f) * WalkAnimAngle * 2); + transform.localRotation = Quaternion.Euler(0, 0, side * (position - 0.5f) * WalkAnimAngle * 2); yield return null; } if (aspi.State == Astronaut.AstronautState.Walking) { - StartCoroutine(Rotate()); + Debug.Log("Walking again"); + StartCoroutine(Rotate(-side)); } - yield return null; + else + Debug.Log("Walking stop"); + //yield return null; } public void EmitDustParticules() diff --git a/Assets/Scripts/PlanetManager.cs b/Assets/Scripts/PlanetManager.cs index c5ee485..7dfc99f 100644 --- a/Assets/Scripts/PlanetManager.cs +++ b/Assets/Scripts/PlanetManager.cs @@ -14,6 +14,7 @@ public class PlanetManager : MonoBehaviour public float CartierMinRatio = 0.4f; public float CartierMaxRatio = 2.0f; public float CartierStepSize = 0.25f; + public float CartierWaitBeforeRaise = 2f; public float balanceValue; private float disbalance = 0f; public GameObject WedgePrefab = null; @@ -88,7 +89,7 @@ public class PlanetManager : MonoBehaviour { w.offset = 1.0f; } - else if (w.offset > 1.0f) + else if (w.offset > 1.0f && Time.time >= w.timeSinceLastPushedBack + CartierWaitBeforeRaise) { if (!CartierResetRatioSpeedRandomize) { @@ -96,10 +97,10 @@ public class PlanetManager : MonoBehaviour } else { - w.offset -= 0.005f*CartierResetRatioSpeedFactor * UnityEngine.Random.Range(-0.5f, 2f); + w.offset -= 0.005f*CartierResetRatioSpeedFactor * UnityEngine.Random.Range(-0.5f, 1.8f); } } - else if (w.offset < 1.0f) + else if ((w.offset < 1.0f) && Time.time >= w.timeSincePushedToMinimum + CartierWaitBeforeRaise ) { if (!CartierResetRatioSpeedRandomize) { @@ -121,9 +122,18 @@ public class PlanetManager : MonoBehaviour var index = GetWedgeIndex(thetaPlayerX); var w = wedges[index]; + + var difference = CartierStepSize; + + var wOffsetBefore = w.offset; w.offset = w.offset - CartierStepSize; - if (w.offset < CartierMinRatio) + if (w.offset <= CartierMinRatio) + { + difference -= CartierMinRatio - w.offset; //enlever du push pour la plateforme qui va faire pousser dans le sens opposé + w.timeSincePushedToMinimum = Time.time; w.offset = CartierMinRatio; + } + w.sprite.transform.localScale = new Vector3(w.offset, w.offset, 1); @@ -132,27 +142,33 @@ public class PlanetManager : MonoBehaviour var indexOppose = GetWedgeOpposé(index); var v = wedges[indexOppose]; - v.offset = v.offset + CartierStepSize; - if (v.offset >= CartierMaxRatio) - { - v.offset = CartierMaxRatio; + // if (Time.time >= v.timeSincePushedToMinimum + CartierWaitBeforeRaise) // résultats étranges ;) + // if (wOffsetBefore >= 0.9f) + // { + if (v.offset < CartierMaxRatio) v.timeSinceLastPushedBack = Time.time; - - //checker si on éjecte des players - var players = FindObjectsOfType(); - foreach (var p in players) + v.offset = v.offset + difference; //CartierStepSize; //diférentiel au lieu du step size + if (v.offset >= CartierMaxRatio) { - if (v.tMax >= p.GetTheta() && p.GetTheta() >= v.tMin && p.IsGrounded()) + v.offset = CartierMaxRatio; + + + //checker si on éjecte des players + var players = FindObjectsOfType(); + foreach (var p in players) { - p.Eject(); + if (v.tMax >= p.GetTheta() && p.GetTheta() >= v.tMin && p.IsGrounded()) + { + p.Eject(); + } } } - - - } + v.sprite.transform.localScale = new Vector3(v.offset, v.offset, 1); + // } + - v.sprite.transform.localScale = new Vector3(v.offset, v.offset, 1); + // call fill gauge after every hit. var earthQuakeGauge = FindObjectOfType(); @@ -301,7 +317,7 @@ public class PlanetManager : MonoBehaviour /// public Wedge GetWedgeFromTheta(float thetaPlayerX) { - return wedges[GetWedgeIndex((thetaPlayerX) % 360)]; + return wedges[GetWedgeIndex((360 + thetaPlayerX) % 360)]; } /// @@ -312,7 +328,8 @@ public class PlanetManager : MonoBehaviour public float offset = 1.0f; //valeurs entre minRatio et maxRatio; < 1 étant renfoncé, 1 position normale, et > 1 vers l'extérieur public float tMin = 0; //theta min et theta max : angle thetat de début et fin du cartier; public float tMax = 0; - + public float timeSincePushedToMinimum = 0.0f; + public float timeSinceLastPushedBack = 0.0f; public GameObject sprite; //sprite et collider 2D public GameObject gameObject; //wedge prefab avec collider } diff --git a/Assets/_Scenes/Main.unity b/Assets/_Scenes/Main.unity index 5cf0404..4d45db9 100644 --- a/Assets/_Scenes/Main.unity +++ b/Assets/_Scenes/Main.unity @@ -132,10 +132,6 @@ Prefab: propertyPath: m_Name value: Astronaut_0 objectReference: {fileID: 0} - - target: {fileID: 11434752, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} - propertyPath: PlayerNumber - value: 0 - objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} m_IsPrefabParent: 0 @@ -241,6 +237,64 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_RootOrder: 7 +--- !u!1 &227879751 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 227879752} + - 212: {fileID: 227879753} + m_Layer: 0 + m_Name: Atmosphere + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &227879752 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 227879751} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1867085522} + m_RootOrder: 1 +--- !u!212 &227879753 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 227879751} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000e000000000000000, type: 0} + m_SubsetIndices: + m_StaticBatchRoot: {fileID: 0} + m_UseLightProbes: 0 + m_ReflectionProbeUsage: 0 + m_ProbeAnchor: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 --- !u!114 &1027139440 stripped MonoBehaviour: m_PrefabParentObject: {fileID: 11471614, guid: 198e988adacced646a19f757f6237ae1, @@ -453,6 +507,14 @@ Prefab: propertyPath: EjectSpinSpeed value: 10 objectReference: {fileID: 0} + - target: {fileID: 154602, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11434752, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} + propertyPath: PlayerNumber + value: 1 + objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} m_IsPrefabParent: 0 @@ -495,9 +557,17 @@ Prefab: propertyPath: m_RootOrder value: 5 objectReference: {fileID: 0} + - target: {fileID: 140218, guid: 8347d06db0c264442891d12282c4a4dd, type: 2} + propertyPath: m_Name + value: Stars behind + objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: 8347d06db0c264442891d12282c4a4dd, type: 2} m_IsPrefabParent: 0 +--- !u!4 &1867085522 stripped +Transform: + m_PrefabParentObject: {fileID: 483280, guid: 8347d06db0c264442891d12282c4a4dd, type: 2} + m_PrefabInternal: {fileID: 1867085521} --- !u!1 &1945693977 GameObject: m_ObjectHideFlags: 0