organize scripts
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user