using System.Collections; using System.Collections.Generic; using UnityEngine;
public class LightTripping : MonoBehaviour { ?? ?public GameObject LightObj1, LightObj2, LightObj3, LightObj4, LightObj5, LightObj6, LightObj7, LightObj8, LightObj9; ?? ?public Light LightCon1, LightCon2, LightCon3, LightCon4, LightCon5, LightCon6, LightCon7, LightCon8, LightCon9; ?? ?public bool isopen = true; ?? ?private void Start() ?? ?{ ?? ??? ?LightCon1 = LightObj1.GetComponent<Light>(); ?? ??? ?LightCon2 = LightObj2.GetComponent<Light>(); ?? ??? ?LightCon3 = LightObj3.GetComponent<Light>(); ?? ??? ?LightCon4 = LightObj4.GetComponent<Light>(); ?? ??? ?LightCon5 = LightObj5.GetComponent<Light>(); ?? ??? ?LightCon6 = LightObj6.GetComponent<Light>(); ?? ??? ?LightCon7 = LightObj7.GetComponent<Light>(); ?? ??? ?LightCon8 = LightObj8.GetComponent<Light>(); ?? ??? ?LightCon9 = LightObj9.GetComponent<Light>(); ?? ?} ?? ?private void OnMouseDown() ?? ?{
?? ??? ?Invoke("Change", Random.Range(2,6)); ?? ?}
?? ?private void Change() ?? ?{ ?? ??? ?isopen = !isopen; ?? ??? ?LightCon1.enabled = isopen; ?? ??? ?LightCon2.enabled = isopen; ?? ??? ?LightCon3.enabled = isopen; ?? ??? ?LightCon4.enabled = isopen; ?? ??? ?LightCon5.enabled = isopen; ?? ??? ?LightCon6.enabled = isopen; ?? ??? ?LightCon7.enabled = isopen; ?? ??? ?LightCon8.enabled = isopen; ?? ??? ?LightCon9.enabled = isopen; ?? ?} }
|