diff --git a/IronToad_UnityProject/Assets/Scripts/Catapult.cs b/IronToad_UnityProject/Assets/Scripts/Catapult.cs index c0353ee..92ebc73 100644 --- a/IronToad_UnityProject/Assets/Scripts/Catapult.cs +++ b/IronToad_UnityProject/Assets/Scripts/Catapult.cs @@ -23,21 +23,25 @@ public class Catapult : MonoBehaviour private BGCcCursorObjectTranslate splineObjectTranslate; private Vector3 originalScale; private MeshRenderer meshRenderer; - private ParticleSystem particleSystem; + private Collider boulderCollider; + private ParticleSystem boulderParticleSystem; void Start () { splineCursor = splineCurve.GetComponent(); splineObjectTranslate = splineCurve.GetComponent(); meshRenderer = splineObjectTranslate.ObjectToManipulate.GetComponent(); - particleSystem = splineObjectTranslate.ObjectToManipulate.GetComponentInChildren(); + boulderCollider = splineObjectTranslate.ObjectToManipulate.GetComponent(); + boulderParticleSystem = splineObjectTranslate.ObjectToManipulate.GetComponentInChildren(); meshRenderer.enabled = false; - particleSystem.Stop(); + boulderCollider.enabled = false; + boulderParticleSystem.Stop(); originalScale = splineCurve.transform.parent.localScale; NotificationServer.register("statechange Searchlight", searchlightStateChanged); NotificationServer.register("BoulderHit", boulderHit); + NotificationServer.register("restart scene", boulderHit); } void Update() @@ -72,26 +76,31 @@ public class Catapult : MonoBehaviour isLaunching = false; return; } - particleSystem.Stop(); - meshRenderer.enabled = true; + boulderParticleSystem.Stop(); splineCursor.DistanceRatio = 0f; splineCurve.transform.parent.position = player.position + Vector3.right * Random.Range(-randomFactor, randomFactor) + Vector3.forward * Random.Range(-randomFactor, randomFactor); splineCurve.transform.parent.localEulerAngles = Vector3.up * Random.Range(0f, 360f); splineCurve.transform.parent.localScale = new Vector3(Random.Range(minScale * originalScale.x, maxScale * originalScale.x), originalScale.y, originalScale.z); - particleSystem.Play(); - LeanTween.value(splineObjectTranslate.ObjectToManipulate.gameObject, 0f, 1f, splineCursor.Math.GetDistance() / speed) - .setEase(animationCurve) - .setOnUpdate((float val)=>{ - splineCursor.DistanceRatio = val; - }).setOnComplete(()=>{ - particleSystem.Stop(); -// splineCursor.DistanceRatio = 0f; - isLaunching = false; - meshRenderer.enabled = false; - launchBoulder(); - }); + LeanTween.delayedCall(splineObjectTranslate.ObjectToManipulate.gameObject, 0.1f, ()=>{ + boulderParticleSystem.Play(); + meshRenderer.enabled = true; + boulderCollider.enabled = true; + LeanTween.value(splineObjectTranslate.ObjectToManipulate.gameObject, 0f, 1f, splineCursor.Math.GetDistance() / speed) + .setEase(animationCurve) + .setOnUpdate((float val)=>{ + splineCursor.DistanceRatio = val; + }).setOnComplete(()=>{ + boulderParticleSystem.Stop(); + isLaunching = false; + meshRenderer.enabled = false; + LeanTween.delayedCall(splineObjectTranslate.ObjectToManipulate.gameObject, 0.5f, ()=>{ + boulderCollider.enabled = false; + launchBoulder(); + }); + }); + }); }); } } diff --git a/IronToad_UnityProject/Assets/Scripts/LightBeam.cs b/IronToad_UnityProject/Assets/Scripts/LightBeam.cs index 3138f02..b857d0d 100644 --- a/IronToad_UnityProject/Assets/Scripts/LightBeam.cs +++ b/IronToad_UnityProject/Assets/Scripts/LightBeam.cs @@ -11,6 +11,7 @@ public class LightBeam : MonoBehaviour { void Start () { NotificationServer.register("statechange Searchlight", toggleState); NotificationServer.register("switch off", switchOff); + NotificationServer.register("restart scene", resetState); } // Update is called once per frame @@ -18,16 +19,18 @@ public class LightBeam : MonoBehaviour { Vector3 lookAtPos = target.position; lookAtPos.y = lightBeam.position.y; lightBeam.LookAt(target); - - - - } private void toggleState() { GetComponent().SetBool("isSeen", (Searchlight.state == Searchlight.SearchState.Chasing)); } + private void resetState() { + lightBeam.gameObject.SetActive(true); + target.gameObject.SetActive(true); + GetComponent().SetBool("isSeen", false); + } + private void switchOff() { lightBeam.gameObject.SetActive(false); target.gameObject.SetActive(false); diff --git a/IronToad_UnityProject/Assets/Scripts/PlayerController.cs b/IronToad_UnityProject/Assets/Scripts/PlayerController.cs index 4566461..9a4fcae 100644 --- a/IronToad_UnityProject/Assets/Scripts/PlayerController.cs +++ b/IronToad_UnityProject/Assets/Scripts/PlayerController.cs @@ -30,7 +30,7 @@ public class PlayerController : MonoBehaviour { instance = this; startPoint = boat.transform.position; - + isLocked = true; } // Update is called once per frame @@ -73,7 +73,13 @@ public class PlayerController : MonoBehaviour { setLife(life - 1); lastDamageTime = Time.time; if (life == 0) - NotificationServer.notify("show GameOverPanel"); + { + NotificationServer.notify("fade bgm"); + NotificationServer.notify("play sfx", "shipSpotted:0.5"); + NotificationServer.notify("play sfx", "sinkingShip:0.75"); + NotificationServer.notify("show GameOverPanel"); + NotificationServer.notify("hide GameUI"); + } } } diff --git a/IronToad_UnityProject/Assets/Scripts/ScreenEffects.cs b/IronToad_UnityProject/Assets/Scripts/ScreenEffects.cs index 8537e45..8618b3c 100644 --- a/IronToad_UnityProject/Assets/Scripts/ScreenEffects.cs +++ b/IronToad_UnityProject/Assets/Scripts/ScreenEffects.cs @@ -6,6 +6,7 @@ using UnityStandardAssets.CinematicEffects; public class ScreenEffects : MonoBehaviour { public DepthOfField depthOfField; + public float strength = 0f; private float originalNearRadius; private float originalFarRadius; @@ -28,11 +29,12 @@ public class ScreenEffects : MonoBehaviour float startNear = depthOfField.focus.nearBlurRadius; float startFar = depthOfField.focus.farBlurRadius; DepthOfField.FocusSettings focus = depthOfField.focus; - LeanTween.value(gameObject, 1f, 0f, 0.5f).setEaseInOutQuad().setOnUpdate((float val)=>{ + LeanTween.value(gameObject, 1f, 1f*strength, 0.5f).setEaseInOutQuad().setOnUpdate((float val)=>{ focus.nearBlurRadius = startNear * val; focus.farBlurRadius = startFar * val; }).setOnComplete(()=>{ - depthOfField.enabled = false; + if (strength == 0f) + depthOfField.enabled = false; }).setIgnoreTimeScale(true); } @@ -43,7 +45,7 @@ public class ScreenEffects : MonoBehaviour float startNear = depthOfField.focus.nearBlurRadius; float startFar = depthOfField.focus.farBlurRadius; DepthOfField.FocusSettings focus = depthOfField.focus; - LeanTween.value(gameObject, 0f, 1f, 0.5f).setEaseInOutQuad().setOnUpdate((float val)=>{ + LeanTween.value(gameObject, 1f*strength, 1f, 0.5f).setEaseInOutQuad().setOnUpdate((float val)=>{ focus.nearBlurRadius = startNear + (originalNearRadius-startNear) * val; focus.farBlurRadius = startFar + (originalFarRadius-startFar) * val; }).setIgnoreTimeScale(true); diff --git a/IronToad_UnityProject/Assets/_Scenes/GreyBox_Prototype.unity b/IronToad_UnityProject/Assets/_Scenes/GreyBox_Prototype.unity index 8438fcd..1669bf2 100644 Binary files a/IronToad_UnityProject/Assets/_Scenes/GreyBox_Prototype.unity and b/IronToad_UnityProject/Assets/_Scenes/GreyBox_Prototype.unity differ diff --git a/IronToad_UnityProject/Assets/_Scenes/LighthouseTestScene.unity b/IronToad_UnityProject/Assets/_Scenes/LighthouseTestScene.unity index a51988c..0dbefaf 100644 Binary files a/IronToad_UnityProject/Assets/_Scenes/LighthouseTestScene.unity and b/IronToad_UnityProject/Assets/_Scenes/LighthouseTestScene.unity differ