|
|
@ -7,7 +7,7 @@ using Networking.Server; |
|
|
|
|
|
|
|
public class Character : MonoBehaviour |
|
|
|
{ |
|
|
|
public enum Animation {Walk,Jump,Slide} |
|
|
|
public enum Animation {Walk,Run,Jump,Slide} |
|
|
|
|
|
|
|
public string nextScene; |
|
|
|
Animator characterAnimator; |
|
|
@ -106,7 +106,60 @@ public class Character : MonoBehaviour |
|
|
|
return new Vector3(0, y, 0); |
|
|
|
} |
|
|
|
|
|
|
|
public IEnumerator MoveToBlock(Block Target, Animation animation, float time) |
|
|
|
public IEnumerator MoveToBlock(Block target, Animation animation, float time) |
|
|
|
{ |
|
|
|
|
|
|
|
switch (animation) |
|
|
|
{ |
|
|
|
case Animation.Walk: |
|
|
|
characterAnimator.SetBool("isWalking", true); |
|
|
|
break; |
|
|
|
case Animation.Run: |
|
|
|
characterAnimator.SetBool("isRunning", true); |
|
|
|
break; |
|
|
|
case Animation.Jump: |
|
|
|
characterAnimator.SetTrigger("Jump"); |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
yield return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public IEnumerator LerpToBlock(Block target,float time, System.Func<float,float> heightOffset) |
|
|
|
{ |
|
|
|
|
|
|
|
Vector3 _startPos = transform.position; |
|
|
|
Vector3 _endPos = target.VisualPosition; |
|
|
|
|
|
|
|
Vector3 _newPos; |
|
|
|
|
|
|
|
float elapsedTime = 0; |
|
|
|
while(elapsedTime/time < 1) |
|
|
|
{ |
|
|
|
|
|
|
|
_newPos = Vector3.Lerp(_startPos, _endPos, (elapsedTime / time)); |
|
|
|
_newPos.y += heightOffset(elapsedTime / time); |
|
|
|
|
|
|
|
transform.position = _newPos; |
|
|
|
|
|
|
|
yield return new WaitForEndOfFrame(); |
|
|
|
|
|
|
|
elapsedTime += Time.deltaTime; |
|
|
|
} |
|
|
|
|
|
|
|
_newPos = _endPos; |
|
|
|
_newPos.y += heightOffset(elapsedTime / time); |
|
|
|
|
|
|
|
transform.position = _newPos; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
IEnumerator JumpCoroutine(Block Target, Transform Current, float time, float heightMax) |
|
|
|
{ |
|
|
|