This commit is contained in:
yzx 2023-12-26 13:16:56 +08:00
parent 585c819adf
commit 234b98c440
2 changed files with 1000 additions and 22 deletions

File diff suppressed because it is too large Load Diff

View File

@ -4,12 +4,14 @@ using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
public enum TrafficLightState public enum TrafficLightState
{ {
Red, Red,
Yellow, Yellow,
Green Green
} }
public class TrafficLightManager : MonoBehaviour public class TrafficLightManager : MonoBehaviour
{ {
[System.Serializable] [System.Serializable]
@ -33,7 +35,6 @@ public class TrafficLightManager : MonoBehaviour
public void UpdateTrafficLightTexture(TrafficLightState state) public void UpdateTrafficLightTexture(TrafficLightState state)
{ {
Debug.Log("123"); Debug.Log("123");
foreach (var light in trafficLights) foreach (var light in trafficLights)
@ -60,6 +61,7 @@ foreach (var light in trafficLights)
light.transform.Find("red2").GetComponent<MeshRenderer>().material.EnableKeyword("_EMISSION"); light.transform.Find("red2").GetComponent<MeshRenderer>().material.EnableKeyword("_EMISSION");
} }
} }
break; break;
case TrafficLightState.Yellow: case TrafficLightState.Yellow:
foreach (var light in trafficLights) foreach (var light in trafficLights)
@ -71,6 +73,7 @@ foreach (var light in trafficLights)
light.transform.Find("yellow1").GetComponent<MeshRenderer>().material.EnableKeyword("_EMISSION"); light.transform.Find("yellow1").GetComponent<MeshRenderer>().material.EnableKeyword("_EMISSION");
} }
} }
break; break;
case TrafficLightState.Green: case TrafficLightState.Green:
foreach (var light in trafficLights) foreach (var light in trafficLights)
@ -82,11 +85,11 @@ foreach (var light in trafficLights)
light.transform.Find("green2").GetComponent<MeshRenderer>().material.EnableKeyword("_EMISSION"); light.transform.Find("green2").GetComponent<MeshRenderer>().material.EnableKeyword("_EMISSION");
} }
} }
break; break;
default: default:
throw new ArgumentOutOfRangeException(nameof(state), state, null); throw new ArgumentOutOfRangeException(nameof(state), state, null);
} }
} }
// private Texture GetTextureForState(TrafficLightState state) // private Texture GetTextureForState(TrafficLightState state)
@ -105,7 +108,6 @@ foreach (var light in trafficLights)
{ {
group.Initialize(); group.Initialize();
} }
} }
@ -157,9 +159,6 @@ foreach (var light in trafficLights)
} }
void UpdateLights(List<TMP_Text> lights, string state, float time) void UpdateLights(List<TMP_Text> lights, string state, float time)
{ {
int timeInt = Mathf.CeilToInt(time); int timeInt = Mathf.CeilToInt(time);