add weather and time
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 32eb3e5967ad85d49ac6699f0ee29648
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,59 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
|
||||
namespace Enviro
|
||||
{
|
||||
|
||||
[ExecuteInEditMode]
|
||||
[AddComponentMenu("Enviro 3/Integrations/MicroSplat Integration")]
|
||||
public class EnviroMicrosplatIntegration : MonoBehaviour
|
||||
{
|
||||
[Header("Wetness")]
|
||||
public bool UpdateWetness = true;
|
||||
[Range(0f, 1f)]
|
||||
public float minWetness = 0f;
|
||||
[Header("Rain Ripples")]
|
||||
public bool UpdateRainRipples = true;
|
||||
[Header("Puddle Settings")]
|
||||
public bool UpdatePuddles = true;
|
||||
[Header("Stream Settings")]
|
||||
public bool UpdateStreams = true;
|
||||
[Header("Snow Settings")]
|
||||
public bool UpdateSnow = true;
|
||||
// [Header("Wind Settings")]
|
||||
// public bool UpdateWindStrength = true;
|
||||
// public bool UpdateWindRotation = true;
|
||||
|
||||
void Update ()
|
||||
{
|
||||
if (EnviroManager.instance == null || EnviroManager.instance.Environment == null)
|
||||
return;
|
||||
|
||||
if (UpdateSnow){
|
||||
Shader.SetGlobalFloat ("_Global_SnowLevel", EnviroManager.instance.Environment.Settings.snow);
|
||||
}
|
||||
|
||||
if (UpdateWetness) {
|
||||
Shader.SetGlobalVector("_Global_WetnessParams", new Vector2(minWetness, EnviroManager.instance.Environment.Settings.wetness));
|
||||
}
|
||||
|
||||
if (UpdatePuddles) {
|
||||
Shader.SetGlobalFloat("_Global_PuddleParams", EnviroManager.instance.Environment.Settings.wetness);
|
||||
}
|
||||
|
||||
if (UpdateRainRipples)
|
||||
{
|
||||
if(EnviroManager.instance.Environment != null)
|
||||
{
|
||||
float rainIntensity = Mathf.Clamp(EnviroManager.instance.Environment.Settings.wetness,0f,1f);
|
||||
Shader.SetGlobalFloat("_Global_RainIntensity", rainIntensity);
|
||||
}
|
||||
}
|
||||
|
||||
if (UpdateStreams) {
|
||||
Shader.SetGlobalFloat("_Global_StreamMax", EnviroManager.instance.Environment.Settings.wetness);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6b1b283892eb3a54fafb5a6ad110b8e1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/ThirdPartySupport/Microsplat/EnviroMicrosplatIntegration.cs
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b60e268327e81984da6698e54b3cb7cb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,88 @@
|
||||
/// <summary>
|
||||
/// This component can be used to synchronize time and weather in games where server is a player too.
|
||||
/// </summary>
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
#if ENVIRO_MIRROR_SUPPORT
|
||||
using Mirror;
|
||||
#endif
|
||||
|
||||
namespace Enviro
|
||||
{
|
||||
#if ENVIRO_MIRROR_SUPPORT
|
||||
[AddComponentMenu("Enviro 3/Integrations/Mirror Player")]
|
||||
[RequireComponent(typeof (NetworkIdentity))]
|
||||
public class EnviroMirrorPlayer : NetworkBehaviour
|
||||
{
|
||||
#else
|
||||
public class EnviroMirrorPlayer : MonoBehaviour
|
||||
{
|
||||
#endif
|
||||
#if ENVIRO_MIRROR_SUPPORT
|
||||
public bool assignOnStart = true;
|
||||
public bool findSceneCamera = true;
|
||||
|
||||
public Camera Camera;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
// Deactivate if it isn't ours!
|
||||
if (!isLocalPlayer && !isServer) {
|
||||
this.enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Camera == null && findSceneCamera)
|
||||
Camera = Camera.main;
|
||||
|
||||
if (isLocalPlayer)
|
||||
{
|
||||
if (assignOnStart && Camera != null)
|
||||
EnviroManager.instance.Camera = Camera;
|
||||
|
||||
Cmd_RequestSeason ();
|
||||
Cmd_RequestCurrentWeather ();
|
||||
}
|
||||
}
|
||||
|
||||
[Command]
|
||||
void Cmd_RequestSeason ()
|
||||
{
|
||||
if(EnviroManager.instance.Environment != null)
|
||||
RpcRequestSeason((int)EnviroManager.instance.Environment.Settings.season);
|
||||
}
|
||||
|
||||
[ClientRpc]
|
||||
void RpcRequestSeason (int season)
|
||||
{
|
||||
if(EnviroManager.instance.Environment != null)
|
||||
EnviroManager.instance.Environment.ChangeSeason((EnviroEnvironment.Seasons)season);
|
||||
}
|
||||
|
||||
[Command]
|
||||
void Cmd_RequestCurrentWeather ()
|
||||
{
|
||||
if(EnviroManager.instance.Weather != null)
|
||||
{
|
||||
//for (int i = 0; i < EnviroSkyMgr.instance.Weather.zones.Count; i++)
|
||||
//{
|
||||
for (int w = 0; w < EnviroManager.instance.Weather.Settings.weatherTypes.Count; w++)
|
||||
{
|
||||
if (EnviroManager.instance.Weather.Settings.weatherTypes[w] == EnviroManager.instance.Weather.targetWeatherType)
|
||||
RpcRequestCurrentWeather(w);
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
[ClientRpc]
|
||||
void RpcRequestCurrentWeather (int weather)
|
||||
{
|
||||
if(EnviroManager.instance.Weather != null)
|
||||
EnviroManager.instance.Weather.ChangeWeatherInstant(EnviroManager.instance.Weather.Settings.weatherTypes[weather]);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d95b72a2e3fe9c43b3bd9530a383745
|
||||
timeCreated: 1480502929
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/ThirdPartySupport/Mirror/EnviroMirrorPlayer.cs
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,122 @@
|
||||
/// <summary>
|
||||
/// This component can be used to synchronize time and weather.
|
||||
/// </summary>
|
||||
|
||||
using UnityEngine;
|
||||
#if ENVIRO_MIRROR_SUPPORT
|
||||
using Mirror;
|
||||
#endif
|
||||
using System.Collections;
|
||||
namespace Enviro
|
||||
{
|
||||
#if ENVIRO_MIRROR_SUPPORT
|
||||
[AddComponentMenu("Enviro 3/Integrations/Mirror Server")]
|
||||
[RequireComponent(typeof (NetworkIdentity))]
|
||||
public class EnviroMirrorServer : NetworkBehaviour {
|
||||
#else
|
||||
public class EnviroMirrorServer : MonoBehaviour {
|
||||
#endif
|
||||
#if ENVIRO_MIRROR_SUPPORT
|
||||
public float updateSmoothing = 15f;
|
||||
|
||||
[SyncVar] private float networkHours;
|
||||
[SyncVar] private int networkDays;
|
||||
[SyncVar] private int networkMonths;
|
||||
[SyncVar] private int networkYears;
|
||||
|
||||
public override void OnStartServer()
|
||||
{
|
||||
EnviroManager.instance.OnSeasonChanged += (EnviroEnvironment.Seasons season) => {
|
||||
SendSeasonToClient (season);
|
||||
};
|
||||
EnviroManager.instance.OnZoneWeatherChanged += (EnviroWeatherType type, EnviroZone zone) => {
|
||||
SendWeatherToClient (type, zone);
|
||||
};
|
||||
}
|
||||
|
||||
public void Start ()
|
||||
{
|
||||
if (!isServer)
|
||||
{
|
||||
if(EnviroManager.instance.Time != null)
|
||||
EnviroManager.instance.Time.Settings.simulate = false;
|
||||
|
||||
if(EnviroManager.instance.Weather != null)
|
||||
EnviroManager.instance.Weather.globalAutoWeatherChange = false;
|
||||
|
||||
if(EnviroManager.instance.Environment != null)
|
||||
EnviroManager.instance.Environment.Settings.changeSeason = false;
|
||||
}
|
||||
}
|
||||
|
||||
void SendWeatherToClient (EnviroWeatherType w, EnviroZone z)
|
||||
{
|
||||
int weatherID = 0;
|
||||
int zoneID = -1;
|
||||
|
||||
for(int i = 0; i < EnviroManager.instance.Weather.Settings.weatherTypes.Count; i++)
|
||||
{
|
||||
if (EnviroManager.instance.Weather.Settings.weatherTypes [i] == w)
|
||||
weatherID = i;
|
||||
}
|
||||
|
||||
for (int i = 0; i < EnviroManager.instance.zones.Count; i++)
|
||||
{
|
||||
if (EnviroManager.instance.zones [i] == z)
|
||||
zoneID = i;
|
||||
}
|
||||
RpcWeatherUpdate(weatherID,zoneID);
|
||||
}
|
||||
|
||||
void SendSeasonToClient (EnviroEnvironment.Seasons s)
|
||||
{
|
||||
RpcSeasonUpdate((int)s);
|
||||
}
|
||||
|
||||
[ClientRpc]
|
||||
void RpcSeasonUpdate (int season)
|
||||
{
|
||||
if(EnviroManager.instance.Environment != null)
|
||||
EnviroManager.instance.Environment.ChangeSeason((EnviroEnvironment.Seasons)season);
|
||||
}
|
||||
|
||||
[ClientRpc]
|
||||
void RpcWeatherUpdate (int weather, int zone)
|
||||
{
|
||||
if(EnviroManager.instance.Weather != null)
|
||||
{
|
||||
if(zone == -1)
|
||||
EnviroManager.instance.Weather.ChangeWeather(weather);
|
||||
else
|
||||
EnviroManager.instance.Weather.ChangeZoneWeather(weather,zone);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Update ()
|
||||
{
|
||||
if (EnviroManager.instance == null || EnviroManager.instance.Time == null)
|
||||
return;
|
||||
|
||||
if (!isServer)
|
||||
{
|
||||
if (networkHours < 1f && EnviroManager.instance.Time.GetTimeOfDay() > 23f)
|
||||
EnviroManager.instance.Time.SetTimeOfDay(networkHours);
|
||||
|
||||
EnviroManager.instance.Time.SetTimeOfDay(Mathf.Lerp(EnviroManager.instance.Time.GetTimeOfDay(), (float)networkHours, Time.deltaTime * updateSmoothing));
|
||||
EnviroManager.instance.Time.years = networkYears;
|
||||
EnviroManager.instance.Time.months = networkMonths;
|
||||
EnviroManager.instance.Time.days = networkDays;
|
||||
|
||||
} else {
|
||||
networkHours = EnviroManager.instance.Time.GetTimeOfDay();
|
||||
networkDays = EnviroManager.instance.Time.days;
|
||||
networkMonths = EnviroManager.instance.Time.months;
|
||||
networkYears = EnviroManager.instance.Time.years;
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 16fa76d7b5adcb14f894e96a517beec7
|
||||
timeCreated: 1491610098
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/ThirdPartySupport/Mirror/EnviroMirrorServer.cs
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 762513959524c4645b4c5d50c73b4fb4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,188 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
#if ENVIRO_PHOTON_SUPPORT
|
||||
using Photon.Pun;
|
||||
#endif
|
||||
|
||||
namespace Enviro
|
||||
{
|
||||
#if ENVIRO_PHOTON_SUPPORT
|
||||
[RequireComponent(typeof (PhotonView))]
|
||||
[AddComponentMenu("Enviro 3/Integrations/Photon Integration")]
|
||||
public class EnviroPhotonIntegration : MonoBehaviourPunCallbacks, IPunObservable
|
||||
{
|
||||
#else
|
||||
public class EnviroPhotonIntegration : MonoBehaviour
|
||||
{
|
||||
|
||||
#endif
|
||||
#if ENVIRO_PHOTON_SUPPORT
|
||||
public ViewSynchronization synchronizationType = ViewSynchronization.Unreliable;
|
||||
public float updateSmoothing = 15f;
|
||||
private float networkHours;
|
||||
|
||||
void Start ()
|
||||
{
|
||||
if(EnviroManager.instance != null && EnviroManager.instance.Time != null)
|
||||
networkHours = EnviroManager.instance.Time.GetTimeOfDay();
|
||||
|
||||
photonView.ObservedComponents[0] = this;
|
||||
photonView.Synchronization = synchronizationType;
|
||||
}
|
||||
|
||||
public override void OnJoinedRoom()
|
||||
{
|
||||
if (PhotonNetwork.IsMasterClient)
|
||||
{
|
||||
EnviroManager.instance.OnZoneWeatherChanged += (EnviroWeatherType type, EnviroZone zone) => {
|
||||
SendWeatherToClient (type, zone);
|
||||
};
|
||||
|
||||
EnviroManager.instance.OnSeasonChanged += (EnviroEnvironment.Seasons season) => {
|
||||
SendSeasonToClient (season);
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
if(EnviroManager.instance.Weather != null)
|
||||
EnviroManager.instance.Weather.globalAutoWeatherChange = false;
|
||||
|
||||
if(EnviroManager.instance.Time != null)
|
||||
EnviroManager.instance.Time.Settings.simulate = false;
|
||||
|
||||
if(EnviroManager.instance.Environment != null)
|
||||
EnviroManager.instance.Environment.Settings.changeSeason = false;
|
||||
|
||||
StartCoroutine (GetWeather ());
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator GetWeather ()
|
||||
{
|
||||
yield return 0;
|
||||
photonView.RPC("GetWeatherAndSeason", RpcTarget.MasterClient);
|
||||
}
|
||||
|
||||
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
|
||||
{
|
||||
if(EnviroManager.instance.Time == null)
|
||||
return;
|
||||
|
||||
if (stream.IsWriting)
|
||||
{
|
||||
stream.SendNext(EnviroManager.instance.Time.GetTimeOfDay());
|
||||
stream.SendNext(EnviroManager.instance.Time.days);
|
||||
stream.SendNext(EnviroManager.instance.Time.months);
|
||||
stream.SendNext(EnviroManager.instance.Time.years);
|
||||
}
|
||||
else
|
||||
{
|
||||
networkHours = (float) stream.ReceiveNext();
|
||||
EnviroManager.instance.Time.days = (int) stream.ReceiveNext();
|
||||
EnviroManager.instance.Time.months = (int) stream.ReceiveNext();
|
||||
EnviroManager.instance.Time.years = (int) stream.ReceiveNext();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SendWeatherToClient (EnviroWeatherType type, EnviroZone zone)
|
||||
{
|
||||
int weatherID = 0;
|
||||
int zoneID = -1;
|
||||
|
||||
for(int i = 0; i < EnviroManager.instance.Weather.Settings.weatherTypes.Count; i++)
|
||||
{
|
||||
if (EnviroManager.instance.Weather.Settings.weatherTypes [i] == type)
|
||||
weatherID = i;
|
||||
}
|
||||
|
||||
for (int i = 0; i < EnviroManager.instance.zones.Count; i++)
|
||||
{
|
||||
if (EnviroManager.instance.zones [i] == zone)
|
||||
zoneID = i;
|
||||
}
|
||||
|
||||
photonView.RPC("SendWeatherUpdate", RpcTarget.OthersBuffered,weatherID,zoneID);
|
||||
}
|
||||
|
||||
void SendSeasonToClient (EnviroEnvironment.Seasons s)
|
||||
{
|
||||
photonView.RPC("SendSeasonUpdate",RpcTarget.OthersBuffered,(int)s);
|
||||
}
|
||||
|
||||
[PunRPC]
|
||||
void GetWeatherAndSeason ()
|
||||
{
|
||||
if(EnviroManager.instance.Weather != null)
|
||||
{
|
||||
for (int i = 0; i < EnviroManager.instance.zones.Count; i++)
|
||||
{
|
||||
SendWeatherToClient(EnviroManager.instance.zones[i].currentWeatherType, EnviroManager.instance.zones[i]);
|
||||
}
|
||||
|
||||
SendWeatherToClient(EnviroManager.instance.Weather.targetWeatherType, null);
|
||||
}
|
||||
|
||||
if(EnviroManager.instance.Environment != null)
|
||||
SendSeasonToClient(EnviroManager.instance.Environment.Settings.season);
|
||||
}
|
||||
|
||||
|
||||
|
||||
[PunRPC]
|
||||
void SendWeatherUpdate (int id, int zone)
|
||||
{
|
||||
if(EnviroManager.instance.Weather != null)
|
||||
{
|
||||
if(zone == -1)
|
||||
EnviroManager.instance.Weather.ChangeWeather(id);
|
||||
else
|
||||
EnviroManager.instance.Weather.ChangeZoneWeather(id,zone);
|
||||
}
|
||||
}
|
||||
|
||||
[PunRPC]
|
||||
void SendSeasonUpdate (int id)
|
||||
{
|
||||
if(EnviroManager.instance.Environment != null)
|
||||
return;
|
||||
|
||||
switch (id)
|
||||
{
|
||||
case 0:
|
||||
EnviroManager.instance.Environment.Settings.season = EnviroEnvironment.Seasons.Spring;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
EnviroManager.instance.Environment.Settings.season = EnviroEnvironment.Seasons.Summer;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
EnviroManager.instance.Environment.Settings.season = EnviroEnvironment.Seasons.Autumn;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
EnviroManager.instance.Environment.Settings.season = EnviroEnvironment.Seasons.Winter;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Update ()
|
||||
{
|
||||
|
||||
if (EnviroManager.instance == null || EnviroManager.instance.Time == null)
|
||||
return;
|
||||
|
||||
if (!PhotonNetwork.IsMasterClient)
|
||||
{
|
||||
if (networkHours < 0.5f && EnviroManager.instance.Time.GetTimeOfDay() > 23f)
|
||||
EnviroManager.instance.Time.SetTimeOfDay(networkHours);
|
||||
|
||||
EnviroManager.instance.Time.SetTimeOfDay(Mathf.Lerp (EnviroManager.instance.Time.GetTimeOfDay(), (float)networkHours, Time.deltaTime * updateSmoothing));
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4dd54ee80a458f64c9f7b84d7cb22be8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/ThirdPartySupport/Photon/EnviroPhotonIntegration.cs
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4bdcae585ab4c8c478ad671b81e4eec7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2ee33e14d8909a54eb1239e78c83f708
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d6ff0236dc092d740be13a9152c5747b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae47b8694bf2fb14189274551eb5f9c8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,104 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
#if WORLDAPI_PRESENT
|
||||
|
||||
namespace Enviro
|
||||
{
|
||||
[CustomEditor(typeof(EnviroWorldAPI))]
|
||||
public class EnviroWAPIEditor : Editor {
|
||||
|
||||
private GUIStyle boxStyle;
|
||||
private GUIStyle wrapStyle;
|
||||
private GUIStyle headerStyle;
|
||||
|
||||
SerializedObject serializedObj;
|
||||
private EnviroWorldAPI myTarget;
|
||||
|
||||
SerializedProperty snowPower, wetnessPower, fogPower, seasons, time,date, cloudCover, location, temperature;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
myTarget = (EnviroWorldAPI)target;
|
||||
serializedObj = new SerializedObject (myTarget);
|
||||
snowPower = serializedObj.FindProperty ("snowPower");
|
||||
wetnessPower = serializedObj.FindProperty ("wetnessPower");
|
||||
temperature = serializedObj.FindProperty("temperature");
|
||||
fogPower = serializedObj.FindProperty ("fogPower");
|
||||
//windDirection = serializedObj.FindProperty ("windDirection");
|
||||
//windSpeed = serializedObj.FindProperty ("windSpeed");
|
||||
seasons = serializedObj.FindProperty ("seasons");
|
||||
time = serializedObj.FindProperty ("time");
|
||||
date = serializedObj.FindProperty ("date");
|
||||
cloudCover = serializedObj.FindProperty ("cloudCover");
|
||||
location = serializedObj.FindProperty ("location");
|
||||
}
|
||||
|
||||
|
||||
public override void OnInspectorGUI ()
|
||||
{
|
||||
if (boxStyle == null)
|
||||
{
|
||||
boxStyle = new GUIStyle(GUI.skin.box);
|
||||
boxStyle.normal.textColor = GUI.skin.label.normal.textColor;
|
||||
boxStyle.fontStyle = FontStyle.Bold;
|
||||
boxStyle.alignment = TextAnchor.UpperLeft;
|
||||
}
|
||||
|
||||
if (wrapStyle == null)
|
||||
{
|
||||
wrapStyle = new GUIStyle(GUI.skin.label);
|
||||
wrapStyle.fontStyle = FontStyle.Normal;
|
||||
wrapStyle.wordWrap = true;
|
||||
}
|
||||
|
||||
if (headerStyle == null)
|
||||
{
|
||||
headerStyle = new GUIStyle(GUI.skin.label);
|
||||
headerStyle.fontStyle = FontStyle.Bold;
|
||||
headerStyle.wordWrap = true;
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck ();
|
||||
GUILayout.BeginVertical("Enviro 3 - WAPI Integration", boxStyle);
|
||||
GUILayout.Space(20);
|
||||
EditorGUILayout.LabelField("Welcome to the World Manager Integration for Enviro 3 - Sky and Weather!", wrapStyle);
|
||||
GUILayout.EndVertical ();
|
||||
GUILayout.BeginVertical("Controls", boxStyle);
|
||||
GUILayout.Space(20);
|
||||
GUILayout.BeginVertical("Time, Season and Location", boxStyle);
|
||||
GUILayout.Space(20);
|
||||
EditorGUILayout.PropertyField (time, true, null);
|
||||
EditorGUILayout.PropertyField (date, true, null);
|
||||
EditorGUILayout.PropertyField (location, true, null);
|
||||
EditorGUILayout.PropertyField (seasons, true, null);
|
||||
GUILayout.EndVertical ();
|
||||
GUILayout.BeginVertical("Weather", boxStyle);
|
||||
GUILayout.Space(20);
|
||||
EditorGUILayout.LabelField("Enviro will change weather when using GetFromWAPI mode here to match WAPI values!", wrapStyle);
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField (cloudCover, true, null);
|
||||
EditorGUILayout.PropertyField (snowPower, true, null);
|
||||
EditorGUILayout.PropertyField (wetnessPower, true, null);
|
||||
EditorGUILayout.PropertyField (temperature, true, null);
|
||||
EditorGUI.indentLevel--;
|
||||
GUILayout.Space(10);
|
||||
//GUILayout.Label ("Wind",headerStyle);
|
||||
//EditorGUI.indentLevel++;
|
||||
//EditorGUILayout.PropertyField (windSpeed, true, null);
|
||||
//EditorGUILayout.PropertyField (windDirection, true, null);
|
||||
//EditorGUI.indentLevel--;
|
||||
GUILayout.Label ("Fog",headerStyle);
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField (fogPower, true, null);
|
||||
EditorGUI.indentLevel--;
|
||||
GUILayout.EndVertical ();
|
||||
GUILayout.EndVertical ();
|
||||
if (EditorGUI.EndChangeCheck ()) {
|
||||
serializedObj.ApplyModifiedProperties ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fa5dddff0dff4c64b915b71ad9bf846c
|
||||
timeCreated: 1504230849
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/ThirdPartySupport/WAPI/Editor/EnviroWAPIEditor.cs
|
||||
uploadId: 660896
|
||||
@@ -0,0 +1,442 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#if WORLDAPI_PRESENT
|
||||
using WAPI;
|
||||
#endif
|
||||
|
||||
#if WORLDAPI_PRESENT
|
||||
|
||||
namespace Enviro
|
||||
{
|
||||
[ExecuteInEditMode]
|
||||
[AddComponentMenu("Enviro 3/Integrations/WAPI Integration")]
|
||||
public class EnviroWorldAPI : MonoBehaviour, IWorldApiChangeHandler
|
||||
{
|
||||
public enum GetSet
|
||||
{
|
||||
None,
|
||||
GetFromWAPI,
|
||||
SendToWAPI
|
||||
}
|
||||
|
||||
public enum Get
|
||||
{
|
||||
None,
|
||||
GetFromWAPI
|
||||
}
|
||||
|
||||
public enum Set
|
||||
{
|
||||
None,
|
||||
SendToWAPI
|
||||
}
|
||||
|
||||
// Controls
|
||||
public GetSet snowPower;
|
||||
public GetSet wetnessPower;
|
||||
public GetSet fogPower;
|
||||
public GetSet temperature;
|
||||
//public float fogPowerMult = 1000f;
|
||||
//public Set windDirection;
|
||||
//public Set windSpeed;
|
||||
public GetSet seasons;
|
||||
public GetSet time;
|
||||
public GetSet date;
|
||||
public GetSet cloudCover;
|
||||
public GetSet location;
|
||||
|
||||
private List<EnviroWeatherType> weatherPresets = new List<EnviroWeatherType>();
|
||||
private List<EnviroWeatherType> clearWeatherPresets = new List<EnviroWeatherType>();
|
||||
private List<EnviroWeatherType> cloudyWeatherPresets = new List<EnviroWeatherType>();
|
||||
private List<EnviroWeatherType> rainWeatherPresets = new List<EnviroWeatherType>();
|
||||
private List<EnviroWeatherType> snowWeatherPresets = new List<EnviroWeatherType>();
|
||||
|
||||
|
||||
|
||||
|
||||
private float timeOfDayChached;
|
||||
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
ConnectToWorldAPI();
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
DisconnectFromWorldAPI();
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (EnviroManager.instance == null)
|
||||
{
|
||||
Debug.LogWarning("Enviro 3 Manager not found!");
|
||||
return;
|
||||
}
|
||||
|
||||
if(EnviroManager.instance.Time != null)
|
||||
timeOfDayChached = EnviroManager.instance.Time.GetTimeOfDay();
|
||||
|
||||
if(EnviroManager.instance.Weather != null)
|
||||
{
|
||||
//Create Lists of weather presets
|
||||
for (int i = 0; i < EnviroManager.instance.Weather.Settings.weatherTypes.Count; i++)
|
||||
{
|
||||
weatherPresets.Add(EnviroManager.instance.Weather.Settings.weatherTypes[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < weatherPresets.Count; i++)
|
||||
{
|
||||
//Clear Weather List
|
||||
if (weatherPresets [i].cloudsOverride.coverage <= -0.5)
|
||||
clearWeatherPresets.Add (weatherPresets [i]);
|
||||
|
||||
//Cloudy Weather List
|
||||
if (weatherPresets [i].cloudsOverride.coverage >= -0.5) {
|
||||
if (weatherPresets [i].environmentOverride.wetnessTarget == 0f && weatherPresets [i].environmentOverride.snowTarget == 0f)
|
||||
cloudyWeatherPresets.Add (weatherPresets [i]);
|
||||
}
|
||||
|
||||
// Rainy Weather List
|
||||
if (weatherPresets [i].environmentOverride.wetnessTarget > 0f)
|
||||
rainWeatherPresets.Add (weatherPresets [i]);
|
||||
|
||||
//Snowy Weather List
|
||||
if (weatherPresets [i].environmentOverride.snowTarget > 0f)
|
||||
snowWeatherPresets.Add (weatherPresets [i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ConnectToWorldAPI();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (EnviroManager.instance == null)
|
||||
return;
|
||||
|
||||
|
||||
if (snowPower == GetSet.SendToWAPI)
|
||||
{
|
||||
if(EnviroManager.instance.Environment != null)
|
||||
WorldManager.Instance.Snow = new Vector4 (EnviroManager.instance.Environment.Settings.snowTarget, EnviroManager.instance.Environment.Settings.snow, WorldManager.Instance.SnowMinHeight, WorldManager.Instance.SnowAge);
|
||||
}
|
||||
|
||||
if (wetnessPower == GetSet.SendToWAPI)
|
||||
{
|
||||
if(EnviroManager.instance.Environment != null)
|
||||
WorldManager.Instance.Rain = new Vector4 (EnviroManager.instance.Environment.Settings.wetnessTarget, EnviroManager.instance.Environment.Settings.wetness, WorldManager.Instance.RainMinHeight, WorldManager.Instance.RainMaxHeight);
|
||||
}
|
||||
|
||||
if (fogPower == GetSet.SendToWAPI)
|
||||
{
|
||||
if(EnviroManager.instance.Fog != null)
|
||||
WorldManager.Instance.Fog = new Vector4 (EnviroManager.instance.Fog.Settings.fogDensity2, EnviroManager.instance.Fog.Settings.fogHeight2, EnviroManager.instance.Fog.Settings.fogDensity, EnviroManager.instance.Fog.Settings.fogHeight);
|
||||
}
|
||||
|
||||
if (seasons == GetSet.SendToWAPI)
|
||||
{
|
||||
if(EnviroManager.instance.Time != null)
|
||||
WorldManager.Instance.Season = Mathf.Lerp(0f, 4f, EnviroManager.instance.Time.Settings.date.DayOfYear / 366);
|
||||
}
|
||||
|
||||
if (time == GetSet.SendToWAPI)
|
||||
{
|
||||
if(EnviroManager.instance.Time != null)
|
||||
WorldManager.Instance.SetDecimalTime(EnviroManager.instance.Time.GetTimeOfDay());
|
||||
}
|
||||
|
||||
if (date == GetSet.SendToWAPI)
|
||||
{
|
||||
if(EnviroManager.instance.Time != null)
|
||||
WorldManager.Instance.GameTime = EnviroManager.instance.Time.Settings.date;
|
||||
}
|
||||
|
||||
|
||||
if (temperature == GetSet.SendToWAPI)
|
||||
{
|
||||
if(EnviroManager.instance.Environment != null)
|
||||
WorldManager.Instance.Temperature = EnviroManager.instance.Environment.Settings.temperature;
|
||||
}
|
||||
|
||||
if (location == GetSet.SendToWAPI)
|
||||
{
|
||||
if(EnviroManager.instance.Time != null)
|
||||
{
|
||||
WorldManager.Instance.Latitude = EnviroManager.instance.Time.Settings.latitude;
|
||||
WorldManager.Instance.Longitude = EnviroManager.instance.Time.Settings.longitude;
|
||||
}
|
||||
}
|
||||
|
||||
if (cloudCover == GetSet.SendToWAPI)
|
||||
{
|
||||
if(EnviroManager.instance.VolumetricClouds != null)
|
||||
WorldManager.Instance.CloudPower = Mathf.Clamp01(EnviroManager.instance.VolumetricClouds.settingsVolume.coverage);
|
||||
else if (EnviroManager.instance.FlatClouds != null)
|
||||
WorldManager.Instance.CloudPower = Mathf.Clamp01(EnviroManager.instance.FlatClouds.settings.flatCloudsCoverage);
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectToWorldAPI()
|
||||
{
|
||||
WorldManager.Instance.AddListener(this);
|
||||
}
|
||||
|
||||
void DisconnectFromWorldAPI()
|
||||
{
|
||||
WorldManager.Instance.RemoveListener(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle updates from world manager
|
||||
/// </summary>
|
||||
/// <param name="changeArgs">Change to time of day</param>
|
||||
public void OnWorldChanged(WorldChangeArgs changeArgs)
|
||||
{
|
||||
if (EnviroManager.instance == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get Time from WAPI
|
||||
if (changeArgs.HasChanged(WorldConstants.WorldChangeEvents.GameTimeChanged) && EnviroManager.instance.Time != null)
|
||||
{
|
||||
if(time == GetSet.GetFromWAPI)
|
||||
{
|
||||
float newTimeOfDay = (float) changeArgs.manager.GetTimeDecimal();
|
||||
|
||||
if (newTimeOfDay != timeOfDayChached)
|
||||
{
|
||||
timeOfDayChached = newTimeOfDay;
|
||||
EnviroManager.instance.Time.SetTimeOfDay(newTimeOfDay);
|
||||
}
|
||||
}
|
||||
|
||||
if(date == GetSet.GetFromWAPI)
|
||||
{
|
||||
System.DateTime d = changeArgs.manager.GameTime;
|
||||
EnviroManager.instance.Time.SetDateTime(d.Second,d.Minute, d.Hour,d.Day,d.Month,d.Year);
|
||||
}
|
||||
}
|
||||
|
||||
//Get Season from WAPI
|
||||
if (changeArgs.HasChanged(WorldConstants.WorldChangeEvents.SeasonChanged) && seasons == GetSet.GetFromWAPI && EnviroManager.instance.Environment != null)
|
||||
{
|
||||
if (WorldManager.Instance.Season < 1f)
|
||||
EnviroManager.instance.Environment.ChangeSeason(EnviroEnvironment.Seasons.Winter);
|
||||
else if (WorldManager.Instance.Season < 2f)
|
||||
EnviroManager.instance.Environment.ChangeSeason(EnviroEnvironment.Seasons.Spring);
|
||||
else if (WorldManager.Instance.Season < 3f)
|
||||
EnviroManager.instance.Environment.ChangeSeason(EnviroEnvironment.Seasons.Summer);
|
||||
else
|
||||
EnviroManager.instance.Environment.ChangeSeason(EnviroEnvironment.Seasons.Autumn);
|
||||
}
|
||||
|
||||
// Set Lat/Lng from WAPI
|
||||
if (changeArgs.HasChanged(WorldConstants.WorldChangeEvents.LatLngChanged) && location == GetSet.GetFromWAPI && EnviroManager.instance.Time != null)
|
||||
{
|
||||
EnviroManager.instance.Time.Settings.latitude = WorldManager.Instance.Latitude;
|
||||
EnviroManager.instance.Time.Settings.longitude = WorldManager.Instance.Longitude;
|
||||
}
|
||||
|
||||
// Set Distance and Height Fog from WAPI
|
||||
if (changeArgs.HasChanged(WorldConstants.WorldChangeEvents.FogChanged) && fogPower == GetSet.GetFromWAPI && EnviroManager.instance.Fog != null)
|
||||
{
|
||||
EnviroManager.instance.Fog.Settings.fogDensity = WorldManager.Instance.FogDistancePower;
|
||||
EnviroManager.instance.Fog.Settings.fogDensity2 = WorldManager.Instance.FogHeightPower;
|
||||
EnviroManager.instance.Fog.Settings.fogHeight = WorldManager.Instance.FogHeightMax;
|
||||
EnviroManager.instance.Fog.Settings.fogHeight2 = WorldManager.Instance.FogHeightMax;
|
||||
}
|
||||
|
||||
// Set temparaute from WAPI
|
||||
if (changeArgs.HasChanged(WorldConstants.WorldChangeEvents.TempAndHumidityChanged) && temperature == GetSet.GetFromWAPI && EnviroManager.instance.Environment != null)
|
||||
{
|
||||
EnviroManager.instance.Environment.Settings.temperature = WorldManager.Instance.Temperature;
|
||||
}
|
||||
|
||||
|
||||
if (EnviroManager.instance.Weather == null)
|
||||
{
|
||||
// Cloud
|
||||
if (changeArgs.HasChanged(WorldConstants.WorldChangeEvents.CloudsChanged) && cloudCover == GetSet.GetFromWAPI)
|
||||
{
|
||||
if(EnviroManager.instance.VolumetricClouds != null)
|
||||
{
|
||||
EnviroManager.instance.VolumetricClouds.settingsVolume.coverage = EnviroHelper.Remap(WorldManager.Instance.CloudPower,0f,1f,-1f,1f);
|
||||
}
|
||||
|
||||
if(EnviroManager.instance.FlatClouds != null)
|
||||
{
|
||||
EnviroManager.instance.FlatClouds.settings.flatCloudsCoverage = WorldManager.Instance.CloudPower;
|
||||
}
|
||||
}
|
||||
|
||||
//Rain
|
||||
if (changeArgs.HasChanged (WorldConstants.WorldChangeEvents.RainChanged) && wetnessPower == GetSet.GetFromWAPI)
|
||||
{
|
||||
if(EnviroManager.instance.VolumetricClouds != null)
|
||||
{
|
||||
EnviroManager.instance.VolumetricClouds.settingsVolume.scatteringIntensity = 1.25f - WorldManager.Instance.RainPower;
|
||||
}
|
||||
|
||||
if(EnviroManager.instance.Effects != null)
|
||||
{
|
||||
for(int i = 0; i < EnviroManager.instance.Effects.Settings.effectTypes.Count; i++)
|
||||
{
|
||||
if(EnviroManager.instance.Effects.Settings.effectTypes[i].name.Contains("Rain"))
|
||||
EnviroManager.instance.Effects.Settings.effectTypes[i].emissionRate = WorldManager.Instance.RainPower;
|
||||
}
|
||||
}
|
||||
|
||||
if(EnviroManager.instance.Audio != null)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Snow
|
||||
if (changeArgs.HasChanged (WorldConstants.WorldChangeEvents.SnowChanged) && snowPower == GetSet.GetFromWAPI)
|
||||
{
|
||||
if(EnviroManager.instance.Effects != null)
|
||||
{
|
||||
for(int i = 0; i < EnviroManager.instance.Effects.Settings.effectTypes.Count; i++)
|
||||
{
|
||||
if(EnviroManager.instance.Effects.Settings.effectTypes[i].name.Contains("Snow"))
|
||||
EnviroManager.instance.Effects.Settings.effectTypes[i].emissionRate = WorldManager.Instance.SnowPower;
|
||||
}
|
||||
}
|
||||
|
||||
if(EnviroManager.instance.Audio != null)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (changeArgs.HasChanged(WorldConstants.WorldChangeEvents.CloudsChanged) && cloudCover == GetSet.GetFromWAPI){
|
||||
ChangeWeatherOnCloudCoverChanged ();
|
||||
}
|
||||
|
||||
//Rain
|
||||
if (changeArgs.HasChanged (WorldConstants.WorldChangeEvents.RainChanged) && wetnessPower == GetSet.GetFromWAPI) {
|
||||
ChangeWeatherOnRainChanged (WorldManager.Instance.RainPower,WorldManager.Instance.SnowPower);
|
||||
}
|
||||
|
||||
//Snow
|
||||
if (changeArgs.HasChanged (WorldConstants.WorldChangeEvents.SnowChanged) && snowPower == GetSet.GetFromWAPI) {
|
||||
ChangeWeatherOnSnowChanged (WorldManager.Instance.RainPower,WorldManager.Instance.SnowPower);
|
||||
}
|
||||
}
|
||||
|
||||
void ChangeWeatherOnCloudCoverChanged()
|
||||
{
|
||||
if (WorldManager.Instance.RainPower > 0.01f)
|
||||
return;
|
||||
|
||||
if (WorldManager.Instance.SnowPower > 0.01f)
|
||||
return;
|
||||
|
||||
float cloudCover = WorldManager.Instance.CloudPower;
|
||||
|
||||
if (cloudCover <= 0.1f)
|
||||
{
|
||||
if (clearWeatherPresets.Count > 0 && EnviroManager.instance.Weather.targetWeatherType.name != clearWeatherPresets[0].name)
|
||||
EnviroManager.instance.Weather.ChangeWeather(clearWeatherPresets[0].name);
|
||||
|
||||
}
|
||||
else if (cloudCover > 0.1f && cloudCover <= 0.3f)
|
||||
{
|
||||
if (cloudyWeatherPresets.Count > 0 && EnviroManager.instance.Weather.targetWeatherType.name != cloudyWeatherPresets[0].name)
|
||||
EnviroManager.instance.Weather.ChangeWeather(cloudyWeatherPresets[0].name);
|
||||
|
||||
}
|
||||
else if (cloudCover > 0.3f && cloudCover <= 0.7f)
|
||||
{
|
||||
if (cloudyWeatherPresets.Count > 1 && EnviroManager.instance.Weather.targetWeatherType.name != cloudyWeatherPresets[1].name)
|
||||
EnviroManager.instance.Weather.ChangeWeather(cloudyWeatherPresets[1].name);
|
||||
|
||||
}
|
||||
else if (cloudCover > 0.7f)
|
||||
{
|
||||
if (cloudyWeatherPresets.Count > 2 && EnviroManager.instance.Weather.targetWeatherType.name != cloudyWeatherPresets[2].name)
|
||||
EnviroManager.instance.Weather.ChangeWeather(cloudyWeatherPresets[2].name);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void ChangeWeatherOnRainChanged(float r, float s)
|
||||
{
|
||||
if (r < s || r == 0f)
|
||||
{
|
||||
if (s > 0)
|
||||
ChangeWeatherOnSnowChanged(r, s);
|
||||
else
|
||||
ChangeWeatherOnCloudCoverChanged();
|
||||
return;
|
||||
}
|
||||
|
||||
float rainPower = r;
|
||||
|
||||
if (rainPower < 0.1f)
|
||||
{
|
||||
ChangeWeatherOnCloudCoverChanged();
|
||||
}
|
||||
else if (rainPower > 0.1f && rainPower <= 0.4f)
|
||||
{
|
||||
if (rainWeatherPresets.Count > 0 && EnviroManager.instance.Weather.targetWeatherType.name != rainWeatherPresets[0].name)
|
||||
EnviroManager.instance.Weather.ChangeWeather(rainWeatherPresets[0].name);
|
||||
|
||||
}
|
||||
else if (rainPower > 0.4f && rainPower < 0.7f)
|
||||
{
|
||||
if (rainWeatherPresets.Count > 1 && EnviroManager.instance.Weather.targetWeatherType.name != rainWeatherPresets[1].name)
|
||||
EnviroManager.instance.Weather.ChangeWeather(rainWeatherPresets[1].name);
|
||||
|
||||
}
|
||||
else if (rainPower > 0.7f)
|
||||
{
|
||||
if (rainWeatherPresets.Count > 2 && EnviroManager.instance.Weather.targetWeatherType.name != rainWeatherPresets[2].name)
|
||||
EnviroManager.instance.Weather.ChangeWeather(rainWeatherPresets[2].name);
|
||||
}
|
||||
}
|
||||
|
||||
void ChangeWeatherOnSnowChanged(float r, float s)
|
||||
{
|
||||
if (s < r || s == 0f)
|
||||
{
|
||||
if (r > 0)
|
||||
ChangeWeatherOnRainChanged(r, s);
|
||||
else
|
||||
ChangeWeatherOnCloudCoverChanged();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
float snowPower = s;
|
||||
|
||||
if (snowPower <= 0.1f)
|
||||
{
|
||||
ChangeWeatherOnCloudCoverChanged();
|
||||
}
|
||||
else if (snowPower > 0.1f && snowPower <= 0.5f)
|
||||
{
|
||||
if (snowWeatherPresets.Count > 0 && EnviroManager.instance.Weather.targetWeatherType.name != snowWeatherPresets[0].name)
|
||||
EnviroManager.instance.Weather.ChangeWeather(snowWeatherPresets[0].name);
|
||||
|
||||
}
|
||||
else if (snowPower > 0.5f)
|
||||
{
|
||||
if (snowWeatherPresets.Count > 1 && EnviroManager.instance.Weather.targetWeatherType.name != snowWeatherPresets[1].name)
|
||||
EnviroManager.instance.Weather.ChangeWeather(snowWeatherPresets[1].name);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d466e0e248e40b41bf5a1dc3bcd8be6
|
||||
timeCreated: 1503278604
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 236601
|
||||
packageName: Enviro 3 - Sky and Weather
|
||||
packageVersion: 3.1.2
|
||||
assetPath: Assets/Enviro 3 - Sky and Weather/Scripts/ThirdPartySupport/WAPI/EnviroWorldAPI.cs
|
||||
uploadId: 660896
|
||||
Reference in New Issue
Block a user