diff --git a/Assets/Art/T_Char_Stunned_03.png b/Assets/Art/T_Char_Stunned_03.png new file mode 100644 index 0000000..7eb5682 Binary files /dev/null and b/Assets/Art/T_Char_Stunned_03.png differ diff --git a/Assets/Art/T_Char_Stunned_03.png.meta b/Assets/Art/T_Char_Stunned_03.png.meta new file mode 100644 index 0000000..d5672ec --- /dev/null +++ b/Assets/Art/T_Char_Stunned_03.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: f232242ccad7e3842bad3905b644b140 +timeCreated: 1460228310 +licenseType: Free +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 13038c3..676a3e2 100644 --- a/Assets/Prefabs/Astronaut.prefab +++ b/Assets/Prefabs/Astronaut.prefab @@ -46,7 +46,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!1 &170392 GameObject: m_ObjectHideFlags: 0 @@ -69,6 +69,22 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 +--- !u!1 &183028 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 497504} + - 212: {fileID: 21293154} + m_Layer: 0 + m_Name: Sprite_Stun + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 --- !u!4 &403646 Transform: m_ObjectHideFlags: 1 @@ -81,6 +97,7 @@ Transform: m_Children: - {fileID: 418246} - {fileID: 406446} + - {fileID: 497504} m_Father: {fileID: 494126} m_RootOrder: 0 --- !u!4 &406446 @@ -120,6 +137,18 @@ Transform: - {fileID: 403646} m_Father: {fileID: 0} m_RootOrder: 0 +--- !u!4 &497504 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 183028} + 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: 403646} + m_RootOrder: 2 --- !u!54 &5462614 Rigidbody: m_ObjectHideFlags: 1 @@ -251,6 +280,7 @@ MonoBehaviour: Rotator: {fileID: 154602} SpriteWalk: {fileID: 21220066} SpriteDash: {fileID: 157058} + SpriteStun: {fileID: 183028} Width: 0.4 DashTime: 0.4 StepTime: 5 @@ -345,6 +375,36 @@ SpriteRenderer: m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 m_FlipY: 0 +--- !u!212 &21293154 +SpriteRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 183028} + 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: 15 + m_Sprite: {fileID: 21300000, guid: f232242ccad7e3842bad3905b644b140, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 --- !u!1001 &100100000 Prefab: m_ObjectHideFlags: 1 diff --git a/Assets/Scripts/Astronaut.cs b/Assets/Scripts/Astronaut.cs index ceab2ba..63f3f73 100644 --- a/Assets/Scripts/Astronaut.cs +++ b/Assets/Scripts/Astronaut.cs @@ -12,7 +12,8 @@ public class Astronaut : MonoBehaviour { public GameObject Rotator; public SpriteRenderer SpriteWalk; - public GameObject SpriteDash; + public GameObject SpriteDash; + public GameObject SpriteStun; public float Width; public float DashTime = 0.4f; //Temps de l'animation et rate limiting @@ -42,10 +43,9 @@ public class Astronaut : MonoBehaviour { if (oldState == AstronautState.Dashing) { - _astronautAnimator.Land(); + _astronautAnimator.Idle(); } - - if (State == AstronautState.Walking) + else if (State == AstronautState.Walking) { _astronautAnimator.Walk(walkRight); } @@ -155,6 +155,9 @@ public class Astronaut : MonoBehaviour { public void Move(float x, float y) { + if (State >= AstronautState.Dashing ) + return; + float playerX, playerY; PlanetUtilities.Spheric2Cartesian(theta - 108, height, out playerX, out playerY); @@ -165,9 +168,6 @@ public class Astronaut : MonoBehaviour { float move = proj; - if (State >= AstronautState.Dashing ) - return; - if (State < AstronautState.Jumping) { if (Mathf.Approximately(move, 0)) @@ -182,28 +182,20 @@ public class Astronaut : MonoBehaviour { } } - if (State < AstronautState.Dashing) + 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) { - 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"); - return; // Blocked by wall - } - - theta = newTheta; + //Debug.Log("Blocked by wall"); + return; // Blocked by wall } - if (State == AstronautState.Dashing && grounded) - { - //TODO arreter mouvement lateral - State=AstronautState.Idle; - } + + theta = newTheta; } public void Jump() @@ -258,13 +250,26 @@ public class Astronaut : MonoBehaviour { /// public void Stun() { - //TODO + State = AstronautState.Stun; + StartCoroutine(StunTimeout()); + _astronautAnimator.Stun(); + } + + IEnumerator StunTimeout() + { + for (float i = 0f; i <0.6f; i += Time.deltaTime) + { + yield return null; + } + State = AstronautState.Idle; + _astronautAnimator.Idle(); } public void OnGUI() { if (GUI.Button(new Rect(10, 10, 150, 50), State.ToString())) { + Stun(); Debug.Log("Clicked the button with an image"); //_astronautAnimator.Walk(); //Eject(); diff --git a/Assets/Scripts/AstronautAnimator.cs b/Assets/Scripts/AstronautAnimator.cs index 18a07b2..e52863f 100644 --- a/Assets/Scripts/AstronautAnimator.cs +++ b/Assets/Scripts/AstronautAnimator.cs @@ -24,19 +24,21 @@ public class AstronautAnimator : MonoBehaviour { { aspi.SpriteWalk.gameObject.SetActive(true); aspi.SpriteDash.gameObject.SetActive(false); + aspi.SpriteStun.gameObject.SetActive(false); } public void Dash() { aspi.SpriteWalk.gameObject.SetActive(false); aspi.SpriteDash.gameObject.SetActive(true); + aspi.SpriteStun.gameObject.SetActive(false); } - public void Land() + public void Idle() { - aspi.SpriteWalk.gameObject.SetActive(true); aspi.SpriteDash.gameObject.SetActive(false); + aspi.SpriteStun.gameObject.SetActive(false); } public void Walk(bool right) @@ -50,6 +52,14 @@ public class AstronautAnimator : MonoBehaviour { var audio = aspi.GetComponent(); //eject sound audio.bypassListenerEffects = true; AudioSource.PlayClipAtPoint(audio.clip, transform.position, audio.volume); + Stun(); + } + + public void Stun() + { + aspi.SpriteWalk.gameObject.SetActive(false); + aspi.SpriteDash.gameObject.SetActive(false); + aspi.SpriteStun.gameObject.SetActive(true); } IEnumerator Spin() diff --git a/Assets/_Scenes/Main.unity b/Assets/_Scenes/Main.unity index 837a65a..12826c3 100644 --- a/Assets/_Scenes/Main.unity +++ b/Assets/_Scenes/Main.unity @@ -136,6 +136,14 @@ Prefab: propertyPath: m_Enabled value: 1 objectReference: {fileID: 0} + - target: {fileID: 21293154, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} + propertyPath: m_SortingOrder + value: 15 + objectReference: {fileID: 0} + - target: {fileID: 154602, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} m_IsPrefabParent: 0 @@ -197,6 +205,48 @@ SpriteRenderer: m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 m_FlipY: 0 +--- !u!1001 &315578644 +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: 8 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 100100000, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} + m_IsPrefabParent: 0 --- !u!1001 &894002996 Prefab: m_ObjectHideFlags: 0 @@ -412,80 +462,6 @@ Prefab: 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: 11491252, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} - propertyPath: WalkAnimSpeed - value: 3 - objectReference: {fileID: 0} - - target: {fileID: 11491252, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} - propertyPath: WalkAnimAngle - value: 20 - objectReference: {fileID: 0} - - target: {fileID: 11491252, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} - propertyPath: EjectSpinSpeed - value: 10 - objectReference: {fileID: 0} - - target: {fileID: 154602, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} - propertyPath: m_IsActive - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 11434752, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} - propertyPath: PlayerNumber - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 21257324, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} - propertyPath: m_Enabled - value: 1 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_ParentPrefab: {fileID: 100100000, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} - m_IsPrefabParent: 0 --- !u!1001 &1867085521 Prefab: m_ObjectHideFlags: 0