|
@ -25,6 +25,7 @@ public class Catapult : MonoBehaviour |
|
|
private MeshRenderer meshRenderer; |
|
|
private MeshRenderer meshRenderer; |
|
|
private Collider boulderCollider; |
|
|
private Collider boulderCollider; |
|
|
private ParticleSystem boulderParticleSystem; |
|
|
private ParticleSystem boulderParticleSystem; |
|
|
|
|
|
private bool switchedOff = false; |
|
|
|
|
|
|
|
|
private Searchlight.SearchState searchState; |
|
|
private Searchlight.SearchState searchState; |
|
|
|
|
|
|
|
@ -37,6 +38,7 @@ public class Catapult : MonoBehaviour |
|
|
boulderParticleSystem = splineObjectTranslate.ObjectToManipulate.GetComponentInChildren<ParticleSystem>(); |
|
|
boulderParticleSystem = splineObjectTranslate.ObjectToManipulate.GetComponentInChildren<ParticleSystem>(); |
|
|
meshRenderer.enabled = false; |
|
|
meshRenderer.enabled = false; |
|
|
boulderCollider.enabled = false; |
|
|
boulderCollider.enabled = false; |
|
|
|
|
|
switchedOff = false; |
|
|
boulderParticleSystem.Stop(); |
|
|
boulderParticleSystem.Stop(); |
|
|
|
|
|
|
|
|
originalScale = splineCurve.transform.parent.localScale; |
|
|
originalScale = splineCurve.transform.parent.localScale; |
|
@ -44,6 +46,7 @@ public class Catapult : MonoBehaviour |
|
|
NotificationServer.register("statechange Searchlight", searchlightStateChanged); |
|
|
NotificationServer.register("statechange Searchlight", searchlightStateChanged); |
|
|
NotificationServer.register("BoulderHit", boulderHit); |
|
|
NotificationServer.register("BoulderHit", boulderHit); |
|
|
NotificationServer.register("restart scene", restartScene); |
|
|
NotificationServer.register("restart scene", restartScene); |
|
|
|
|
|
NotificationServer.register("switch off", switchOff); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void Update() |
|
|
void Update() |
|
@ -55,6 +58,10 @@ public class Catapult : MonoBehaviour |
|
|
{ |
|
|
{ |
|
|
if (searchState == Searchlight.state) |
|
|
if (searchState == Searchlight.state) |
|
|
return; |
|
|
return; |
|
|
|
|
|
if (switchedOff) |
|
|
|
|
|
return; |
|
|
|
|
|
if (!isActiveAndEnabled) |
|
|
|
|
|
return; |
|
|
searchState = Searchlight.state; |
|
|
searchState = Searchlight.state; |
|
|
LeanTween.cancel(splineObjectTranslate.ObjectToManipulate.gameObject, true); |
|
|
LeanTween.cancel(splineObjectTranslate.ObjectToManipulate.gameObject, true); |
|
|
if (Searchlight.state == Searchlight.SearchState.Chasing) |
|
|
if (Searchlight.state == Searchlight.SearchState.Chasing) |
|
@ -70,10 +77,18 @@ public class Catapult : MonoBehaviour |
|
|
|
|
|
|
|
|
public void restartScene() |
|
|
public void restartScene() |
|
|
{ |
|
|
{ |
|
|
|
|
|
switchedOff = false; |
|
|
searchState = Searchlight.SearchState.Spline; |
|
|
searchState = Searchlight.SearchState.Spline; |
|
|
LeanTween.cancel(splineObjectTranslate.ObjectToManipulate.gameObject, true); |
|
|
LeanTween.cancel(splineObjectTranslate.ObjectToManipulate.gameObject, true); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void switchOff(object offObject) { |
|
|
|
|
|
GameObject offGO = offObject as GameObject; |
|
|
|
|
|
// Debug.LogWarning(offGO + " vs " + transform.parent.gameObject);
|
|
|
|
|
|
if (offGO == transform.parent.gameObject) |
|
|
|
|
|
switchedOff = true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public void launchBoulder() |
|
|
public void launchBoulder() |
|
|
{ |
|
|
{ |
|
|
if (Searchlight.state != Searchlight.SearchState.Chasing || isLaunching) |
|
|
if (Searchlight.state != Searchlight.SearchState.Chasing || isLaunching) |
|
|