|
@ -31,7 +31,7 @@ public class Character : MonoBehaviour |
|
|
public bool CloneInventoryOnStart = false; |
|
|
public bool CloneInventoryOnStart = false; |
|
|
|
|
|
|
|
|
[Tooltip("How many lives to start out with")] |
|
|
[Tooltip("How many lives to start out with")] |
|
|
public int lives = 5; |
|
|
|
|
|
|
|
|
public int lives = 3; |
|
|
|
|
|
|
|
|
[SerializeField] |
|
|
[SerializeField] |
|
|
[Tooltip("Character to display")] |
|
|
[Tooltip("Character to display")] |
|
@ -120,7 +120,6 @@ public class Character : MonoBehaviour |
|
|
} |
|
|
} |
|
|
transform.position = Target.VisualPosition; |
|
|
transform.position = Target.VisualPosition; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
IEnumerator MoveCoroutine(Block Target, Transform Current, float time, float heightMax) |
|
|
IEnumerator MoveCoroutine(Block Target, Transform Current, float time, float heightMax) |
|
|
{ |
|
|
{ |
|
|
float elapsedTime = 0; |
|
|
float elapsedTime = 0; |
|
@ -137,7 +136,6 @@ public class Character : MonoBehaviour |
|
|
} |
|
|
} |
|
|
transform.position = Target.VisualPosition; |
|
|
transform.position = Target.VisualPosition; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
IEnumerator MoveConveyorForwardCoroutine(Block Target, Transform Current, float time, float heightMax) |
|
|
IEnumerator MoveConveyorForwardCoroutine(Block Target, Transform Current, float time, float heightMax) |
|
|
{ |
|
|
{ |
|
|
float elapsedTime = 0; |
|
|
float elapsedTime = 0; |
|
@ -198,7 +196,6 @@ public class Character : MonoBehaviour |
|
|
} |
|
|
} |
|
|
Current.position = charEndPosition; |
|
|
Current.position = charEndPosition; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
IEnumerator PushLeftCoroutine(Transform Current, float time) |
|
|
IEnumerator PushLeftCoroutine(Transform Current, float time) |
|
|
{ |
|
|
{ |
|
|
float elapsedTime = 0; |
|
|
float elapsedTime = 0; |
|
@ -214,7 +211,6 @@ public class Character : MonoBehaviour |
|
|
} |
|
|
} |
|
|
Current.position = endPosition; |
|
|
Current.position = endPosition; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
IEnumerator PushRightCoroutine(Transform Current, float time) |
|
|
IEnumerator PushRightCoroutine(Transform Current, float time) |
|
|
{ |
|
|
{ |
|
|
float elapsedTime = 0; |
|
|
float elapsedTime = 0; |
|
@ -230,7 +226,6 @@ public class Character : MonoBehaviour |
|
|
} |
|
|
} |
|
|
Current.position = endPosition; |
|
|
Current.position = endPosition; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
IEnumerator MoveDownCoroutine(Block Target, Transform Current, float time, float heightMax) |
|
|
IEnumerator MoveDownCoroutine(Block Target, Transform Current, float time, float heightMax) |
|
|
{ |
|
|
{ |
|
|
float elapsedTime = 0; |
|
|
float elapsedTime = 0; |
|
@ -246,14 +241,12 @@ public class Character : MonoBehaviour |
|
|
} |
|
|
} |
|
|
transform.position = Target.VisualPosition; |
|
|
transform.position = Target.VisualPosition; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
IEnumerator rotateCoroutine(Direction direction, Transform Current, float time, float heightMax) |
|
|
IEnumerator rotateCoroutine(Direction direction, Transform Current, float time, float heightMax) |
|
|
{ |
|
|
{ |
|
|
float elapsedTime = 0; |
|
|
float elapsedTime = 0; |
|
|
time *= 0.8f; |
|
|
time *= 0.8f; |
|
|
Vector3 endDirection = direction.ToVector(Current); |
|
|
Vector3 endDirection = direction.ToVector(Current); |
|
|
Vector3 startDirection = Current.forward; |
|
|
Vector3 startDirection = Current.forward; |
|
|
Vector3 startPosition = transform.position; |
|
|
|
|
|
while (elapsedTime < time) |
|
|
while (elapsedTime < time) |
|
|
{ |
|
|
{ |
|
|
characterAnimator.Play("Jump"); |
|
|
characterAnimator.Play("Jump"); |
|
@ -263,7 +256,21 @@ public class Character : MonoBehaviour |
|
|
} |
|
|
} |
|
|
transform.forward = endDirection; |
|
|
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>
|
|
|
/// <summary>
|
|
|
/// Moves one block in specefied direction, Can walk off obstacles
|
|
|
/// Moves one block in specefied direction, Can walk off obstacles
|
|
@ -375,7 +382,6 @@ public class Character : MonoBehaviour |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void respawnCharacter() |
|
|
public void respawnCharacter() |
|
|
{ |
|
|
{ |
|
|
/* Will introduce more complex criteria for choosing where to respawn the player in future |
|
|
/* 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)); |
|
|
StartCoroutine(rotateCoroutine(direction, transform, speed, 0.15f)); |
|
|
//transform.forward = direction.ToVector(transform);
|
|
|
//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>
|
|
|
/// <summary>
|
|
|
/// Jumps in specefied direction, picks between Long Jump and Jumping up
|
|
|
/// Jumps in specefied direction, picks between Long Jump and Jumping up
|
|
|