diff --git a/Assets/Animations/CharacterController.controller b/Assets/Animations/CharacterController.controller index b12dea9..3f8cdf3 100644 --- a/Assets/Animations/CharacterController.controller +++ b/Assets/Animations/CharacterController.controller @@ -45,7 +45,7 @@ AnimatorController: m_DefaultInt: 0 m_DefaultBool: 0 m_Controller: {fileID: 0} - - m_Name: SpeedMultiple + - m_Name: AnimationSpeed m_Type: 1 m_DefaultFloat: 1 m_DefaultInt: 0 @@ -400,7 +400,7 @@ AnimatorState: m_TimeParameterActive: 0 m_Motion: {fileID: 7400016, guid: ecb900ca4b414eae9053afe2b45f3656, type: 3} m_Tag: - m_SpeedParameter: SpeedMultiple + m_SpeedParameter: AnimationSpeed m_MirrorParameter: m_CycleOffsetParameter: m_TimeParameter: @@ -427,7 +427,7 @@ AnimatorState: m_TimeParameterActive: 0 m_Motion: {fileID: 7400018, guid: ecb900ca4b414eae9053afe2b45f3656, type: 3} m_Tag: - m_SpeedParameter: SpeedMultiple + m_SpeedParameter: AnimationSpeed m_MirrorParameter: m_CycleOffsetParameter: m_TimeParameter: @@ -454,7 +454,7 @@ AnimatorState: m_TimeParameterActive: 0 m_Motion: {fileID: 7400004, guid: ecb900ca4b414eae9053afe2b45f3656, type: 3} m_Tag: - m_SpeedParameter: SpeedMultiple + m_SpeedParameter: AnimationSpeed m_MirrorParameter: m_CycleOffsetParameter: m_TimeParameter: @@ -481,7 +481,7 @@ AnimatorState: m_TimeParameterActive: 0 m_Motion: {fileID: 7400012, guid: ecb900ca4b414eae9053afe2b45f3656, type: 3} m_Tag: - m_SpeedParameter: SpeedMultiple + m_SpeedParameter: AnimationSpeed m_MirrorParameter: m_CycleOffsetParameter: m_TimeParameter: @@ -508,7 +508,7 @@ AnimatorState: m_TimeParameterActive: 0 m_Motion: {fileID: 7400008, guid: ecb900ca4b414eae9053afe2b45f3656, type: 3} m_Tag: - m_SpeedParameter: SpeedMultiple + m_SpeedParameter: AnimationSpeed m_MirrorParameter: m_CycleOffsetParameter: m_TimeParameter: @@ -564,7 +564,7 @@ AnimatorState: m_TimeParameterActive: 0 m_Motion: {fileID: 7400006, guid: ecb900ca4b414eae9053afe2b45f3656, type: 3} m_Tag: - m_SpeedParameter: SpeedMultiple + m_SpeedParameter: AnimationSpeed m_MirrorParameter: m_CycleOffsetParameter: m_TimeParameter: @@ -591,7 +591,7 @@ AnimatorState: m_TimeParameterActive: 0 m_Motion: {fileID: 7400010, guid: ecb900ca4b414eae9053afe2b45f3656, type: 3} m_Tag: - m_SpeedParameter: SpeedMultiple + m_SpeedParameter: AnimationSpeed m_MirrorParameter: m_CycleOffsetParameter: m_TimeParameter: diff --git a/Assets/Data/Logic Blocks/Diagonal Left.asset b/Assets/Data/Logic Blocks/Diagonal Left.asset index 948bd41..d943b36 100644 --- a/Assets/Data/Logic Blocks/Diagonal Left.asset +++ b/Assets/Data/Logic Blocks/Diagonal Left.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9ec63e7f90a7facdb5a834a6de80a1d3a24eefad4e66edf48da4beeea8997828 -size 797 +oid sha256:f0a05826b5823f5f159f5b67277de6e24551a7e1a5cde6113c13371a117fe7ad +size 798 diff --git a/Assets/Data/Logic Blocks/Diagonal Right.asset b/Assets/Data/Logic Blocks/Diagonal Right.asset index 9367242..8fce0d6 100644 --- a/Assets/Data/Logic Blocks/Diagonal Right.asset +++ b/Assets/Data/Logic Blocks/Diagonal Right.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6148522c50f0cd5dc7d6ca8ea8a6b0fd461d82fa7ca2b018633eebd8e5fd6577 -size 798 +oid sha256:edf4b3bd5a1f10ecf8721fe4410092ee3e909e1e07c25c66f2b0b87012db8569 +size 799 diff --git a/Assets/Scripts/Character.cs b/Assets/Scripts/Character.cs index 2f1b6f4..899ebd6 100644 --- a/Assets/Scripts/Character.cs +++ b/Assets/Scripts/Character.cs @@ -191,7 +191,7 @@ public class Character : MonoBehaviour transform.position = _startPos + Vector3.up * heightOffset(1); } - private void StartAnimation(Animation animation,float speed = 1) + public void StartAnimation(Animation animation,float speed = 1) { characterAnimator.SetFloat("AnimationSpeed", (1 / speed)); @@ -220,7 +220,7 @@ public class Character : MonoBehaviour } } - private void StopAnimation(Animation animation) + public void StopAnimation(Animation animation) { characterAnimator.SetFloat("AnimationSpeed", 1f); switch (animation) diff --git a/Assets/Scripts/KeyboardInput.cs b/Assets/Scripts/KeyboardInput.cs index 607e951..886aee4 100644 --- a/Assets/Scripts/KeyboardInput.cs +++ b/Assets/Scripts/KeyboardInput.cs @@ -25,19 +25,25 @@ public class KeyboardInput : MonoBehaviour if (Input.GetKeyDown(KeyCode.LeftArrow)) { - character.Rotate(Direction.Left, characterSpeed); + StartCoroutine(character.RotateToDirection(Direction.Left, Character.Animation.Jump, characterSpeed, true)); } if (Input.GetKeyDown(KeyCode.RightArrow)) { - character.Rotate(Direction.Right, characterSpeed); + StartCoroutine(character.RotateToDirection(Direction.Right, Character.Animation.Jump, characterSpeed, true)); } if (Input.GetKeyDown(KeyCode.UpArrow)) { - character.Move(Direction.Forward, characterSpeed); + float outTime; + Move move = (Move)ScriptableObject.CreateInstance(typeof(Move)); + move.Run(character, characterSpeed, out outTime); + Destroy(move); } if (Input.GetKeyDown(KeyCode.Space)) { - character.Jump(Direction.Forward, characterSpeed); + float outTime; + Jump jump = (Jump)ScriptableObject.CreateInstance(typeof(Jump)); + jump.Run(character, characterSpeed, out outTime); + Destroy(jump); } } @@ -49,4 +55,4 @@ public class KeyboardInput : MonoBehaviour } #endregion Unity Functions -} +} \ No newline at end of file diff --git a/Assets/Scripts/LevelBlocks/Water.cs b/Assets/Scripts/LevelBlocks/Water.cs new file mode 100644 index 0000000..2a2f046 --- /dev/null +++ b/Assets/Scripts/LevelBlocks/Water.cs @@ -0,0 +1,65 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class Water : ActiveBlock +{ + + [SerializeField] + [Tooltip("GameObject which appears when character respawns")] + private GameObject lillyPad; + + [SerializeField] + [Tooltip("Distance character will be submerged into the water")] + private float FallDistance = 0.5f; + + private Character trappedCharacter; + + + public override void OnWalkedOnByPlayer(PlayerData player) + { + base.OnWalkedOnByPlayer(player); + + if (trappedCharacter == null) + { + player.character = trappedCharacter; + trappedCharacter.stuck = true; + + trappedCharacter.StartAnimation(Character.Animation.Hit); + StartCoroutine(LerpToPosition(trappedCharacter.transform, VisualPosition + Vector3.down * FallDistance, 1)); + } + + } + + public override void OnRoundEnd(PlayerData[] allPlayers) + { + base.OnRoundEnd(allPlayers); + + if (trappedCharacter != null) + { + StartCoroutine(LerpToPosition(trappedCharacter.transform, VisualPosition, 1)); + StartCoroutine(LerpToPosition(lillyPad.transform, VisualPosition, 1)); + trappedCharacter.stuck = false; + } + + } + + private IEnumerator LerpToPosition(Transform target, Vector3 endPos, float time) + { + Vector3 _startPos = target.position; + + float elapsedTime = 0; + while (elapsedTime / time < 1) + { + + target.position = Vector3.Lerp(_startPos, endPos, (elapsedTime / time)); + yield return new WaitForEndOfFrame(); + + elapsedTime += Time.deltaTime; + } + + target.position = endPos; + } + + +} diff --git a/Assets/Scripts/LevelBlocks/Water.cs.meta b/Assets/Scripts/LevelBlocks/Water.cs.meta new file mode 100644 index 0000000..de5ecbc --- /dev/null +++ b/Assets/Scripts/LevelBlocks/Water.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 68d0f0591435c9944a441b8fa5244072 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: