fix:风机初始化代码提交

This commit is contained in:
zhangjiajia
2026-05-20 17:05:47 +08:00
parent 8510a3dcda
commit 9579356ed1
3752 changed files with 1351544 additions and 1 deletions

View File

@@ -0,0 +1,76 @@
using Enviro;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using static UnityEngine.Rendering.DebugUI.Table;
public class LightManager : MonoBehaviour
{
public enum SwitchCondition { turnON,turnOFF};
SwitchCondition currentCondition;
SwitchCondition lightCondition;
private List<Light> streetLightingAndAutomativeLighting;
// Start is called before the first frame update
void Start()
{
var streetLightings=GameObject.FindGameObjectsWithTag("StreetLighting");
var automativeLightings = GameObject.FindGameObjectsWithTag("AutomativeLighting");
streetLightingAndAutomativeLighting = new List<Light>();
for (int i = 0; i < streetLightings.Length; i++)
{
streetLightingAndAutomativeLighting.Add(streetLightings[i].GetComponent<Light>());
}
for (int i = 0; i < automativeLightings.Length; i++)
{
streetLightingAndAutomativeLighting.Add(automativeLightings[i].GetComponent<Light>());
}
UpdateLight();
}
// Update is called once per frame
void Update()
{
//System.DateTime now = System.DateTime.Now;
int hour = Enviro.EnviroManager.instance.Time.hours;
if (hour >= 6 && hour <= 18)
{
currentCondition = SwitchCondition.turnOFF;
}
else
{
currentCondition = SwitchCondition.turnON;
}
if (currentCondition != lightCondition)
{
UpdateLight();
}
}
void UpdateLight()
{
int hour = Enviro.EnviroManager.instance.Time.hours;
//System.DateTime now = System.DateTime.Now;
if (hour >= 6 && hour <= 18)//°×Ìì
{
lightCondition = SwitchCondition.turnOFF;
foreach (var light in streetLightingAndAutomativeLighting)
{
light.enabled = false;
}
}
else//ÍíÉÏ
{
lightCondition = SwitchCondition.turnON;
foreach (var light in streetLightingAndAutomativeLighting)
{
light.enabled = true;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 826a15849d68a714f8520ec9a1584c39
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: