fix:代码提初始化
This commit is contained in:
96
Assets/Scripts/Environ3/WeatherAndTime.cs
Normal file
96
Assets/Scripts/Environ3/WeatherAndTime.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using static UnityEngine.Rendering.DebugUI.Table;
|
||||
|
||||
public class WeatherAndTime : MonoBehaviour
|
||||
{
|
||||
public GameObject Rain;
|
||||
private Coroutine updateTime;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
updateTime = StartCoroutine(setTimeEveryFrame());
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
public void Sunny()
|
||||
{
|
||||
Enviro.EnviroManager.instance.Weather.ChangeWeather("Clear Sky");
|
||||
Rain.SetActive(false);
|
||||
}
|
||||
public void Sprinkle()
|
||||
{
|
||||
Enviro.EnviroManager.instance.Weather.ChangeWeather("Rain");
|
||||
Rain.SetActive(true);
|
||||
ParticleSystem.EmissionModule emission = Rain.GetComponent<ParticleSystem>().emission;
|
||||
emission.rateOverTime = 2000f;
|
||||
}
|
||||
public void ModerateRain()
|
||||
{
|
||||
Enviro.EnviroManager.instance.Weather.ChangeWeather("Rain");
|
||||
Rain.SetActive(true);
|
||||
ParticleSystem.EmissionModule emission = Rain.GetComponent<ParticleSystem>().emission;
|
||||
emission.rateOverTime = 5000f;
|
||||
}
|
||||
public void HeavyRain()
|
||||
{
|
||||
Enviro.EnviroManager.instance.Weather.ChangeWeather("Rain");
|
||||
Rain.SetActive(true);
|
||||
ParticleSystem.EmissionModule emission = Rain.GetComponent<ParticleSystem>().emission;
|
||||
emission.rateOverTime = 10000f;
|
||||
}
|
||||
public void Storm()
|
||||
{
|
||||
Enviro.EnviroManager.instance.Weather.ChangeWeather("Storm");
|
||||
Rain.SetActive(true);
|
||||
ParticleSystem.EmissionModule emission = Rain.GetComponent<ParticleSystem>().emission;
|
||||
emission.rateOverTime = 20000f;
|
||||
}
|
||||
|
||||
public void Snow()
|
||||
{
|
||||
Enviro.EnviroManager.instance.Weather.ChangeWeather("Snow");
|
||||
Rain.SetActive(false);
|
||||
}
|
||||
public void Cloudy()
|
||||
{
|
||||
Enviro.EnviroManager.instance.Weather.ChangeWeather("Cloudy 1");
|
||||
Rain.SetActive(false);
|
||||
}
|
||||
|
||||
public void SetTime(int hour)
|
||||
{
|
||||
StopCoroutine(updateTime);
|
||||
Enviro.EnviroManager.instance.Time.hours = hour;
|
||||
}
|
||||
public void RealTime()
|
||||
{
|
||||
if (updateTime != null)
|
||||
{
|
||||
StopCoroutine(updateTime);
|
||||
}
|
||||
updateTime = StartCoroutine(setTimeEveryFrame());
|
||||
}
|
||||
IEnumerator setTimeEveryFrame()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
System.DateTime now = System.DateTime.Now;
|
||||
//string timeStr = now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
//Debug.Log(timeStr);
|
||||
Enviro.EnviroManager.instance.Time.seconds = now.Second;
|
||||
Enviro.EnviroManager.instance.Time.minutes = now.Minute;
|
||||
Enviro.EnviroManager.instance.Time.hours = now.Hour;
|
||||
Enviro.EnviroManager.instance.Time.days = now.Day;
|
||||
Enviro.EnviroManager.instance.Time.months = now.Month;
|
||||
Enviro.EnviroManager.instance.Time.years = now.Year;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Environ3/WeatherAndTime.cs.meta
Normal file
11
Assets/Scripts/Environ3/WeatherAndTime.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 17ba587f07ac49d418788609b2f72ea9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user