diff --git a/IronToad_UnityProject/Assets/Scripts/AlertController.cs b/IronToad_UnityProject/Assets/Scripts/AlertController.cs index 4b17bbb..0054caa 100644 --- a/IronToad_UnityProject/Assets/Scripts/AlertController.cs +++ b/IronToad_UnityProject/Assets/Scripts/AlertController.cs @@ -42,6 +42,7 @@ public class AlertController : MonoBehaviour }).setOnComplete(()=>{ NotificationServer.notify("hide AlertTimer"); NotificationServer.notify("statechange Searchlight returning"); + NotificationServer.notify("statechange Searchlight"); text.text = "hidden..."; LeanTween.delayedCall(text.gameObject, 2f, ()=>{ diff --git a/IronToad_UnityProject/Assets/Scripts/AudioController.cs b/IronToad_UnityProject/Assets/Scripts/AudioController.cs index dbee699..cc422a7 100644 --- a/IronToad_UnityProject/Assets/Scripts/AudioController.cs +++ b/IronToad_UnityProject/Assets/Scripts/AudioController.cs @@ -15,6 +15,8 @@ public class AudioController : MonoBehaviour public AudioClip[] ambClips; public AudioClip[] sfxClips; + private Searchlight.SearchState searchState; + void Awake() { NotificationServer.register("play bgm", playBgm); @@ -57,6 +59,9 @@ public class AudioController : MonoBehaviour public void searchlightStateChanged() { + if (searchState == Searchlight.state) + return; + searchState = Searchlight.state; if (Searchlight.state == Searchlight.SearchState.Chasing) { NotificationServer.notify("play sfx", "spottedDialogue:0.9"); diff --git a/IronToad_UnityProject/Assets/Scripts/Catapult.cs b/IronToad_UnityProject/Assets/Scripts/Catapult.cs index 92ebc73..e47d900 100644 --- a/IronToad_UnityProject/Assets/Scripts/Catapult.cs +++ b/IronToad_UnityProject/Assets/Scripts/Catapult.cs @@ -26,6 +26,8 @@ public class Catapult : MonoBehaviour private Collider boulderCollider; private ParticleSystem boulderParticleSystem; + private Searchlight.SearchState searchState; + void Start () { splineCursor = splineCurve.GetComponent(); @@ -51,6 +53,9 @@ public class Catapult : MonoBehaviour public void searchlightStateChanged() { + if (searchState == Searchlight.state) + return; + searchState = Searchlight.state; LeanTween.cancel(splineObjectTranslate.ObjectToManipulate.gameObject, true); if (Searchlight.state == Searchlight.SearchState.Chasing) launchBoulder(); diff --git a/IronToad_UnityProject/Assets/Scripts/LightBeam.cs b/IronToad_UnityProject/Assets/Scripts/LightBeam.cs index 9c61b15..ef13401 100644 --- a/IronToad_UnityProject/Assets/Scripts/LightBeam.cs +++ b/IronToad_UnityProject/Assets/Scripts/LightBeam.cs @@ -7,6 +7,8 @@ public class LightBeam : MonoBehaviour { public Transform target; public Transform lightBeam; + private Searchlight.SearchState searchState; + // Use this for initialization void Start () { NotificationServer.register("statechange Searchlight", toggleState); @@ -22,6 +24,9 @@ public class LightBeam : MonoBehaviour { } private void toggleState() { + if (searchState == Searchlight.state) + return; + searchState = Searchlight.state; GetComponent().SetBool("isSeen", (Searchlight.state == Searchlight.SearchState.Chasing)); } diff --git a/IronToad_UnityProject/Assets/Scripts/Lighthouse.cs b/IronToad_UnityProject/Assets/Scripts/Lighthouse.cs index 0b1648c..5532ecf 100644 --- a/IronToad_UnityProject/Assets/Scripts/Lighthouse.cs +++ b/IronToad_UnityProject/Assets/Scripts/Lighthouse.cs @@ -19,6 +19,7 @@ public class Lighthouse : MonoBehaviour private int targetPoint = 0; private bool reverseDirection = false; private bool midpoint = false; + private Searchlight.SearchState searchState; void Start() { @@ -38,6 +39,7 @@ public class Lighthouse : MonoBehaviour splineDistantPoints.Add(splineCursor.Math.GetDistance()); } splineCursor.Distance = 0f; + searchState = Searchlight.SearchState.Spline; moveToNextPoint(); NotificationServer.register("statechange Searchlight", searchlightStateChanged); @@ -80,6 +82,9 @@ public class Lighthouse : MonoBehaviour public void searchlightStateChanged() { + if (searchState == Searchlight.state) + return; + searchState = Searchlight.state; LeanTween.cancel(gameObject, false); if (Searchlight.state == Searchlight.SearchState.Chasing) { @@ -116,6 +121,7 @@ public class Lighthouse : MonoBehaviour reverseDirection = false; targetPoint = 0; splineObjectTranslate.ObjectToManipulate.position = splineCursor.CalculatePosition(); + searchState = Searchlight.SearchState.Spline; moveToNextPoint(); NotificationServer.notify("statechange Searchlight safe"); } diff --git a/IronToad_UnityProject/Assets/Scripts/LighthouseLanding.cs b/IronToad_UnityProject/Assets/Scripts/LighthouseLanding.cs index 6c6a007..f4d2e23 100644 --- a/IronToad_UnityProject/Assets/Scripts/LighthouseLanding.cs +++ b/IronToad_UnityProject/Assets/Scripts/LighthouseLanding.cs @@ -8,6 +8,7 @@ public class LighthouseLanding : MonoBehaviour private bool isTriggering = false; + private Searchlight.SearchState searchState; static private Transform lastTriggered; void Awake() @@ -48,6 +49,10 @@ public class LighthouseLanding : MonoBehaviour void searchlightStateChanged() { + if (searchState == Searchlight.state) + return; + searchState = Searchlight.state; + if (switchedOff) return; if (isTriggering && Searchlight.state == Searchlight.SearchState.Chasing) diff --git a/IronToad_UnityProject/Assets/Scripts/ScreenEffects.cs b/IronToad_UnityProject/Assets/Scripts/ScreenEffects.cs index 475973f..337f333 100644 --- a/IronToad_UnityProject/Assets/Scripts/ScreenEffects.cs +++ b/IronToad_UnityProject/Assets/Scripts/ScreenEffects.cs @@ -8,7 +8,9 @@ public class ScreenEffects : MonoBehaviour public DepthOfField depthOfField; public float strength = 0f; public CanvasGroup flashCanvas; + public float alertFlashAlpha = 0f; + private float baseFlashAlpha; private float originalNearRadius; private float originalFarRadius; @@ -25,6 +27,7 @@ public class ScreenEffects : MonoBehaviour NotificationServer.register("show GameUI", showGame); NotificationServer.register("hide GameUI", hideGame); NotificationServer.register("flash damage", flashDamage); + NotificationServer.register("statechange Searchlight", searchlightStateChanged); } public void showGame() @@ -40,6 +43,12 @@ public class ScreenEffects : MonoBehaviour if (strength == 0f) depthOfField.enabled = false; }).setIgnoreTimeScale(true); + + float target = 0f; + if (Searchlight.state == Searchlight.SearchState.Chasing) + target = alertFlashAlpha; + LeanTween.cancel(flashID); + flashID = LeanTween.alphaCanvas(flashCanvas, target, 0.5f).setEaseInOutCubic().setIgnoreTimeScale(true).uniqueId; } public void hideGame() @@ -59,7 +68,19 @@ public class ScreenEffects : MonoBehaviour { LeanTween.cancel(flashID); flashID = LeanTween.alphaCanvas(flashCanvas, 1f, 0.2f).setEaseInOutCubic().setOnComplete(()=>{ - LeanTween.alphaCanvas(flashCanvas, 0f, 0.6f).setEaseInOutCubic(); + float target = 0f; + if (Searchlight.state == Searchlight.SearchState.Chasing) + target = alertFlashAlpha; + flashID = LeanTween.alphaCanvas(flashCanvas, target, 0.8f).setEaseInOutCubic().uniqueId; }).uniqueId; } + + public void searchlightStateChanged() + { + float target = 0f; + if (Searchlight.state == Searchlight.SearchState.Chasing) + target = alertFlashAlpha; + LeanTween.cancel(flashID); + flashID = LeanTween.alphaCanvas(flashCanvas, target, 0.5f).setEaseInOutCubic().uniqueId; + } } diff --git a/IronToad_UnityProject/Assets/Scripts/Searchlight.cs b/IronToad_UnityProject/Assets/Scripts/Searchlight.cs index f83985b..e419ddc 100644 --- a/IronToad_UnityProject/Assets/Scripts/Searchlight.cs +++ b/IronToad_UnityProject/Assets/Scripts/Searchlight.cs @@ -24,6 +24,8 @@ public class Searchlight : MonoBehaviour public static bool playerHidden = false; + private int chaseID; + private static List instants = new List(); public static bool isTriggeringAtLeastOne() @@ -78,46 +80,39 @@ public class Searchlight : MonoBehaviour public void stateSafe() { state = SearchState.Spline; -// NotificationServer.notify("statechange Searchlight"); + LeanTween.cancel(chaseID, false); } public void stateReturning() { 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() { 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() { if (isTriggering) { - LeanTween.delayedCall(gameObject, timeBetweenChase, chase); + chaseID = LeanTween.delayedCall(gameObject, timeBetweenChase, chase).uniqueId; } else { - LeanTween.delayedCall(gameObject, timeBetweenChase, ()=>{ + chaseID = LeanTween.delayedCall(gameObject, timeBetweenChase, ()=>{ Vector3 start = transform.position; Vector3 end = chased.transform.position + Vector3.right * Random.Range(-randomFactor, randomFactor) + Vector3.forward * Random.Range(-randomFactor, randomFactor); 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; - }).setEase(animationCurve).setOnComplete(chase); - }); + }).setEase(animationCurve).setOnComplete(chase).uniqueId; + }).uniqueId; } } } diff --git a/IronToad_UnityProject/Assets/_Scenes/IGDA_Lighthouse.unity b/IronToad_UnityProject/Assets/_Scenes/IGDA_Lighthouse.unity index 448308d..5b0f5ad 100644 Binary files a/IronToad_UnityProject/Assets/_Scenes/IGDA_Lighthouse.unity and b/IronToad_UnityProject/Assets/_Scenes/IGDA_Lighthouse.unity differ diff --git a/IronToad_UnityProject/ProjectSettings/GraphicsSettings.asset b/IronToad_UnityProject/ProjectSettings/GraphicsSettings.asset index 3dbd62f..5bbdb35 100644 Binary files a/IronToad_UnityProject/ProjectSettings/GraphicsSettings.asset and b/IronToad_UnityProject/ProjectSettings/GraphicsSettings.asset differ