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