|
|
@ -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
|
|
|
|