*
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user