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