diff --git a/Assets/Data/Logic Blocks/Diagonal Left.asset b/Assets/Data/Logic Blocks/Diagonal Left.asset new file mode 100644 index 0000000..948bd41 --- /dev/null +++ b/Assets/Data/Logic Blocks/Diagonal Left.asset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9ec63e7f90a7facdb5a834a6de80a1d3a24eefad4e66edf48da4beeea8997828 +size 797 diff --git a/Assets/Data/Logic Blocks/Horse_Left.asset.meta b/Assets/Data/Logic Blocks/Diagonal Left.asset.meta similarity index 79% rename from Assets/Data/Logic Blocks/Horse_Left.asset.meta rename to Assets/Data/Logic Blocks/Diagonal Left.asset.meta index 2443346..2c84677 100644 --- a/Assets/Data/Logic Blocks/Horse_Left.asset.meta +++ b/Assets/Data/Logic Blocks/Diagonal Left.asset.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 478ec601e0a1c854984276a192a52666 +guid: 752565cc5a95020498b9ed396343f3c0 NativeFormatImporter: externalObjects: {} mainObjectFileID: 11400000 diff --git a/Assets/Data/Logic Blocks/Diagonal Right.asset b/Assets/Data/Logic Blocks/Diagonal Right.asset new file mode 100644 index 0000000..9367242 --- /dev/null +++ b/Assets/Data/Logic Blocks/Diagonal Right.asset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6148522c50f0cd5dc7d6ca8ea8a6b0fd461d82fa7ca2b018633eebd8e5fd6577 +size 798 diff --git a/Assets/Data/Logic Blocks/Diagonal_Left.asset.meta b/Assets/Data/Logic Blocks/Diagonal Right.asset.meta similarity index 79% rename from Assets/Data/Logic Blocks/Diagonal_Left.asset.meta rename to Assets/Data/Logic Blocks/Diagonal Right.asset.meta index 87aa9b3..e4cd8f5 100644 --- a/Assets/Data/Logic Blocks/Diagonal_Left.asset.meta +++ b/Assets/Data/Logic Blocks/Diagonal Right.asset.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: ba4f7785390953441913d0e6f419d9b7 +guid: efab8a199b362cb42b3e0bce70dd05f4 NativeFormatImporter: externalObjects: {} mainObjectFileID: 11400000 diff --git a/Assets/Data/Logic Blocks/Diagonal_Left.asset b/Assets/Data/Logic Blocks/Diagonal_Left.asset deleted file mode 100644 index ab3253d..0000000 --- a/Assets/Data/Logic Blocks/Diagonal_Left.asset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5671a1a7b9e5f4f0a3fee67ebf92615af4279d9edfce79d28823f279d009e22a -size 872 diff --git a/Assets/Data/Logic Blocks/Diagonal_Right.asset b/Assets/Data/Logic Blocks/Diagonal_Right.asset deleted file mode 100644 index 6e1710c..0000000 --- a/Assets/Data/Logic Blocks/Diagonal_Right.asset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:33d9e2ccd3a3a69112bfc9e679471d717af1102f0cb6223791a9a2624557d982 -size 873 diff --git a/Assets/Data/Logic Blocks/Horse_Left.asset b/Assets/Data/Logic Blocks/Horse_Left.asset deleted file mode 100644 index 24bcec6..0000000 --- a/Assets/Data/Logic Blocks/Horse_Left.asset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c689e7823398372bb409980d735f9ce532db12ffa527ff0b996e907cc0390745 -size 868 diff --git a/Assets/Data/Logic Blocks/Horse_Right.asset b/Assets/Data/Logic Blocks/Horse_Right.asset deleted file mode 100644 index 996704a..0000000 --- a/Assets/Data/Logic Blocks/Horse_Right.asset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:fd3e7a21a3b9ea59742941d1f65dec34c56480c36ac7742d03ce15768b696311 -size 869 diff --git a/Assets/Data/Logic Blocks/Rotate Half Left.asset b/Assets/Data/Logic Blocks/Rotate Half Left.asset new file mode 100644 index 0000000..2ec5ee4 --- /dev/null +++ b/Assets/Data/Logic Blocks/Rotate Half Left.asset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:717bae5b5493eeae1844f77f15938d1f0f2d88f54d609e5fb196e638ba0f14a1 +size 554 diff --git a/Assets/Data/Logic Blocks/Horse_Right.asset.meta b/Assets/Data/Logic Blocks/Rotate Half Left.asset.meta similarity index 79% rename from Assets/Data/Logic Blocks/Horse_Right.asset.meta rename to Assets/Data/Logic Blocks/Rotate Half Left.asset.meta index 6dd5359..1fe5727 100644 --- a/Assets/Data/Logic Blocks/Horse_Right.asset.meta +++ b/Assets/Data/Logic Blocks/Rotate Half Left.asset.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 86adbb7231bac86469daf8668e55025f +guid: 6658a5299cc9a044a913d219abbe4a99 NativeFormatImporter: externalObjects: {} mainObjectFileID: 11400000 diff --git a/Assets/Data/Logic Blocks/Rotate Half Right.asset b/Assets/Data/Logic Blocks/Rotate Half Right.asset new file mode 100644 index 0000000..3984049 --- /dev/null +++ b/Assets/Data/Logic Blocks/Rotate Half Right.asset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:990248dac7144fbca0b3bb00119abd7a9c46e9f59e5fbdfb6d72317fc611e668 +size 555 diff --git a/Assets/Data/Logic Blocks/Diagonal_Right.asset.meta b/Assets/Data/Logic Blocks/Rotate Half Right.asset.meta similarity index 79% rename from Assets/Data/Logic Blocks/Diagonal_Right.asset.meta rename to Assets/Data/Logic Blocks/Rotate Half Right.asset.meta index 727e0dc..b733043 100644 --- a/Assets/Data/Logic Blocks/Diagonal_Right.asset.meta +++ b/Assets/Data/Logic Blocks/Rotate Half Right.asset.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 0086f005a63e8404aaee25e4ae4734d7 +guid: f6be455a4dfaafd4fb4a0e74a9d19b0b NativeFormatImporter: externalObjects: {} mainObjectFileID: 11400000 diff --git a/Assets/Scripts/Character.cs b/Assets/Scripts/Character.cs index 9beb1d1..7d99184 100644 --- a/Assets/Scripts/Character.cs +++ b/Assets/Scripts/Character.cs @@ -31,7 +31,7 @@ public class Character : MonoBehaviour public bool CloneInventoryOnStart = false; [Tooltip("How many lives to start out with")] - public int lives = 5; + public int lives = 3; [SerializeField] [Tooltip("Character to display")] @@ -120,7 +120,6 @@ public class Character : MonoBehaviour } transform.position = Target.VisualPosition; } - IEnumerator MoveCoroutine(Block Target, Transform Current, float time, float heightMax) { float elapsedTime = 0; @@ -137,7 +136,6 @@ public class Character : MonoBehaviour } transform.position = Target.VisualPosition; } - IEnumerator MoveConveyorForwardCoroutine(Block Target, Transform Current, float time, float heightMax) { float elapsedTime = 0; @@ -198,7 +196,6 @@ public class Character : MonoBehaviour } Current.position = charEndPosition; } - IEnumerator PushLeftCoroutine(Transform Current, float time) { float elapsedTime = 0; @@ -214,7 +211,6 @@ public class Character : MonoBehaviour } Current.position = endPosition; } - IEnumerator PushRightCoroutine(Transform Current, float time) { float elapsedTime = 0; @@ -230,7 +226,6 @@ public class Character : MonoBehaviour } Current.position = endPosition; } - IEnumerator MoveDownCoroutine(Block Target, Transform Current, float time, float heightMax) { float elapsedTime = 0; @@ -246,14 +241,12 @@ public class Character : MonoBehaviour } transform.position = Target.VisualPosition; } - IEnumerator rotateCoroutine(Direction direction, Transform Current, float time, float heightMax) { float elapsedTime = 0; time *= 0.8f; Vector3 endDirection = direction.ToVector(Current); Vector3 startDirection = Current.forward; - Vector3 startPosition = transform.position; while (elapsedTime < time) { characterAnimator.Play("Jump"); @@ -263,7 +256,21 @@ public class Character : MonoBehaviour } transform.forward = endDirection; } - + IEnumerator rotateHalfCoroutine(Direction direction, Transform Current, float time, float heightMax) + { + float elapsedTime = 0; + time *= 0.8f; + Vector3 endDirection = (direction.ToVector(Current) + Current.forward).normalized; + Vector3 startDirection = Current.forward; + while (elapsedTime < time) + { + characterAnimator.Play("Jump"); + transform.forward = Vector3.Slerp(startDirection, endDirection, (elapsedTime / time)); + yield return new WaitForEndOfFrame(); + elapsedTime += Time.deltaTime; + } + transform.forward = endDirection; + } /// /// Moves one block in specefied direction, Can walk off obstacles @@ -375,7 +382,6 @@ public class Character : MonoBehaviour } } - public void respawnCharacter() { /* Will introduce more complex criteria for choosing where to respawn the player in future @@ -490,6 +496,11 @@ public class Character : MonoBehaviour StartCoroutine(rotateCoroutine(direction, transform, speed, 0.15f)); //transform.forward = direction.ToVector(transform); } + public void RotateHalf(Direction direction, float speed) + { + StartCoroutine(rotateHalfCoroutine(direction, transform, speed, 0.15f)); + //transform.forward = direction.ToVector(transform); + } /// /// Jumps in specefied direction, picks between Long Jump and Jumping up diff --git a/Assets/Scripts/Logic/Blocks/RotateHalf.cs b/Assets/Scripts/Logic/Blocks/RotateHalf.cs new file mode 100644 index 0000000..d5815f8 --- /dev/null +++ b/Assets/Scripts/Logic/Blocks/RotateHalf.cs @@ -0,0 +1,61 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +/// +/// Logic block which deals with moving a character in a direction +/// +[CreateAssetMenu(menuName = "Major Project/RotateHalf Block")] +[System.Serializable] +public class RotateHalf : LogicBlock +{ + #region Inspector Fields + [SerializeField] + [Header("Rotate Settings")] + [Tooltip("Direction to rotate in")] + protected Direction direction; + #endregion Inspector Fields + + + #region Class Functions + + /// + /// Rotates the player in the direction specified by this block + /// + /// Player to rotate + protected override void BlockLogic(Character player, float animationTime) + { + player.RotateHalf(direction, animationTime); + } + + /// + /// Returns the block that the character will endUp on after they use this logic element + /// + /// block character is on + /// layers to ignore + /// block which character will finish on after performing this function + public override Block GetEndBlock(Block startBlock, Transform transform, LayerMask layerMask) + { + //no movement when rotating + return startBlock; + } + + public override void CopyToken(BlockToken token) + { + base.CopyToken(token); + direction = ((DirectionToken)token).direction; + } + + public override BlockToken ToToken(BlockToken token = null) + { + if (token == null) + token = new DirectionToken(this); + + DirectionToken retVal = (DirectionToken)base.ToToken(token); + retVal.direction = direction; + + return retVal; + } + + #endregion Class Functions +} diff --git a/Assets/Scripts/Logic/Blocks/RotateHalf.cs.meta b/Assets/Scripts/Logic/Blocks/RotateHalf.cs.meta new file mode 100644 index 0000000..0a6654d --- /dev/null +++ b/Assets/Scripts/Logic/Blocks/RotateHalf.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f6cdbe450444d7945857bf5bc1cd58d2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: