Files
MetalGear2D.Unity/Assets/Scripts/LampController.cs
T
2025-05-13 05:19:58 +03:00

36 lines
618 B
C#

using UnityEngine;
using System.Collections;
public class LampController : MonoBehaviour {
private Led _lamp;
public Predicate[] enablePredicates;
private bool _enabled;
public bool Enabled {
get {
return _enabled;
}
set {
_enabled = value;
}
}
// Use this for initialization
void Start () {
_lamp = GetComponentInChildren<Led>();
}
// Update is called once per frame
void Update () {
_enabled = true;
foreach(var p in enablePredicates){
if(p != null && !p.Check()){
_enabled = false;
break;
}
}
_lamp.GetComponent<SpriteRenderer>().enabled = _enabled;
}
}