Advertisement
evelynshilosky

VIllageLampSystem - Part 37

Apr 18th, 2024
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class VillageLampSystem : MonoBehaviour
  6. {
  7.     public int timeLampsTurnOn;
  8.     public int timeLampsTurnOff;
  9.  
  10.     public bool lampsAreOn;
  11.  
  12.     public DayNightSystem DayNightSystem;
  13.  
  14.     private void Update()
  15.     {
  16.         if (DayNightSystem.currentHour == timeLampsTurnOn && lampsAreOn == false)
  17.         {
  18.             foreach (Transform child in transform)
  19.             {
  20.                 child.GetComponent<Light>().enabled = true;
  21.             }
  22.  
  23.             lampsAreOn = true;
  24.         }
  25.  
  26.         if (DayNightSystem.currentHour == timeLampsTurnOff && lampsAreOn == true)
  27.         {
  28.             foreach (Transform child in transform)
  29.             {
  30.                 child.GetComponent<Light>().enabled = false;
  31.             }
  32.  
  33.             lampsAreOn = false;
  34.         }
  35.     }
  36.  
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement