Browse Source

Added Animations

main
Joshua Reason 2 years ago
parent
commit
3c687b5b29
14 changed files with 287 additions and 19 deletions
  1. +53
    -0
      Assets/Art Assets/Animations/Player/Death.anim
  2. +8
    -0
      Assets/Art Assets/Animations/Player/Death.anim.meta
  3. +53
    -0
      Assets/Art Assets/Animations/Player/Land.anim
  4. +8
    -0
      Assets/Art Assets/Animations/Player/Land.anim.meta
  5. +53
    -0
      Assets/Art Assets/Animations/Player/Respawn.anim
  6. +8
    -0
      Assets/Art Assets/Animations/Player/Respawn.anim.meta
  7. +38
    -1
      Assets/Prefabs/Player.prefab
  8. BIN
      Assets/Scenes/Official Levels/Level 1.unity
  9. +8
    -2
      Assets/Scripts/Character/CharacterController2D.cs
  10. +44
    -3
      Assets/Scripts/Character/CharacterInputController.cs
  11. +3
    -1
      Assets/Scripts/Character/CharacterReset.cs
  12. +1
    -7
      Assets/Scripts/ChestController.cs
  13. +6
    -3
      Assets/Scripts/IntroController.cs
  14. +2
    -0
      Assets/Scripts/LevelManager.cs

+ 53
- 0
Assets/Art Assets/Animations/Player/Death.anim View File

@ -0,0 +1,53 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Death
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves: []
m_PPtrCurves: []
m_SampleRate: 60
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings: []
pptrCurveMapping: []
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 1
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 1
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves: []
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_Events: []

+ 8
- 0
Assets/Art Assets/Animations/Player/Death.anim.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: de457e59ca99d9440a3e448860144a88
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleVariant:

+ 53
- 0
Assets/Art Assets/Animations/Player/Land.anim View File

@ -0,0 +1,53 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Land
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves: []
m_PPtrCurves: []
m_SampleRate: 60
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings: []
pptrCurveMapping: []
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 1
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 1
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves: []
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_Events: []

+ 8
- 0
Assets/Art Assets/Animations/Player/Land.anim.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5a26a046d2fbfac4fb272dfb1eaf4773
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleVariant:

+ 53
- 0
Assets/Art Assets/Animations/Player/Respawn.anim View File

@ -0,0 +1,53 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Respawn
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves: []
m_PPtrCurves: []
m_SampleRate: 60
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings: []
pptrCurveMapping: []
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 1
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 1
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves: []
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_Events: []

+ 8
- 0
Assets/Art Assets/Animations/Player/Respawn.anim.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ad9e15950709a444795a50d271f72b81
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleVariant:

+ 38
- 1
Assets/Prefabs/Player.prefab View File

@ -216,9 +216,36 @@ MonoBehaviour:
m_CeilingCheck: {fileID: 4668322656710469013}
m_WallCheck: {fileID: 4668322655870949457}
m_CrouchDisableCollider: {fileID: 0}
OnJumpEvent:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 4668322654876184624}
m_TargetAssemblyTypeName: CharacterInputController, Assembly-CSharp
m_MethodName: OnJumpHappened
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
OnLandEvent:
m_PersistentCalls:
m_Calls: []
m_Calls:
- m_Target: {fileID: 4668322654876184624}
m_TargetAssemblyTypeName: CharacterInputController, Assembly-CSharp
m_MethodName: OnLandHappened
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
OnCrouchEvent:
m_PersistentCalls:
m_Calls: []
@ -243,6 +270,15 @@ MonoBehaviour:
Variable: {fileID: 11400000, guid: 4644ea58ce4d81544b22caddc5e66c86, type: 2}
m_useLocal: 0
m_localValue: 0
m_isPlayerDead:
Variable: {fileID: 11400000, guid: a1586014535831a4e80b30178ff5ced4, type: 2}
m_useLocal: 0
m_localValue: 0
m_isVictory:
Variable: {fileID: 11400000, guid: f1d9845714eccd24bafc361e7f23c030, type: 2}
m_useLocal: 0
m_localValue: 0
m_animator: {fileID: 4668322655423991002}
m_speed: 2
--- !u!95 &4668322654876184631
Animator:
@ -279,6 +315,7 @@ MonoBehaviour:
Variable: {fileID: 11400000, guid: a1586014535831a4e80b30178ff5ced4, type: 2}
m_useLocal: 0
m_localValue: 0
m_playerAnimator: {fileID: 4668322655423991002}
--- !u!1 &4668322655423990996
GameObject:
m_ObjectHideFlags: 0

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

size 173708

+ 8
- 2
Assets/Scripts/Character/CharacterController2D.cs View File

