From 5a8e42e43977b4212cd9746db44463b46b4b77c2 Mon Sep 17 00:00:00 2001 From: jreason Date: Sun, 30 Jan 2022 23:03:11 +1100 Subject: [PATCH] Some work on Walljump + minor level changes --- Assets/Art Assets/Textures/UI.meta | 8 + Assets/Art Assets/Textures/UI/Arrow Keys.png | 3 + .../Textures/UI/Arrow Keys.png.meta | 156 ++++++++++++ Assets/Art Assets/Textures/UI/WASD Empty.png | 3 + .../Textures/UI/WASD Empty.png.meta | 156 ++++++++++++ .../Tiles/Environment/Death/Spikes.asset | 2 +- Assets/Prefabs/Level Manager.prefab | 97 +++++++ Assets/Prefabs/Player.prefab | 8 +- Assets/Scenes/Credits.unity | 4 +- Assets/Scenes/How To Play.unity | 3 + Assets/Scenes/How To Play.unity.meta | 7 + Assets/Scenes/Main Menu.unity | 4 +- Assets/Scenes/Official Levels/Level 2.unity | 4 +- Assets/Scenes/Official Levels/Level 3.unity | 4 +- Assets/Scenes/Official Levels/Level 4.unity | 4 +- .../Character/CharacterController2D.cs | 93 +++++-- .../Character/CharacterInputController.cs | 237 +++++++++--------- Assets/Scripts/MonsterController.cs | 6 +- Assets/Scripts/UI/HowToPlayController.cs | 77 ++++++ Assets/Scripts/UI/HowToPlayController.cs.meta | 11 + Assets/Settings/PlayerInput.cs | 22 ++ Assets/Settings/PlayerInput.inputactions | 22 ++ ProjectSettings/EditorBuildSettings.asset | 4 +- ProjectSettings/ProjectSettings.asset | 4 +- 24 files changed, 779 insertions(+), 160 deletions(-) create mode 100644 Assets/Art Assets/Textures/UI.meta create mode 100644 Assets/Art Assets/Textures/UI/Arrow Keys.png create mode 100644 Assets/Art Assets/Textures/UI/Arrow Keys.png.meta create mode 100644 Assets/Art Assets/Textures/UI/WASD Empty.png create mode 100644 Assets/Art Assets/Textures/UI/WASD Empty.png.meta create mode 100644 Assets/Scenes/How To Play.unity create mode 100644 Assets/Scenes/How To Play.unity.meta create mode 100644 Assets/Scripts/UI/HowToPlayController.cs create mode 100644 Assets/Scripts/UI/HowToPlayController.cs.meta diff --git a/Assets/Art Assets/Textures/UI.meta b/Assets/Art Assets/Textures/UI.meta new file mode 100644 index 0000000..db5b43f --- /dev/null +++ b/Assets/Art Assets/Textures/UI.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4fcfd2d70cff21d4ba923565a0fc6c61 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Art Assets/Textures/UI/Arrow Keys.png b/Assets/Art Assets/Textures/UI/Arrow Keys.png new file mode 100644 index 0000000..c0b13ef --- /dev/null +++ b/Assets/Art Assets/Textures/UI/Arrow Keys.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d782e6cde3191063a0ccfbc20967e39fa125da95ad2166f7b8f1ae1cc5c41afb +size 1758 diff --git a/Assets/Art Assets/Textures/UI/Arrow Keys.png.meta b/Assets/Art Assets/Textures/UI/Arrow Keys.png.meta new file mode 100644 index 0000000..5fbfa7a --- /dev/null +++ b/Assets/Art Assets/Textures/UI/Arrow Keys.png.meta @@ -0,0 +1,156 @@ +fileFormatVersion: 2 +guid: 8a23e75d544e7154ca3b6e33c7feaff3 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 1 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 0 + aniso: 2 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 0 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 8192 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 8192 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: iPhone + maxTextureSize: 8192 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Android + maxTextureSize: 8192 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Windows Store Apps + maxTextureSize: 8192 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: WebGL + maxTextureSize: 8192 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Art Assets/Textures/UI/WASD Empty.png b/Assets/Art Assets/Textures/UI/WASD Empty.png new file mode 100644 index 0000000..e2ce5f2 --- /dev/null +++ b/Assets/Art Assets/Textures/UI/WASD Empty.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fac165a4ff43bffb33b8e2bcdbd2af8920952d1c895162d030cae31afcb3ccdd +size 1726 diff --git a/Assets/Art Assets/Textures/UI/WASD Empty.png.meta b/Assets/Art Assets/Textures/UI/WASD Empty.png.meta new file mode 100644 index 0000000..1c2aad8 --- /dev/null +++ b/Assets/Art Assets/Textures/UI/WASD Empty.png.meta @@ -0,0 +1,156 @@ +fileFormatVersion: 2 +guid: 3b602cd9815cf5342b732566bbeefbb8 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 1 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 0 + aniso: 2 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 0 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 1, y: 1, z: 1, w: 1} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 8192 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 8192 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: iPhone + maxTextureSize: 8192 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Android + maxTextureSize: 8192 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Windows Store Apps + maxTextureSize: 8192 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: WebGL + maxTextureSize: 8192 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Art Assets/Tiles/Environment/Death/Spikes.asset b/Assets/Art Assets/Tiles/Environment/Death/Spikes.asset index 5eaabef..eba3daf 100644 --- a/Assets/Art Assets/Tiles/Environment/Death/Spikes.asset +++ b/Assets/Art Assets/Tiles/Environment/Death/Spikes.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7115e8cfd7fc0cb5474dba5a48e8ac07a96c34eefd9aa2fd259bc0db4b26232f +oid sha256:3ade587dbca3eb644b8a1abcf2042f99b808df0e0a8b7c11b54b735640f2299f size 1029 diff --git a/Assets/Prefabs/Level Manager.prefab b/Assets/Prefabs/Level Manager.prefab index 1f2ad80..b85d1f0 100644 --- a/Assets/Prefabs/Level Manager.prefab +++ b/Assets/Prefabs/Level Manager.prefab @@ -854,6 +854,7 @@ GameObject: - component: {fileID: 5467881121666507904} - component: {fileID: 5467881121666507907} - component: {fileID: 5467881121666507905} + - component: {fileID: 6023099206999651644} m_Layer: 0 m_Name: Level Manager m_TagString: Untagged @@ -980,3 +981,99 @@ MonoBehaviour: m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 +--- !u!82 &6023099206999651644 +AudioSource: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5467881121666507906} + m_Enabled: 1 + serializedVersion: 4 + OutputAudioMixerGroup: {fileID: 0} + m_audioClip: {fileID: 8300000, guid: 26b05661b72f11741a80e5126f2256f2, type: 3} + m_PlayOnAwake: 1 + m_Volume: 1 + m_Pitch: 1 + Loop: 1 + Mute: 0 + Spatialize: 0 + SpatializePostEffects: 0 + Priority: 128 + DopplerLevel: 1 + MinDistance: 1 + MaxDistance: 500 + Pan2D: 0 + rolloffMode: 0 + BypassEffects: 0 + BypassListenerEffects: 0 + BypassReverbZones: 0 + rolloffCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + panLevelCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + spreadCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + reverbZoneMixCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab index 2d7898c..43913b1 100644 --- a/Assets/Prefabs/Player.prefab +++ b/Assets/Prefabs/Player.prefab @@ -204,8 +204,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 32250bba13a1233448b3ff49db05c141, type: 3} m_Name: m_EditorClassIdentifier: - m_JumpForce: 100 - m_WallJumpMultiplier: 3 + m_JumpForce: 450 + m_WallJumpMultiplier: 10 m_CrouchSpeed: 0.36 m_MovementSmoothing: 0.05 m_AirControl: 1 @@ -216,6 +216,7 @@ MonoBehaviour: m_CeilingCheck: {fileID: 4668322656710469013} m_WallCheck: {fileID: 4668322655870949457} m_CrouchDisableCollider: {fileID: 0} + m_wallFriction: 0.2 OnJumpEvent: m_PersistentCalls: m_Calls: @@ -279,6 +280,9 @@ MonoBehaviour: m_useLocal: 0 m_localValue: 0 m_animator: {fileID: 4668322655423991002} + m_DeathSound: {fileID: 0} + m_VictoryClip: {fileID: 0} + m_JumpSound: {fileID: 0} m_speed: 2 --- !u!95 &4668322654876184631 Animator: diff --git a/Assets/Scenes/Credits.unity b/Assets/Scenes/Credits.unity index 65f8531..80aee3b 100644 --- a/Assets/Scenes/Credits.unity +++ b/Assets/Scenes/Credits.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7008220909b128ea9a9963ab908662439876b19f3b51846983ae07232b1b72fd -size 39418 +oid sha256:20118121c37016e96746b08a5e6986314ef9ccc84725cc1ac04471d0faef8d53 +size 39413 diff --git a/Assets/Scenes/How To Play.unity b/Assets/Scenes/How To Play.unity new file mode 100644 index 0000000..c409661 --- /dev/null +++ b/Assets/Scenes/How To Play.unity @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c88aeec20995c3b9e9cba1dc2359b04c481eda29c1136df574d9532bfe4ba494 +size 72660 diff --git a/Assets/Scenes/How To Play.unity.meta b/Assets/Scenes/How To Play.unity.meta new file mode 100644 index 0000000..adff247 --- /dev/null +++ b/Assets/Scenes/How To Play.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 8d22d24360cdbac4e9cfef8f8dbec2a9 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/Main Menu.unity b/Assets/Scenes/Main Menu.unity index e9879a3..4bc9f56 100644 --- a/Assets/Scenes/Main Menu.unity +++ b/Assets/Scenes/Main Menu.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f9af27c12eb83dfa6337f6b7e6475d66f4f90e87426edeff3e03fc307d816973 -size 46214 +oid sha256:b3eea219d0578071dc6b2f6bfccb1ceaf1a3fb9556b8a304bb9b6a3488649e9f +size 46191 diff --git a/Assets/Scenes/Official Levels/Level 2.unity b/Assets/Scenes/Official Levels/Level 2.unity index 06d179a..f30611b 100644 --- a/Assets/Scenes/Official Levels/Level 2.unity +++ b/Assets/Scenes/Official Levels/Level 2.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9d4e281f80b5587e52572c2d437b81e5b2e2b1300cba4196e27915fd84f343e5 -size 1968215 +oid sha256:288396a330c255081e114785ac3238f536acc81663e2c70e3b4bfc5515ced864 +size 1966230 diff --git a/Assets/Scenes/Official Levels/Level 3.unity b/Assets/Scenes/Official Levels/Level 3.unity index 8123982..4b8bf47 100644 --- a/Assets/Scenes/Official Levels/Level 3.unity +++ b/Assets/Scenes/Official Levels/Level 3.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c3fc78d912c027e9234353562c9e669c83c014dbd9a0900209da9bec7c106eb5 -size 596483 +oid sha256:358e7c41e75772721ee2fc6c4b764c2ce2a411f24d7b192c2f17fd726efd79e1 +size 594145 diff --git a/Assets/Scenes/Official Levels/Level 4.unity b/Assets/Scenes/Official Levels/Level 4.unity index b4fa96a..1d07b4b 100644 --- a/Assets/Scenes/Official Levels/Level 4.unity +++ b/Assets/Scenes/Official Levels/Level 4.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8ac6db0bee2ec7e3d906ba88a597d4ab4b8b361043289d6bb7bfce1136f26761 -size 390083 +oid sha256:870a911ca33beff5195c749b6d21dbbdab43fb393acc55d910336067f492c912 +size 388608 diff --git a/Assets/Scripts/Character/CharacterController2D.cs b/Assets/Scripts/Character/CharacterController2D.cs index 785acf2..112dee5 100644 --- a/Assets/Scripts/Character/CharacterController2D.cs +++ b/Assets/Scripts/Character/CharacterController2D.cs @@ -13,7 +13,7 @@ public class CharacterController2D : MonoBehaviour [SerializeField] private Transform m_CeilingCheck; // A position marking where to check for ceilings [SerializeField] private Transform m_WallCheck; [SerializeField] private Collider2D m_CrouchDisableCollider; // A collider that will be disabled when crouching - + [SerializeField] private float m_wallFriction = 0.1f; const float k_GroundedRadius = .2f; // Radius of the overlap circle to determine if grounded private bool m_Grounded; // Whether or not the player is grounded. @@ -22,8 +22,9 @@ public class CharacterController2D : MonoBehaviour private Rigidbody2D m_Rigidbody2D; private bool m_FacingRight = true; // For determining which way the player is currently facing. private Vector3 m_Velocity = Vector3.zero; - private enum Direction { NA=0, L, R }; + private enum Direction { NA=0, L=-1, R=1 }; private Direction m_LastWallJumpDirection = Direction.NA; + private int m_forward => (int) Mathf.Sign(transform.localScale.x); [Header("Events")] [Space] @@ -36,6 +37,11 @@ public class CharacterController2D : MonoBehaviour public BoolEvent OnCrouchEvent; private bool m_wasCrouching = false; + private bool m_isJumpDown; + private bool m_lastJump; + private float m_lastWallJumpTime = 0; + private float m_lastMove; + private bool m_invertX; private void Awake() { @@ -95,6 +101,14 @@ public class CharacterController2D : MonoBehaviour } } + m_isJumpDown = !m_lastJump && jump; + m_lastJump = jump; + + bool hasMoveChanged = System.Math.Sign(m_lastMove) != System.Math.Sign(move); + m_lastMove = move; + Debug.Log($"move Changed {hasMoveChanged}"); + + //only control the player if grounded or airControl is turned on if (m_Grounded || m_AirControl) { @@ -130,6 +144,15 @@ public class CharacterController2D : MonoBehaviour // Move the character by finding the target velocity Vector3 targetVelocity = new Vector2(move * 10f, m_Rigidbody2D.velocity.y); + + if (m_invertX) + { + Debug.Log("Inverting Direction"); + targetVelocity *= new Vector2(-1, 1); + } + if (hasMoveChanged || m_Grounded) + m_invertX = false; + // And then smoothing it out and applying it to the character m_Rigidbody2D.velocity = Vector3.SmoothDamp(m_Rigidbody2D.velocity, targetVelocity, ref m_Velocity, m_MovementSmoothing); @@ -147,35 +170,54 @@ public class CharacterController2D : MonoBehaviour } } // If the player should jump... - if (m_Grounded && jump) + if (m_Grounded && m_isJumpDown) { // Add a vertical force to the player. m_Grounded = false; m_Rigidbody2D.AddForce(new Vector2(0f, m_JumpForce)); OnJumpEvent.Invoke(); - - - // Reset wall jump switch - m_LastWallJumpDirection = move > 0 ? Direction.R : Direction.L; + m_LastWallJumpDirection = Direction.NA; + Debug.Log("Regular Jump"); } - else if (m_TouchingWall && jump) + //else if (m_TouchingWall && jump) + //{ + // if (m_FacingRight && m_LastWallJumpDirection == Direction.L) + // { + // m_Rigidbody2D.AddForce(new Vector2(m_JumpForce * m_WallJumpMultiplier * (m_FacingRight ? 1f : -1f), m_JumpForce * m_WallJumpMultiplier)); + // OnJumpEvent.Invoke(); + // + // m_LastWallJumpDirection = Direction.R; + // } + // else if (!m_FacingRight && m_LastWallJumpDirection == Direction.R) + // { + // m_Rigidbody2D.AddForce(new Vector2(m_JumpForce * m_WallJumpMultiplier * (m_FacingRight ? 1f : -1f), m_JumpForce * m_WallJumpMultiplier)); + // OnJumpEvent.Invoke(); + // + // m_LastWallJumpDirection = Direction.L; + // } + // + //} + + else if(m_TouchingWall && m_isJumpDown && (int) m_LastWallJumpDirection != m_forward) { - if (m_FacingRight && m_LastWallJumpDirection == Direction.L) - { - m_Rigidbody2D.AddForce(new Vector2(m_JumpForce * m_WallJumpMultiplier * (m_FacingRight ? 1f : -1f), m_JumpForce * m_WallJumpMultiplier)); - OnJumpEvent.Invoke(); - - m_LastWallJumpDirection = Direction.R; - } - else if (!m_FacingRight && m_LastWallJumpDirection == Direction.R) - { - m_Rigidbody2D.AddForce(new Vector2(m_JumpForce * m_WallJumpMultiplier * (m_FacingRight ? 1f : -1f), m_JumpForce * m_WallJumpMultiplier)); - OnJumpEvent.Invoke(); + m_Rigidbody2D.AddForce(new Vector2(m_WallJumpMultiplier * -m_forward, m_WallJumpMultiplier),ForceMode2D.Impulse); + OnJumpEvent.Invoke(); + m_LastWallJumpDirection = (m_forward == -1) ? Direction.L : Direction.R; + Debug.Log("Wall Jump"); + m_lastWallJumpTime = Time.time; + m_invertX = true; + } - m_LastWallJumpDirection = Direction.L; - } + + if (m_TouchingWall && move != 0 && !m_Grounded && m_Rigidbody2D.velocity.y < 0) + { + Vector2 velocity = m_Rigidbody2D.velocity; + velocity.y = Mathf.Lerp(velocity.y, 0, m_wallFriction); + m_Rigidbody2D.velocity = velocity; + } + } @@ -189,4 +231,13 @@ public class CharacterController2D : MonoBehaviour theScale.x *= -1; transform.localScale = theScale; } + + private void OnDrawGizmosSelected() + { + Gizmos.color = m_TouchingWall ? Color.yellow : Color.green; + Gizmos.DrawWireSphere(m_WallCheck.position, 0.2f); + + Gizmos.color = m_Grounded ? Color.yellow : Color.green; + Gizmos.DrawWireSphere(m_GroundCheck.position, k_GroundedRadius); + } } \ No newline at end of file diff --git a/Assets/Scripts/Character/CharacterInputController.cs b/Assets/Scripts/Character/CharacterInputController.cs index 1d465df..613e4ca 100644 --- a/Assets/Scripts/Character/CharacterInputController.cs +++ b/Assets/Scripts/Character/CharacterInputController.cs @@ -1,124 +1,123 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using UnityEngine.InputSystem; -using Variables; -using NaughtyAttributes; - -public class CharacterInputController : MonoBehaviour -{ - - [SerializeField, Header("References")] - private CharacterController2D m_characterController; - - [SerializeField] - private Reference m_playerInput; - - [SerializeField] - private Reference m_noInputAllowed; - - [SerializeField] - private Reference m_isPlayerDead; - - [SerializeField] - private Reference m_isVictory; - - [SerializeField] - private Animator m_animator; - - [SerializeField] - private AudioClip m_DeathSound; - - [SerializeField] - private AudioClip m_VictoryClip; - - [SerializeField] - private AudioClip m_JumpSound; - - [SerializeField, BoxGroup("Settings")] - private float m_speed = 2.0f; - - [ShowNonSerializedField] - private Vector2 m_movement; - - [ShowNonSerializedField] - private bool m_jump; - - - - private void OnEnable() - { - m_isPlayerDead.OnValueChanged += OnDeath; - m_isVictory.OnValueChanged += OnVictory; - } - - private void OnDisable() - { - m_isPlayerDead.OnValueChanged -= OnDeath; - m_isVictory.OnValueChanged -= OnVictory; - } - - public void OnMove(InputAction.CallbackContext context) - { - m_movement = context.ReadValue(); - } - - public void OnJump(InputAction.CallbackContext context) - { - m_jump = context.ReadValueAsButton(); - } - - private void Update() - { - - if (!m_noInputAllowed) - { - m_characterController.Move(m_movement.x * m_speed, false, m_jump); - m_playerInput.Value = m_movement.magnitude != 0 || m_jump; - - } - else - { - m_characterController.Move(0, false, false); - m_playerInput.Value = false; - } - m_animator.SetBool("isMoving", m_playerInput); - } - - - public void OnLandHappened() - { +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.InputSystem; +using Variables; +using NaughtyAttributes; + +public class CharacterInputController : MonoBehaviour +{ + + [SerializeField, Header("References")] + private CharacterController2D m_characterController; + + [SerializeField] + private Reference m_playerInput; + + [SerializeField] + private Reference m_noInputAllowed; + + [SerializeField] + private Reference m_isPlayerDead; + + [SerializeField] + private Reference m_isVictory; + + [SerializeField] + private Animator m_animator; + + [SerializeField] + private AudioClip m_DeathSound; + + [SerializeField] + private AudioClip m_VictoryClip; + + [SerializeField] + private AudioClip m_JumpSound; + + [SerializeField, BoxGroup("Settings")] + private float m_speed = 2.0f; + + [ShowNonSerializedField] + private Vector2 m_movement; + + [ShowNonSerializedField] + private bool m_jump; + + + private void OnEnable() + { + m_isPlayerDead.OnValueChanged += OnDeath; + m_isVictory.OnValueChanged += OnVictory; + } + + private void OnDisable() + { + m_isPlayerDead.OnValueChanged -= OnDeath; + m_isVictory.OnValueChanged -= OnVictory; + } + + public void OnMove(InputAction.CallbackContext context) + { + m_movement = context.ReadValue(); + } + + public void OnJump(InputAction.CallbackContext context) + { + m_jump = context.ReadValueAsButton(); + } + + private void Update() + { + + if (!m_noInputAllowed) + { + m_characterController.Move(m_movement.x * m_speed, false, m_jump); + m_playerInput.Value = m_movement.magnitude != 0 || m_jump; + + } + else + { + m_characterController.Move(0, false, false); + m_playerInput.Value = false; + } + m_animator.SetBool("isMoving", m_playerInput); + } + + + public void OnLandHappened() + { + m_animator.SetTrigger("Land"); + } + + public void OnJumpHappened() + { m_animator.SetTrigger("Land"); - } - - public void OnJumpHappened() - { - m_animator.SetTrigger("Land"); - //AudioSource.PlayClipAtPoint(m_JumpSound, transform.position); - } - public void OnDeath(bool value) - { + //AudioSource.PlayClipAtPoint(m_JumpSound, transform.position); + } + public void OnDeath(bool value) + { if (value) { - m_animator.SetTrigger("Death"); - AudioSource.PlayClipAtPoint(m_DeathSound, transform.position); - } - else - m_animator.SetTrigger("Respawn"); - } - - public void OnVictory(bool value) - { + m_animator.SetTrigger("Death"); + AudioSource.PlayClipAtPoint(m_DeathSound, transform.position); + } + else + m_animator.SetTrigger("Respawn"); + } + + public void OnVictory(bool value) + { if (value) { - m_animator.SetTrigger("Victory"); - AudioSource.PlayClipAtPoint(m_VictoryClip, transform.position); - } - } - - - - - - -} + m_animator.SetTrigger("Victory"); + AudioSource.PlayClipAtPoint(m_VictoryClip, transform.position); + } + } + + + + + + +} diff --git a/Assets/Scripts/MonsterController.cs b/Assets/Scripts/MonsterController.cs index f321ccb..afca7ce 100644 --- a/Assets/Scripts/MonsterController.cs +++ b/Assets/Scripts/MonsterController.cs @@ -70,14 +70,14 @@ public class MonsterController : MonoBehaviour, IResettable private void OnLightChange(float value) { float distanceToPlayer = Vector3.Distance(m_player.position, transform.position + m_offset); - - if (value <= 0.1 && distanceToPlayer < m_distance && !m_hasChanged) + + if (value <= 0.01 && distanceToPlayer < m_distance && !m_hasChanged) { Debug.Log(distanceToPlayer); ChangeRandomMonster(); m_hasChanged = true; } - else if (value <= 0) + else if (value <= 0 && !m_hasChanged) { ResetMonster(); } diff --git a/Assets/Scripts/UI/HowToPlayController.cs b/Assets/Scripts/UI/HowToPlayController.cs new file mode 100644 index 0000000..47e4575 --- /dev/null +++ b/Assets/Scripts/UI/HowToPlayController.cs @@ -0,0 +1,77 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.SceneManagement; +using UnityEngine.UI; +using TMPro; + +public class HowToPlayController : MonoBehaviour +{ + [SerializeField] + private MaskableGraphic[] graphics; + + [SerializeField] + private float fadeTime = 1.0f; + [SerializeField] + private float showTime = 3; + + [SerializeField] + private string NextLevel = "Level 1"; + + IEnumerator Start() + { + + + float elapsedTime = 0; + Color color; + while (elapsedTime < fadeTime) + { + foreach(MaskableGraphic g in graphics) + { + color = g.color; + color.a = elapsedTime / fadeTime; + g.color = color; + + yield return new WaitForEndOfFrame(); + elapsedTime += Time.deltaTime; + } + } + + foreach (MaskableGraphic g in graphics) + { + color = g.color; + color.a = 1; + g.color = color; + } + + yield return new WaitForSeconds(showTime); + + elapsedTime = 0; + while (elapsedTime < fadeTime) + { + foreach (MaskableGraphic g in graphics) + { + color = g.color; + color.a = 1 - elapsedTime / fadeTime; + g.color = color; + + yield return new WaitForEndOfFrame(); + elapsedTime += Time.deltaTime; + } + } + + foreach (MaskableGraphic g in graphics) + { + color = g.color; + color.a = 0; + g.color = color; + } + + SceneManager.LoadScene(NextLevel); + } + + + + + +} diff --git a/Assets/Scripts/UI/HowToPlayController.cs.meta b/Assets/Scripts/UI/HowToPlayController.cs.meta new file mode 100644 index 0000000..7c7d669 --- /dev/null +++ b/Assets/Scripts/UI/HowToPlayController.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3a01dc30c0a986a4cba3649c4aedf9db +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Settings/PlayerInput.cs b/Assets/Settings/PlayerInput.cs index add47ff..f1c515c 100644 --- a/Assets/Settings/PlayerInput.cs +++ b/Assets/Settings/PlayerInput.cs @@ -146,6 +146,17 @@ public class @PlayerInput : IInputActionCollection, IDisposable ""isComposite"": false, ""isPartOfComposite"": true }, + { + ""name"": """", + ""id"": ""f07ab40a-4b61-4c20-9090-d8d96d5ea496"", + ""path"": ""/leftStick"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Move"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, { ""name"": """", ""id"": ""67ec88e9-6ebb-4f16-9f4a-49d4f75af68e"", @@ -178,6 +189,17 @@ public class @PlayerInput : IInputActionCollection, IDisposable ""action"": ""Jump"", ""isComposite"": false, ""isPartOfComposite"": false + }, + { + ""name"": """", + ""id"": ""6065b818-f9a2-4a58-952b-4054f7f6981a"", + ""path"": ""/buttonSouth"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Jump"", + ""isComposite"": false, + ""isPartOfComposite"": false } ] } diff --git a/Assets/Settings/PlayerInput.inputactions b/Assets/Settings/PlayerInput.inputactions index af02cd3..1a2df87 100644 --- a/Assets/Settings/PlayerInput.inputactions +++ b/Assets/Settings/PlayerInput.inputactions @@ -133,6 +133,17 @@ "isComposite": false, "isPartOfComposite": true }, + { + "name": "", + "id": "f07ab40a-4b61-4c20-9090-d8d96d5ea496", + "path": "/leftStick", + "interactions": "", + "processors": "", + "groups": "", + "action": "Move", + "isComposite": false, + "isPartOfComposite": false + }, { "name": "", "id": "67ec88e9-6ebb-4f16-9f4a-49d4f75af68e", @@ -165,6 +176,17 @@ "action": "Jump", "isComposite": false, "isPartOfComposite": false + }, + { + "name": "", + "id": "6065b818-f9a2-4a58-952b-4054f7f6981a", + "path": "/buttonSouth", + "interactions": "", + "processors": "", + "groups": "", + "action": "Jump", + "isComposite": false, + "isPartOfComposite": false } ] } diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset index daecdc2..f276026 100644 --- a/ProjectSettings/EditorBuildSettings.asset +++ b/ProjectSettings/EditorBuildSettings.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:97cc5d845f79c14fbb168a7f0148f66b8af26072d1522da75df2832f3a8d73e4 -size 756 +oid sha256:090ec9657ec345a95028a2f4a673bafad74d3d9b90a3c6dcebbc61deda8470f7 +size 968 diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 51cbc52..ebf91b1 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:52b58f7debca31cd8ebf12fce41daec447a9e6ee257c6433459e4eb36cdaaaaf -size 19988 +oid sha256:350e5f6a5e60dfc90568c070378b2ecda79c8697172a6d0d7bab53c90b071efe +size 20001