Browse Source

Fixed the diagonal left and right block so character jumps diagonally

Josh_Dev_branch
ClairePeta 5 years ago
parent
commit
8d81b73dee
15 changed files with 109 additions and 26 deletions
  1. +3
    -0
      Assets/Data/Logic Blocks/Diagonal Left.asset
  2. +1
    -1
      Assets/Data/Logic Blocks/Diagonal Left.asset.meta
  3. +3
    -0
      Assets/Data/Logic Blocks/Diagonal Right.asset
  4. +1
    -1
      Assets/Data/Logic Blocks/Diagonal Right.asset.meta
  5. +0
    -3
      Assets/Data/Logic Blocks/Diagonal_Left.asset
  6. +0
    -3
      Assets/Data/Logic Blocks/Diagonal_Right.asset
  7. +0
    -3
      Assets/Data/Logic Blocks/Horse_Left.asset
  8. +0
    -3
      Assets/Data/Logic Blocks/Horse_Right.asset
  9. +3
    -0
      Assets/Data/Logic Blocks/Rotate Half Left.asset
  10. +1
    -1
      Assets/Data/Logic Blocks/Rotate Half Left.asset.meta
  11. +3
    -0
      Assets/Data/Logic Blocks/Rotate Half Right.asset
  12. +1
    -1
      Assets/Data/Logic Blocks/Rotate Half Right.asset.meta
  13. +21
    -10
      Assets/Scripts/Character.cs
  14. +61
    -0
      Assets/Scripts/Logic/Blocks/RotateHalf.cs
  15. +11
    -0
      Assets/Scripts/Logic/Blocks/RotateHalf.cs.meta

+ 3
- 0
Assets/Data/Logic Blocks/Diagonal Left.asset View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9ec63e7f90a7facdb5a834a6de80a1d3a24eefad4e66edf48da4beeea8997828
size 797

Assets/Data/Logic Blocks/Horse_Left.asset.meta → Assets/Data/Logic Blocks/Diagonal Left.asset.meta View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 478ec601e0a1c854984276a192a52666
guid: 752565cc5a95020498b9ed396343f3c0
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000

+ 3
- 0
Assets/Data/Logic Blocks/Diagonal Right.asset View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6148522c50f0cd5dc7d6ca8ea8a6b0fd461d82fa7ca2b018633eebd8e5fd6577
size 798

Assets/Data/Logic Blocks/Diagonal_Left.asset.meta → Assets/Data/Logic Blocks/Diagonal Right.asset.meta View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: ba4f7785390953441913d0e6f419d9b7
guid: efab8a199b362cb42b3e0bce70dd05f4
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000

+ 0
- 3
Assets/Data/Logic Blocks/Diagonal_Left.asset View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:5671a1a7b9e5f4f0a3fee67ebf92615af4279d9edfce79d28823f279d009e22a
size 872

+ 0
- 3
Assets/Data/Logic Blocks/Diagonal_Right.asset View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:33d9e2ccd3a3a69112bfc9e679471d717af1102f0cb6223791a9a2624557d982
size 873

+ 0
- 3
Assets/Data/Logic Blocks/Horse_Left.asset View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c689e7823398372bb409980d735f9ce532db12ffa527ff0b996e907cc0390745
size 868

+ 0
- 3
Assets/Data/Logic Blocks/Horse_Right.asset View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:fd3e7a21a3b9ea59742941d1f65dec34c56480c36ac7742d03ce15768b696311
size 869

+ 3
- 0
Assets/Data/Logic Blocks/Rotate Half Left.asset View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:717bae5b5493eeae1844f77f15938d1f0f2d88f54d609e5fb196e638ba0f14a1
size 554

Assets/Data/Logic Blocks/Horse_Right.asset.meta → Assets/Data/Logic Blocks/Rotate Half Left.asset.meta View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 86adbb7231bac86469daf8668e55025f
guid: 6658a5299cc9a044a913d219abbe4a99
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000

+ 3
- 0
Assets/Data/Logic Blocks/Rotate Half Right.asset View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:990248dac7144fbca0b3bb00119abd7a9c46e9f59e5fbdfb6d72317fc611e668
size 555

Assets/Data/Logic Blocks/Diagonal_Right.asset.meta → Assets/Data/Logic Blocks/Rotate Half Right.asset.meta View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 0086f005a63e8404aaee25e4ae4734d7
guid: f6be455a4dfaafd4fb4a0e74a9d19b0b
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000

+ 21
- 10
Assets/Scripts/Character.cs View File

@ -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;
}
/// <summary>
/// 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);
}
/// <summary>
/// Jumps in specefied direction, picks between Long Jump and Jumping up

+ 61
- 0
Assets/Scripts/Logic/Blocks/RotateHalf.cs View File

@ -0,0 +1,61 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Logic block which deals with moving a character in a direction
/// </summary>
[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
/// <summary>
/// Rotates the player in the direction specified by this block
/// </summary>
/// <param name="player">Player to rotate</param>
protected override void BlockLogic(Character player, float animationTime)
{
player.RotateHalf(direction, animationTime);
}
/// <summary>
/// Returns the block that the character will endUp on after they use this logic element
/// </summary>
/// <param name="startBlock">block character is on</param>
/// <param name="layerMask">layers to ignore</param>
/// <returns>block which character will finish on after performing this function </returns>
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
}

+ 11
- 0
Assets/Scripts/Logic/Blocks/RotateHalf.cs.meta View File

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

Loading…
Cancel
Save