@ -14,6 +14,7 @@ public class CharacterController2D : MonoBehaviour
[SerializeField] private Transform m_WallCheck;
[SerializeField] private Collider2D m_CrouchDisableCollider; // A collider that will be disabled when crouching
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.
private bool m_TouchingWall;
@ -27,6 +28,7 @@ public class CharacterController2D : MonoBehaviour
[Header("Events")]
[Space]
public UnityEvent OnJumpEvent;
public UnityEvent OnLandEvent;
[System.Serializable]
@ -150,6 +152,8 @@ public class CharacterController2D : MonoBehaviour
// 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;
@ -159,14 +163,16 @@ public class CharacterController2D : MonoBehaviour
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;
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;
m_LastWallJumpDirection = Direction.L;
}
}

+ 44
- 3
Assets/Scripts/Character/CharacterInputController.cs View File

@ -8,7 +8,7 @@ using NaughtyAttributes;
public class CharacterInputController : MonoBehaviour
{
[SerializeField,Header("References")]
[SerializeField, Header("References")]
private CharacterController2D m_characterController;
[SerializeField]
@ -17,7 +17,16 @@ public class CharacterInputController : MonoBehaviour
[SerializeField]
private Reference<bool> m_noInputAllowed;
[SerializeField,BoxGroup("Settings")]
[SerializeField]
private Reference<bool> m_isPlayerDead;
[SerializeField]
private Reference<bool> m_isVictory;
[SerializeField]
private Animator m_animator;
[SerializeField, BoxGroup("Settings")]
private float m_speed = 2.0f;
[ShowNonSerializedField]
@ -28,6 +37,12 @@ public class CharacterInputController : MonoBehaviour
private void OnEnable()
{
m_isPlayerDead.OnValueChanged += OnDeath;
m_isVictory.OnValueChanged += OnVictory;
}
public void OnMove(InputAction.CallbackContext context)
{
m_movement = context.ReadValue<Vector2>();
@ -45,12 +60,38 @@ public class CharacterInputController : MonoBehaviour
{
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_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 OnDeath(bool value)
{
if (value)
m_animator.SetTrigger("Death");
else
m_animator.SetTrigger("Respawn");
}
public void OnVictory(bool value)
{
if (value)
m_animator.SetTrigger("Victory");
}

+ 3
- 1
Assets/Scripts/Character/CharacterReset.cs View File

@ -10,6 +10,7 @@ public class CharacterReset : MonoBehaviour, IResettable
Reference<bool> m_isPlayerDead;
private Vector3 m_startPosition;
private Quaternion m_startRotation;
@ -23,7 +24,7 @@ public class CharacterReset : MonoBehaviour, IResettable
public void OnResetEnd()
{
}
public IEnumerator OnResetStart(float time)
@ -32,6 +33,7 @@ public class CharacterReset : MonoBehaviour, IResettable
transform.rotation = m_startRotation;
m_isPlayerDead.Value = false;
yield break;
}
}

+ 1
- 7
Assets/Scripts/ChestController.cs View File

@ -10,9 +10,6 @@ public class ChestController : MonoBehaviour
[SerializeField, Header("References")]
private Animator m_chestAnimator;
[SerializeField]
private Animator m_playerAnimator;
[SerializeField]
private Reference<bool> m_freezePlayer;
@ -21,12 +18,9 @@ public class ChestController : MonoBehaviour
private void OnTriggerEnter2D(Collider2D collision)
{
Animator[] animators = collision.GetComponentsInChildren<Animator>().Concat(collision.GetComponentsInParent<Animator>()).ToArray();
if (animators.Contains(m_playerAnimator))
if (collision.CompareTag("Player"))
{
m_chestAnimator.SetBool("Open", true);
m_playerAnimator.SetTrigger("Victory");
m_freezePlayer.Value = true;
m_isVictory.Value = true;
}

+ 6
- 3
Assets/Scripts/IntroController.cs View File

@ -154,15 +154,18 @@ public class IntroController : MonoBehaviour, IResettable
public IEnumerator OnResetStart(float time)
{
yield break;
}
yield return new WaitForSeconds(time - gotime);
private IEnumerator ResetRoutine(float time)
{
m_goText.gameObject.SetActive(true);
yield return new WaitForSeconds(gotime);
yield return new WaitForSeconds(time);
m_goText.gameObject.SetActive(false);
}
public void OnResetEnd()
{
StartCoroutine(ResetRoutine(gotime));
}
}

+ 2
- 0
Assets/Scripts/LevelManager.cs View File

@ -96,6 +96,8 @@ public class LevelManager : MonoBehaviour
{
m_freezePlayer.Value = true;
yield return new WaitForSeconds(1);
m_timer.Value = m_timeInLevel;

Loading…
Cancel
Save