using UnityEngine;

public class ButtonPupitre : Button {

    private static Transform LampePhare = null;
    private static GameObject DessinCascade = null;
    public int VitessePhare = 2;

    protected override void Start(){
        base.Start();
        if (LampePhare == null && Application.loadedLevelName == "MainScene_2") {
            LampePhare = GameObject.Find("LampePhare").transform;
        }
        if (DessinCascade == null && Application.loadedLevelName == "MainScene_2")
        {
            DessinCascade = GameObject.Find("DessinCascade");
            DessinCascade.SetActive(false);
        }
    }

    protected override void DoAction() {
        base.DoAction();
        Interupt.CheckElectricity(); // Affiche message si pas electricite

        if (Application.loadedLevelName == "MainScene_2") {
            if (Interupt.thereIsElectricity && gameObject.name == "BoutonPupitreGauche") {
                LampePhare.Rotate(Vector3.down * Time.deltaTime * VitessePhare);
            }
            if (Interupt.thereIsElectricity && gameObject.name == "BoutonPupitreDroit") {
                LampePhare.Rotate(Vector3.up * Time.deltaTime * VitessePhare);
            }
            if (LampePhare.localEulerAngles.y > 60 && LampePhare.eulerAngles.y < 65 && Interupt.Allume) {
                DessinCascade.SetActive(true);
            } else {
                DessinCascade.SetActive(false);
            }
        }
    }
}