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

public class StatusButtons : MonoBehaviour
{

    // Populate this array in the Unity Inspector window
    // to contain the sprites you want to switch between.
    public Sprite OnSprite;
    public Sprite OffSprite;
   // public GameObject LED;

    public bool IsOn = false;

    SpriteRenderer _spriteRenderer;

    // Use this for initialization
    void Start()
    {
        // Cache a reference to this component so we don't
        // need to look it up every time we want to use it.
        _spriteRenderer = GetComponent<SpriteRenderer>();
    }

    public void changeState(bool newState)
    {
        if (newState != IsOn)
        {
            IsOn = newState;
            _spriteRenderer.sprite = (IsOn ? OnSprite : OffSprite);
        }
    }

    private void OnMouseOver() {     
        changeState(true);
    }

    private void OnMouseExit() { 
         changeState(false);
    }

    private void OnMouseDown()
    {
        changeState(!IsOn);
       
        ///LED.GetComponentInChildren<LEDscript>().changeState(!LED.GetComponentInChildren<LEDscript>().IsOn);
    }
}
