Browse Source

fixed catapult behavior

master
KG 7 years ago
parent
commit
c555d95d14
3 changed files with 20 additions and 2 deletions
  1. +15
    -0
      IronToad_UnityProject/Assets/Scripts/Catapult.cs
  2. +5
    -2
      IronToad_UnityProject/Assets/Scripts/LightBeam.cs
  3. BIN
      IronToad_UnityProject/Assets/_Scenes/IGDA_Lighthouse.unity

+ 15
- 0
IronToad_UnityProject/Assets/Scripts/Catapult.cs View File

@ -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)

+ 5
- 2
IronToad_UnityProject/Assets/Scripts/LightBeam.cs View File

@ -5,7 +5,7 @@ using UnityEngine;
public class LightBeam : MonoBehaviour { public class LightBeam : MonoBehaviour {
public Transform target; public Transform target;
public Transform lightBeam;
public Transform lightBeam;
private Searchlight.SearchState searchState; private Searchlight.SearchState searchState;
@ -26,6 +26,8 @@ public class LightBeam : MonoBehaviour {
private void toggleState() { private void toggleState() {
if (searchState == Searchlight.state) if (searchState == Searchlight.state)
return; return;
if (!isActiveAndEnabled)
return;
searchState = Searchlight.state; searchState = Searchlight.state;
GetComponent<Animator>().SetBool("isSeen", (Searchlight.state == Searchlight.SearchState.Chasing)); GetComponent<Animator>().SetBool("isSeen", (Searchlight.state == Searchlight.SearchState.Chasing));
} }
@ -34,7 +36,8 @@ public class LightBeam : MonoBehaviour {
searchState = Searchlight.SearchState.Spline; searchState = Searchlight.SearchState.Spline;
lightBeam.gameObject.SetActive(true); lightBeam.gameObject.SetActive(true);
target.gameObject.SetActive(true); target.gameObject.SetActive(true);
GetComponent<Animator>().SetBool("isSeen", false);
if (isActiveAndEnabled)
GetComponent<Animator>().SetBool("isSeen", false);
} }
private void switchOff(object offObject) { private void switchOff(object offObject) {

BIN
IronToad_UnityProject/Assets/_Scenes/IGDA_Lighthouse.unity View File


Loading…
Cancel
Save