|
|
@ -24,6 +24,8 @@ public class Searchlight : MonoBehaviour |
|
|
|
|
|
|
|
public static bool playerHidden = false; |
|
|
|
|
|
|
|
private int chaseID; |
|
|
|
|
|
|
|
private static List<Searchlight> instants = new List<Searchlight>(); |
|
|
|
|
|
|
|
public static bool isTriggeringAtLeastOne() |
|
|
@ -78,46 +80,39 @@ public class Searchlight : MonoBehaviour |
|
|
|
public void stateSafe() |
|
|
|
{ |
|
|
|
state = SearchState.Spline; |
|
|
|
// NotificationServer.notify("statechange Searchlight");
|
|
|
|
LeanTween.cancel(chaseID, false); |
|
|
|
} |
|
|
|
|
|
|
|
public void stateReturning() |
|
|
|
{ |
|
|
|
state = SearchState.Returning; |
|
|
|
NotificationServer.notify("statechange Searchlight"); |
|
|
|
} |
|
|
|
|
|
|
|
public void stateChanged() |
|
|
|
{ |
|
|
|
LeanTween.cancel(gameObject, false); |
|
|
|
// if (state == SearchState.Chasing)
|
|
|
|
// LeanTween.move(gameObject, chased.transform.position, 0.5f).setEase(animationCurve).setOnComplete(chase);
|
|
|
|
LeanTween.cancel(chaseID, false); |
|
|
|
} |
|
|
|
|
|
|
|
public void spottedBoat() |
|
|
|
{ |
|
|
|
isTriggering = true; |
|
|
|
LeanTween.move(gameObject, chased.transform.position, 0.5f).setEase(animationCurve).setOnComplete(chase); |
|
|
|
chaseID = LeanTween.move(gameObject, chased.transform.position, 0.5f).setEase(animationCurve).setOnComplete(chase).uniqueId; |
|
|
|
} |
|
|
|
|
|
|
|
public void chase() |
|
|
|
{ |
|
|
|
if (isTriggering) |
|
|
|
{ |
|
|
|
LeanTween.delayedCall(gameObject, timeBetweenChase, chase); |
|
|
|
chaseID = LeanTween.delayedCall(gameObject, timeBetweenChase, chase).uniqueId; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
LeanTween.delayedCall(gameObject, timeBetweenChase, ()=>{ |
|
|
|
chaseID = LeanTween.delayedCall(gameObject, timeBetweenChase, ()=>{ |
|
|
|
Vector3 start = transform.position; |
|
|
|
Vector3 end = chased.transform.position |
|
|
|
+ Vector3.right * Random.Range(-randomFactor, randomFactor) |
|
|
|
+ Vector3.forward * Random.Range(-randomFactor, randomFactor); |
|
|
|
float distance = (end - start).magnitude; |
|
|
|
LeanTween.value(gameObject, 0f, 1f, distance / speed + timePadding).setOnUpdate((float val)=>{ |
|
|
|
chaseID = LeanTween.value(gameObject, 0f, 1f, distance / speed + timePadding).setOnUpdate((float val)=>{ |
|
|
|
transform.position = start + (end-start)*val; |
|
|
|
}).setEase(animationCurve).setOnComplete(chase); |
|
|
|
}); |
|
|
|
}).setEase(animationCurve).setOnComplete(chase).uniqueId; |
|
|
|
}).uniqueId; |
|
|
|
} |
|
|
|
} |
|
|
|
} |