organize scripts

This commit is contained in:
2026-05-05 21:01:16 -05:00
parent f4be1941d3
commit 343a27936c
18 changed files with 16 additions and 0 deletions
@@ -0,0 +1,31 @@
using System;
using System.Linq;
using UnityEngine;
public class Streetlight : MonoBehaviour
{
// Hours that the light starts and ends
public int[] activeHours = { 18, 19, 20, 21, 22, 23, 0, 1, 2, 3, 4, 5, 6 };
Light objectLight;
private float lightIntensity;
void Start()
{
objectLight = GetComponent<Light>();
lightIntensity = objectLight.intensity;
}
// Update is called once per frame
void Update()
{
if (activeHours.Contains(GameManager.Instance.TimeManager.GetCurrentHour()))
{
objectLight.intensity = lightIntensity;
}
else
{
objectLight.intensity = 0;
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 67529f5a831c7b240bc979c3bd269016
+33
View File
@@ -0,0 +1,33 @@
using UnityEngine;
public class Tnt : MonoBehaviour
{
public Light explodeLight;
public ParticleSystem explodeParticle;
public float fuseTime;
public float explosionLengthTime;
float timer = 0;
private bool exploded = false;
void Update()
{
timer += Time.deltaTime;
if (!exploded && timer > fuseTime)
{
exploded = true;
explodeLight.gameObject.SetActive(true);
explodeLight.transform.parent = null;
explodeParticle.gameObject.SetActive(true);
explodeParticle.transform.parent = null;
explodeParticle.transform.localScale = new Vector3(0.05f, 0.05f, 0.05f);
explodeParticle.Play();
Destroy(explodeLight.gameObject, explosionLengthTime);
Destroy(explodeParticle.gameObject, explosionLengthTime);
Destroy(gameObject);
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: f876d4c98cbd6c8499fa411ab2468058