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

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 {
public void ResetToLevelBegin() {
state = isActive;
UpdateSprite();
}
}
......@@ -2,7 +2,9 @@
using UnityEngine;
using NaughtyAttributes;
public class LaserController : MonoBehaviour {
public class LaserController : MonoBehaviour, IResetable {
[SerializeField] private bool isActive = true;
[SerializeField] private Sprite active;
[SerializeField] private Sprite inactive;
......@@ -11,6 +13,12 @@ public class LaserController : MonoBehaviour {
[SerializeField] private List<SpriteRenderer> laserRenderer;
[SerializeField] private List<Collider2D> lasercollider;
private bool state;
private void Awake() {
state = isActive;
}
public void SetState(bool value) {
foreach (SpriteRenderer r in endpoints) {
r.sprite = value ? active : inactive;
......@@ -23,14 +31,16 @@ public class LaserController : MonoBehaviour {
foreach (Collider2D c in lasercollider) {
c.enabled = value;
}
state = value;
}
[Button]
public void ToggleState() {
if (laserRenderer[0] == null) return;
bool state = laserRenderer[0].enabled;
SetState(!state);
SetState(!state);
}
public void ResetToLevelBegin() {
SetState(isActive);
}
}
......@@ -39,6 +39,5 @@ public class TimedToggle : MonoBehaviour, IResetable {
public void ResetToLevelBegin() {
state = isActive;
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