using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[RequireComponent(typeof(RopeAttachPoint))]
public class Tower : MonoBehaviour {
    public float power = 0;
    public Light light;
    private RopeAttachPoint me;

    void Start() {
        me = GetComponent<RopeAttachPoint>();
    }

    // Update is called once per frame
    void Update () {
        light.enabled = false;
        foreach( GameObject obj in me.GetConnections() ) {
            Generator generator = obj.GetComponent<Generator>();
            if ( generator != null ) {
                if ( generator.power > 2 ) {
                    generator.power -= 2;
                    light.enabled = true;
                }
            }
        }
    }
}
