From 2e370ec2f004e9efd87bcd21bf8ad60498b58e4d Mon Sep 17 00:00:00 2001 From: Joshua Reason Date: Sun, 22 Jan 2017 15:32:55 +1100 Subject: [PATCH] added restart script --- IronToad_UnityProject/Assets/Scripts/LightBeam.cs | 6 ++++++ .../Assets/Scripts/LighthouseLanding.cs | 3 ++- .../Assets/Scripts/PlayerController.cs | 11 +++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/IronToad_UnityProject/Assets/Scripts/LightBeam.cs b/IronToad_UnityProject/Assets/Scripts/LightBeam.cs index 6340672..3138f02 100644 --- a/IronToad_UnityProject/Assets/Scripts/LightBeam.cs +++ b/IronToad_UnityProject/Assets/Scripts/LightBeam.cs @@ -10,6 +10,7 @@ public class LightBeam : MonoBehaviour { // Use this for initialization void Start () { NotificationServer.register("statechange Searchlight", toggleState); + NotificationServer.register("switch off", switchOff); } // Update is called once per frame @@ -26,4 +27,9 @@ public class LightBeam : MonoBehaviour { private void toggleState() { GetComponent().SetBool("isSeen", (Searchlight.state == Searchlight.SearchState.Chasing)); } + + private void switchOff() { + lightBeam.gameObject.SetActive(false); + target.gameObject.SetActive(false); + } } diff --git a/IronToad_UnityProject/Assets/Scripts/LighthouseLanding.cs b/IronToad_UnityProject/Assets/Scripts/LighthouseLanding.cs index 80827a0..2ae4601 100644 --- a/IronToad_UnityProject/Assets/Scripts/LighthouseLanding.cs +++ b/IronToad_UnityProject/Assets/Scripts/LighthouseLanding.cs @@ -57,5 +57,6 @@ public class LighthouseLanding : MonoBehaviour switchedOff = true; NotificationServer.notify("hide TakeoverButton"); NotificationServer.notify("play sfx", "assassination"); - } + NotificationServer.notify("switch off"); + } } diff --git a/IronToad_UnityProject/Assets/Scripts/PlayerController.cs b/IronToad_UnityProject/Assets/Scripts/PlayerController.cs index 4327d9a..fc0a178 100644 --- a/IronToad_UnityProject/Assets/Scripts/PlayerController.cs +++ b/IronToad_UnityProject/Assets/Scripts/PlayerController.cs @@ -19,12 +19,17 @@ public class PlayerController : MonoBehaviour { public GameObject[] lifeHearts; + private Vector3 startPoint; + public GameObject boat; + + void Start() { NotificationServer.register("show GameUI", showGameUI); NotificationServer.register("hide GameUI", hideGameUI); instance = this; + startPoint = boat.transform.position; } @@ -83,4 +88,10 @@ public class PlayerController : MonoBehaviour { isLocked = true; } + public void restartScene() { + setLife(3); + boat.transform.position = startPoint; + boat.GetComponent().velocity = Vector3.zero; + } + }