Browse Source

Some work on Walljump + minor level changes

main
Joshua Reason 2 years ago
parent
commit
5a8e42e439
24 changed files with 779 additions and 160 deletions
  1. +8
    -0
      Assets/Art Assets/Textures/UI.meta
  2. BIN
      Assets/Art Assets/Textures/UI/Arrow Keys.png
  3. +156
    -0
      Assets/Art Assets/Textures/UI/Arrow Keys.png.meta
  4. BIN
      Assets/Art Assets/Textures/UI/WASD Empty.png
  5. +156
    -0
      Assets/Art Assets/Textures/UI/WASD Empty.png.meta
  6. BIN
      Assets/Art Assets/Tiles/Environment/Death/Spikes.asset
  7. +97
    -0
      Assets/Prefabs/Level Manager.prefab
  8. +6
    -2
      Assets/Prefabs/Player.prefab
  9. BIN
      Assets/Scenes/Credits.unity
  10. BIN
      Assets/Scenes/How To Play.unity
  11. +7
    -0
      Assets/Scenes/How To Play.unity.meta
  12. BIN
      Assets/Scenes/Main Menu.unity
  13. BIN
      Assets/Scenes/Official Levels/Level 2.unity
  14. BIN
      Assets/Scenes/Official Levels/Level 3.unity
  15. BIN
      Assets/Scenes/Official Levels/Level 4.unity
  16. +72
    -21
      Assets/Scripts/Character/CharacterController2D.cs
  17. +118
    -119
      Assets/Scripts/Character/CharacterInputController.cs
  18. +3
    -3
      Assets/Scripts/MonsterController.cs
  19. +77
    -0
      Assets/Scripts/UI/HowToPlayController.cs
  20. +11
    -0
      Assets/Scripts/UI/HowToPlayController.cs.meta
  21. +22
    -0
      Assets/Settings/PlayerInput.cs
  22. +22
    -0
      Assets/Settings/PlayerInput.inputactions
  23. BIN
      ProjectSettings/EditorBuildSettings.asset
  24. BIN
      ProjectSettings/ProjectSettings.asset

+ 8
- 0
Assets/Art Assets/Textures/UI.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4fcfd2d70cff21d4ba923565a0fc6c61
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Art Assets/Textures/UI/Arrow Keys.png (Stored with Git LFS) View File

size 1758

+ 156
- 0
Assets/Art Assets/Textures/UI/Arrow Keys.png.meta View File

@ -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:

BIN
Assets/Art Assets/Textures/UI/WASD Empty.png (Stored with Git LFS) View File

size 1726

+ 156
- 0
Assets/Art Assets/Textures/UI/WASD Empty.png.meta View File

@ -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:

BIN
Assets/Art Assets/Tiles/Environment/Death/Spikes.asset (Stored with Git LFS) View File

size 1029

+ 97
- 0
Assets/Prefabs/Level Manager.prefab View File

@ -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

+ 6
- 2
Assets/Prefabs/Player.prefab View File

@ -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:

BIN
Assets/Scenes/Credits.unity (Stored with Git LFS) View File

size 39413

BIN
Assets/Scenes/How To Play.unity (Stored with Git LFS) View File

size 72660

+ 7
- 0
Assets/Scenes/How To Play.unity.meta View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 8d22d24360cdbac4e9cfef8f8dbec2a9
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Scenes/Main Menu.unity (Stored with Git LFS) View File

size 46191

BIN
Assets/Scenes/Official Levels/Level 2.unity (Stored with Git LFS) View File

size 1966230

BIN
Assets/Scenes/Official Levels/Level 3.unity (Stored with Git LFS) View File

size 594145

BIN
Assets/Scenes/Official Levels/Level 4.unity (Stored with Git LFS) View File

size 388608

+ 72
- 21
Assets/Scripts/Character/CharacterController2D.cs View File

@ -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);
}
}

+ 118
- 119
Assets/Scripts/Character/CharacterInputController.cs View File

@ -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<bool> m_playerInput;
[SerializeField]
private Reference<bool> m_noInputAllowed;
[SerializeField]
private Reference<bool> m_isPlayerDead;
[SerializeField]
private Reference<bool> 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<Vector2>();
}
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<bool> m_playerInput;
[SerializeField]
private Reference<bool> m_noInputAllowed;
[SerializeField]
private Reference<bool> m_isPlayerDead;
[SerializeField]
private Reference<bool> 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<Vector2>();
}
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);
}
}
}

+ 3
- 3
Assets/Scripts/MonsterController.cs View File

@ -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();
}

+ 77
- 0
Assets/Scripts/UI/HowToPlayController.cs View File

@ -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);
}
}

+ 11
- 0
Assets/Scripts/UI/HowToPlayController.cs.meta View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3a01dc30c0a986a4cba3649c4aedf9db
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

+ 22
- 0
Assets/Settings/PlayerInput.cs View File

@ -146,6 +146,17 @@ public class @PlayerInput : IInputActionCollection, IDisposable
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": """",
""id"": ""f07ab40a-4b61-4c20-9090-d8d96d5ea496"",
""path"": ""<Gamepad>/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"": ""<Gamepad>/buttonSouth"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Jump"",
""isComposite"": false,
""isPartOfComposite"": false
}
]
}

+ 22
- 0
Assets/Settings/PlayerInput.inputactions View File

@ -133,6 +133,17 @@
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "",
"id": "f07ab40a-4b61-4c20-9090-d8d96d5ea496",
"path": "<Gamepad>/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": "<Gamepad>/buttonSouth",
"interactions": "",
"processors": "",
"groups": "",
"action": "Jump",
"isComposite": false,
"isPartOfComposite": false
}
]
}

BIN
ProjectSettings/EditorBuildSettings.asset (Stored with Git LFS) View File

size 968

BIN
ProjectSettings/ProjectSettings.asset (Stored with Git LFS) View File

size 20001

Loading…
Cancel
Save