|
|
@ -124,14 +124,18 @@ namespace GWConquest |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void MoveToZone(Zone target, float lengthFactor = 1f) |
|
|
|
public void MoveToZone(Zone target) |
|
|
|
{ |
|
|
|
if(entity.IsOwner && !state.IsInTransit) |
|
|
|
{ |
|
|
|
state.CurrentTransition.OriginZone = Zone.GetZoneId(currentZone); |
|
|
|
state.CurrentTransition.TargetZone = Zone.GetZoneId(target); |
|
|
|
bool isGroundTransition = target.zoneType == ZoneType.Ground; |
|
|
|
float lengthFactor = isGroundTransition ? GameManager.Instance.GroundTransitionLengthFactor : GameManager.Instance.SpaceTransitionLengthFactor; |
|
|
|
state.CurrentTransition.TransitionLength |
|
|
|
= Vector3.Distance(currentZone.transform.position, target.transform.position) * lengthFactor; |
|
|
|
state.CurrentTransition.IsCurved = isGroundTransition; |
|
|
|
|
|
|
|
CoveredDistance = 0; |
|
|
|
currentZone = null; |
|
|
|
state.IsInTransit = true; |
|
|
@ -196,12 +200,28 @@ namespace GWConquest |
|
|
|
animDistanceCovered += movementSpeed * Time.deltaTime; |
|
|
|
Zone originZone = Zone.GetFromId(state.CurrentTransition.OriginZone); |
|
|
|
Zone targetZone = Zone.GetFromId(state.CurrentTransition.TargetZone); |
|
|
|
Vector3 newPos = Vector3.Lerp(originZone.transform.position, |
|
|
|
targetZone.transform.position, |
|
|
|
animDistanceCovered / state.CurrentTransition.TransitionLength); |
|
|
|
Vector3 oldPos = transform.position; |
|
|
|
Vector3 newPos; |
|
|
|
if(state.CurrentTransition.IsCurved) |
|
|
|
{ |
|
|
|
|
|
|
|
Vector3 planetPos = targetZone.planet.transform.position; |
|
|
|
Vector3 originPos = originZone.transform.position - planetPos; |
|
|
|
Vector3 targetPos = targetZone.transform.position - planetPos; |
|
|
|
newPos = Vector3.Slerp(originPos, targetPos, |
|
|
|
animDistanceCovered / state.CurrentTransition.TransitionLength); |
|
|
|
newPos += planetPos; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
newPos = Vector3.Lerp(originZone.transform.position, |
|
|
|
targetZone.transform.position, |
|
|
|
animDistanceCovered / state.CurrentTransition.TransitionLength); |
|
|
|
} |
|
|
|
|
|
|
|
transform.position = newPos; |
|
|
|
transform.rotation = Quaternion.FromToRotation(Vector3.forward, |
|
|
|
targetZone.transform.position - originZone.transform.position); |
|
|
|
newPos - oldPos); |
|
|
|
|
|
|
|
} |
|
|
|
else if(currentZone != null) |
|
|
|