add weather and time
This commit is contained in:
8
Assets/Scripts/AudioManage.meta
Normal file
8
Assets/Scripts/AudioManage.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 500eaa2b56c2c074ab576689486fd19f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
57
Assets/Scripts/AudioManage/Mute.cs
Normal file
57
Assets/Scripts/AudioManage/Mute.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Mute : MonoBehaviour
|
||||
{
|
||||
Camera cam;
|
||||
|
||||
|
||||
|
||||
public GameObject Audio;
|
||||
private List<AudioSource> waterAudioList = new List<AudioSource>();
|
||||
public AudioSource waterfall1;
|
||||
public AudioSource waterfall2;
|
||||
public AudioSource waterfall3;
|
||||
public AudioSource waterfall4;
|
||||
public AudioSource waterfall5;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
cam = Camera.main;
|
||||
|
||||
Audio = GameObject.Find("Enviro 3/Audio");
|
||||
|
||||
waterAudioList.Add(waterfall1);
|
||||
waterAudioList.Add(waterfall2);
|
||||
waterAudioList.Add(waterfall3);
|
||||
waterAudioList.Add(waterfall4);
|
||||
waterAudioList.Add(waterfall5);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
public void GlobalMute()
|
||||
{
|
||||
|
||||
Audio.SetActive(false);
|
||||
foreach(var audio in waterAudioList)
|
||||
{
|
||||
audio.enabled = false;
|
||||
}
|
||||
//Audio.SetActive(false);
|
||||
}
|
||||
public void UnMute()
|
||||
{
|
||||
Audio.SetActive(true);
|
||||
foreach (var audio in waterAudioList)
|
||||
{
|
||||
audio.enabled = true;
|
||||
}
|
||||
//Audio.SetActive(true);
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Scripts/AudioManage/Mute.cs.meta
Normal file
11
Assets/Scripts/AudioManage/Mute.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 60c571c6b767316438ed3b3d2e06d714
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/Environ3.meta
Normal file
8
Assets/Scripts/Environ3.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 928c1a340fd1ab846a4ce724e1dca34a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
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: b02116be5e5c0bc49acb94346cf1d5cf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -348,7 +348,7 @@ public class DoubleClickToFocus : MonoBehaviour
|
||||
if (finalObject.gameObject.name == pair.Key)
|
||||
{
|
||||
Vector3 targetPos = pair.Value;
|
||||
transitionDuration = Mathf.Clamp(Vector3.Distance(mainCamera.transform.position, targetPos) / 50f, 0.5f, 1.5f);
|
||||
transitionDuration = Mathf.Clamp(Vector3.Distance(mainCamera.transform.position, targetPos) / 50f, 1.0f, 1.5f);
|
||||
StartCoroutine(MoveCamera(mainCamera, targetPos, transitionDuration, finalObject));
|
||||
}
|
||||
}
|
||||
@@ -409,7 +409,7 @@ public class DoubleClickToFocus : MonoBehaviour
|
||||
{
|
||||
|
||||
Vector3 targetPos = pair.Value;
|
||||
transitionDuration = Mathf.Clamp(Vector3.Distance(mainCamera.transform.position, targetPos) / 50f, 0.5f, 1.5f);
|
||||
transitionDuration = Mathf.Clamp(Vector3.Distance(mainCamera.transform.position, targetPos) / 50f, 1.0f, 1.5f);
|
||||
StartCoroutine(MoveCamera(mainCamera, targetPos, transitionDuration, finalObject));
|
||||
}
|
||||
}
|
||||
@@ -428,7 +428,7 @@ public class DoubleClickToFocus : MonoBehaviour
|
||||
{
|
||||
|
||||
Vector3 targetPos = pair.Value;
|
||||
transitionDuration = Mathf.Clamp(Vector3.Distance(mainCamera.transform.position, targetPos) / 50f, 0.5f, 1.5f);
|
||||
transitionDuration = Mathf.Clamp(Vector3.Distance(mainCamera.transform.position, targetPos) / 50f, 1.0f, 1.5f);
|
||||
StartCoroutine(MoveCamera(mainCamera, targetPos, transitionDuration, finalObject));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user