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

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

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

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


Loading…
Cancel
Save