Commit 3629c83f authored by Markus Schlösser's avatar Markus Schlösser

Added reset to lasers

parent 64932f68
fileFormatVersion: 2
guid: 7d76a63dfd317814d9eef925c0df39c7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 7302d929ac7a2f44180b44e09592ac8a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
...@@ -40,6 +40,5 @@ public class InteractibleLever : MonoBehaviour, IInteractible, IResetable { ...@@ -40,6 +40,5 @@ public class InteractibleLever : MonoBehaviour, IInteractible, IResetable {
public void ResetToLevelBegin() { public void ResetToLevelBegin() {
state = isActive; state = isActive;
UpdateSprite(); UpdateSprite();
} }
} }
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
using UnityEngine; using UnityEngine;
using NaughtyAttributes; using NaughtyAttributes;
public class LaserController : MonoBehaviour { public class LaserController : MonoBehaviour, IResetable {
[SerializeField] private bool isActive = true;
[SerializeField] private Sprite active; [SerializeField] private Sprite active;
[SerializeField] private Sprite inactive; [SerializeField] private Sprite inactive;
...@@ -11,6 +13,12 @@ public class LaserController : MonoBehaviour { ...@@ -11,6 +13,12 @@ public class LaserController : MonoBehaviour {
[SerializeField] private List<SpriteRenderer> laserRenderer; [SerializeField] private List<SpriteRenderer> laserRenderer;
[SerializeField] private List<Collider2D> lasercollider; [SerializeField] private List<Collider2D> lasercollider;
private bool state;
private void Awake() {
state = isActive;
}
public void SetState(bool value) { public void SetState(bool value) {
foreach (SpriteRenderer r in endpoints) { foreach (SpriteRenderer r in endpoints) {
r.sprite = value ? active : inactive; r.sprite = value ? active : inactive;
...@@ -23,14 +31,16 @@ public class LaserController : MonoBehaviour { ...@@ -23,14 +31,16 @@ public class LaserController : MonoBehaviour {
foreach (Collider2D c in lasercollider) { foreach (Collider2D c in lasercollider) {
c.enabled = value; c.enabled = value;
} }
state = value;
} }
[Button] [Button]
public void ToggleState() { public void ToggleState() {
if (laserRenderer[0] == null) return; SetState(!state);
bool state = laserRenderer[0].enabled;
SetState(!state);
} }
public void ResetToLevelBegin() {
SetState(isActive);
}
} }
...@@ -39,6 +39,5 @@ public class TimedToggle : MonoBehaviour, IResetable { ...@@ -39,6 +39,5 @@ public class TimedToggle : MonoBehaviour, IResetable {
public void ResetToLevelBegin() { public void ResetToLevelBegin() {
state = isActive; state = isActive;
time = 0; time = 0;
onStateChange.Invoke(isActive);
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment