424 lines
14 KiB
C#
424 lines
14 KiB
C#
using UnityEngine;
|
|
|
|
namespace Artngame.SKYMASTER
|
|
{
|
|
public class SKYMASTER_Demo3MOBILE_FASTEST : MonoBehaviour
|
|
{
|
|
public float damping = 6f;
|
|
|
|
public bool smooth = true;
|
|
|
|
private VolumeClouds_SM Clouds;
|
|
|
|
private VolumeClouds_SM Clouds_ORIGIN;
|
|
|
|
private Light SunLight;
|
|
|
|
private float SunLight_r;
|
|
|
|
private float SunLight_g;
|
|
|
|
private float SunLight_b;
|
|
|
|
private float Camera_up;
|
|
|
|
private float Sun_up;
|
|
|
|
private float sun_rot_speed;
|
|
|
|
private float cam_rot_speed;
|
|
|
|
private int Cloud_divider;
|
|
|
|
private float Cloud_bed_height;
|
|
|
|
private float Cloud_bed_width;
|
|
|
|
private GameObject Cloud_instance;
|
|
|
|
private float cloud_max_scale;
|
|
|
|
private int cloud_max_particle_size;
|
|
|
|
private bool Rot_clouds;
|
|
|
|
public float Sun_time_start = 14.43f;
|
|
|
|
public GameObject SKYMASTER_OBJ;
|
|
|
|
private SkyMasterManager SUNMASTER;
|
|
|
|
public GameObject SUN;
|
|
|
|
public GameObject TREES;
|
|
|
|
public bool HUD_ON = true;
|
|
|
|
private float HDR = 0.8f;
|
|
|
|
private float Esun = 22f;
|
|
|
|
private float Kr = 0.0025f;
|
|
|
|
private float Km = 0.0015f;
|
|
|
|
private float GE = -0.96f;
|
|
|
|
private float SPEED = 0.01f;
|
|
|
|
private float fSamples = 3f;
|
|
|
|
private float fScaleDepth = 0.5f;
|
|
|
|
private bool set_sun_start;
|
|
|
|
private float Ring_factor;
|
|
|
|
private Vector3 CURRENT_Force_color = new Vector3(0.65f, 0.52f, 0.475f);
|
|
|
|
private float Coloration = 0.28f;
|
|
|
|
private Vector4 TintColor = new Vector4(0f, 0f, 0f, 0f);
|
|
|
|
private bool enable_controls;
|
|
|
|
public GameObject Clouds_top;
|
|
|
|
public GameObject Clouds_bottom;
|
|
|
|
public GameObject Flat_Clouds_top;
|
|
|
|
public GameObject Flat_Clouds_bottom;
|
|
|
|
public GameObject Cloud_Dome;
|
|
|
|
public GameObject Cloud_Rays;
|
|
|
|
public GameObject Cloud_Static;
|
|
|
|
private float Dome_rot;
|
|
|
|
public GameObject Tornado1;
|
|
|
|
public GameObject Tornado2;
|
|
|
|
public GameObject Butterflies;
|
|
|
|
public GameObject FreezeEffect;
|
|
|
|
public GameObject LightningStorm;
|
|
|
|
public bool Auto_Season_Cycle;
|
|
|
|
private float Cycle_speed = 1500f;
|
|
|
|
private bool GI_controls_on;
|
|
|
|
private void LateUpdate()
|
|
{
|
|
if (Rot_clouds)
|
|
{
|
|
if (Clouds != null)
|
|
{
|
|
Clouds.wind.x = 2f * Mathf.Cos(Time.fixedTime * 0.1f);
|
|
Clouds.wind.z = 2f * Mathf.Sin(Time.fixedTime * 0.1f);
|
|
Clouds.speed = 2f;
|
|
Clouds.multiplier = 2f;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Clouds.speed = 0.5f;
|
|
Clouds.multiplier = 1f;
|
|
}
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
if (SKYMASTER_OBJ != null)
|
|
{
|
|
SUNMASTER = SKYMASTER_OBJ.GetComponent(typeof(SkyMasterManager)) as SkyMasterManager;
|
|
}
|
|
SPEED = SUNMASTER.SPEED;
|
|
SUNMASTER.Seasonal_change_auto = false;
|
|
Cloud_instance = Object.Instantiate(Clouds_top.gameObject, Clouds_top.transform.position, Quaternion.identity);
|
|
Cloud_instance.SetActive(value: true);
|
|
Clouds_ORIGIN = Clouds_top.gameObject.GetComponent(typeof(VolumeClouds_SM)) as VolumeClouds_SM;
|
|
Cloud_instance.SetActive(value: false);
|
|
Cloud_instance.SetActive(value: true);
|
|
if (Cloud_instance != null)
|
|
{
|
|
Clouds = Cloud_instance.GetComponent(typeof(VolumeClouds_SM)) as VolumeClouds_SM;
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("AAA");
|
|
}
|
|
}
|
|
|
|
private void OnGUI()
|
|
{
|
|
float num = 100f;
|
|
float num2 = 30f;
|
|
float num3 = -5f;
|
|
float num4 = 60f;
|
|
if (enable_controls)
|
|
{
|
|
SunLight = SUN.GetComponent<Light>();
|
|
float num5 = Screen.currentResolution.width;
|
|
num5 = Camera.main.pixelWidth;
|
|
GUI.TextArea(new Rect(num5 - (num3 + 165f), 1f * num4 + 140f + 7f - 30f, 180f, 30f), "Cloud Centers = " + Clouds_ORIGIN.divider);
|
|
Cloud_divider = (int)GUI.HorizontalSlider(new Rect(num5 - (num3 + 165f), 1f * num4 + 140f + 7f, 100f, 30f), Clouds_ORIGIN.divider, 2f, 45f);
|
|
GUI.TextArea(new Rect(num5 - (num3 + 165f), 1f * num4 + 140f + 7f - 30f - 60f, 180f, 30f), "Cloud Bed size = " + Clouds_ORIGIN.max_bed_corner);
|
|
Cloud_bed_width = GUI.HorizontalSlider(new Rect(num5 - (num3 + 165f), 1f * num4 + 140f + 7f - 60f, 100f, 30f), Clouds_ORIGIN.max_bed_corner, 300f, 1500f);
|
|
GUI.TextArea(new Rect(num5 - (num3 + 165f), 1f * num4 + 140f + 7f - 30f - 60f - 60f, 180f, 30f), "Cloud Bed Height = " + Clouds_ORIGIN.cloud_bed_heigh);
|
|
Cloud_bed_height = GUI.HorizontalSlider(new Rect(num5 - (num3 + 165f), 1f * num4 + 140f + 7f - 60f - 60f, 100f, 30f), Clouds_ORIGIN.cloud_bed_heigh, 500f, 1000f);
|
|
GUI.TextArea(new Rect(num5 - (num3 + 165f), 1f * num4 + 140f + 7f + 30f, 180f, 30f), "Cloud Max size = " + Clouds_ORIGIN.cloud_max_scale);
|
|
cloud_max_scale = GUI.HorizontalSlider(new Rect(num5 - (num3 + 165f), 1f * num4 + 140f + 7f + 30f + 30f, 100f, 30f), Clouds_ORIGIN.cloud_max_scale, 1f, 4f);
|
|
GUI.TextArea(new Rect(num5 - (num3 + 165f), 1f * num4 + 140f + 7f + 30f + 30f + 30f + 30f + 30f, 170f, 40f), "Recreate button will renew the clouds");
|
|
if (GUI.Button(new Rect(num5 - (num3 + 165f), 1f * num4 + 140f + 7f + 30f + 30f + 30f + 40f + 60f, 170f, 40f), "Rotate Clouds"))
|
|
{
|
|
if (Rot_clouds)
|
|
{
|
|
Rot_clouds = false;
|
|
}
|
|
else
|
|
{
|
|
Rot_clouds = true;
|
|
}
|
|
}
|
|
if (GUI.Button(new Rect(num5 - (num3 + 165f), 40f + 1f * num4 + 140f + 7f + 30f + 30f + 30f + 40f + 60f, 170f, 40f), "Recreate Clouds"))
|
|
{
|
|
Object.Destroy(Cloud_instance);
|
|
Clouds_ORIGIN.max_bed_corner = Cloud_bed_width;
|
|
Clouds_ORIGIN.min_bed_corner = 0f - Cloud_bed_width;
|
|
Clouds_ORIGIN.cloud_bed_heigh = Cloud_bed_height;
|
|
Clouds_ORIGIN.divider = Cloud_divider;
|
|
Clouds_ORIGIN.cloud_max_scale = cloud_max_scale;
|
|
Cloud_instance = Object.Instantiate(Clouds_top.gameObject, Clouds_top.transform.position, Quaternion.identity);
|
|
Cloud_instance.SetActive(value: true);
|
|
Clouds = Cloud_instance.GetComponent(typeof(VolumeClouds_SM)) as VolumeClouds_SM;
|
|
}
|
|
Clouds_ORIGIN.max_bed_corner = Cloud_bed_width;
|
|
Clouds_ORIGIN.min_bed_corner = 0f - Cloud_bed_width;
|
|
Clouds_ORIGIN.cloud_bed_heigh = Cloud_bed_height;
|
|
Clouds_ORIGIN.divider = Cloud_divider;
|
|
Clouds_ORIGIN.cloud_max_scale = cloud_max_scale;
|
|
}
|
|
if ((SUNMASTER.Current_Time != Sun_time_start) & !set_sun_start)
|
|
{
|
|
set_sun_start = true;
|
|
}
|
|
if (SUNMASTER.Season == 1)
|
|
{
|
|
if (!Butterflies.activeInHierarchy)
|
|
{
|
|
Butterflies.SetActive(value: true);
|
|
}
|
|
}
|
|
else if (Butterflies.activeInHierarchy)
|
|
{
|
|
Butterflies.SetActive(value: false);
|
|
}
|
|
GI_controls_on = false;
|
|
if (GI_controls_on)
|
|
{
|
|
return;
|
|
}
|
|
if (!enable_controls && GUI.Button(new Rect(1f * num + 10f, num2 + 60f + 30f + 30f, num, 30f), "Cycle Seasons"))
|
|
{
|
|
if (!Auto_Season_Cycle)
|
|
{
|
|
Auto_Season_Cycle = true;
|
|
SUNMASTER.SPEED = 2431.818f;
|
|
SUNMASTER.Seasonal_change_auto = true;
|
|
}
|
|
else
|
|
{
|
|
Auto_Season_Cycle = false;
|
|
SUNMASTER.SPEED = 35f;
|
|
SUNMASTER.Seasonal_change_auto = false;
|
|
}
|
|
}
|
|
if (Auto_Season_Cycle)
|
|
{
|
|
Cycle_speed = GUI.HorizontalSlider(new Rect(5f * num + 10f, num2 + 80f + 30f, num, 30f), Cycle_speed, 50f, 2431.818f);
|
|
SUNMASTER.SPEED = Cycle_speed;
|
|
}
|
|
if (!Auto_Season_Cycle)
|
|
{
|
|
if (!enable_controls && GUI.Button(new Rect(1f * num + 10f, num2 + 60f + 30f, num, 30f), "Sunny"))
|
|
{
|
|
SUNMASTER.Weather = SkyMasterManager.Weather_types.Sunny;
|
|
SUNMASTER.On_demand = true;
|
|
}
|
|
if (GUI.Button(new Rect(2f * num + 10f, num2 - 0f, num, 30f), "Cloudy"))
|
|
{
|
|
SUNMASTER.Weather = SkyMasterManager.Weather_types.Cloudy;
|
|
SUNMASTER.On_demand = true;
|
|
}
|
|
if (GUI.Button(new Rect(2f * num + 10f, num2 + 30f, num, 30f), "Heavy Rain"))
|
|
{
|
|
SUNMASTER.Weather = SkyMasterManager.Weather_types.FlatClouds;
|
|
SUNMASTER.On_demand = true;
|
|
}
|
|
string text = "Spring";
|
|
if (SUNMASTER.Season == 2)
|
|
{
|
|
text = "Summer";
|
|
}
|
|
if (SUNMASTER.Season == 3)
|
|
{
|
|
text = "Autumn";
|
|
}
|
|
if (SUNMASTER.Season == 4)
|
|
{
|
|
text = "Winter";
|
|
}
|
|
GUI.TextArea(new Rect(2f * num + 10f - 0f, num2 + 60f + 30f, num / 1f, 25f), text);
|
|
if (GUI.Button(new Rect(2f * num + 10f, num2 + 60f, num, 30f), "Cycle Season"))
|
|
{
|
|
if (SUNMASTER.Season == 0)
|
|
{
|
|
SUNMASTER.Season = 2;
|
|
}
|
|
else
|
|
{
|
|
SUNMASTER.Season++;
|
|
}
|
|
if (SUNMASTER.Season > 4)
|
|
{
|
|
SUNMASTER.Season = 1;
|
|
}
|
|
}
|
|
if (GUI.Button(new Rect(2f * num + 10f, num2 + 60f + 30f + 30f, num, 30f), "Foggy"))
|
|
{
|
|
SUNMASTER.Weather = SkyMasterManager.Weather_types.HeavyFog;
|
|
SUNMASTER.On_demand = true;
|
|
}
|
|
if (GUI.Button(new Rect(3f * num + 10f, num2 - 0f, num, 30f), "Snow storm"))
|
|
{
|
|
SUNMASTER.Weather = SkyMasterManager.Weather_types.FreezeStorm;
|
|
SUNMASTER.On_demand = true;
|
|
}
|
|
if (GUI.Button(new Rect(2f * num + 10f, num2 - 30f, num, 30f), "Heavy Storm"))
|
|
{
|
|
SUNMASTER.Weather = SkyMasterManager.Weather_types.HeavyStorm;
|
|
SUNMASTER.On_demand = true;
|
|
}
|
|
if (GUI.Button(new Rect(3f * num + 10f, num2 - 30f, num, 30f), "Dark Storm"))
|
|
{
|
|
SUNMASTER.Weather = SkyMasterManager.Weather_types.HeavyStormDark;
|
|
SUNMASTER.On_demand = true;
|
|
}
|
|
if (GUI.Button(new Rect(4f * num + 10f, num2 - 30f, num, 30f), "Lightning"))
|
|
{
|
|
SUNMASTER.Weather = SkyMasterManager.Weather_types.LightningStorm;
|
|
SUNMASTER.On_demand = true;
|
|
}
|
|
if (!enable_controls)
|
|
{
|
|
if (GUI.Button(new Rect(1f * num + 10f, num2 - 30f, num, 30f), "Volume Fog"))
|
|
{
|
|
SUNMASTER.Weather = SkyMasterManager.Weather_types.RollingFog;
|
|
SUNMASTER.On_demand = true;
|
|
}
|
|
if (GUI.Button(new Rect(1f * num + 10f, num2 + 0f, num + 0f, 30f), "Tornado"))
|
|
{
|
|
SUNMASTER.Weather = SkyMasterManager.Weather_types.Tornado;
|
|
SUNMASTER.On_demand = true;
|
|
}
|
|
}
|
|
if (!enable_controls)
|
|
{
|
|
GUI.TextArea(new Rect(1f * num + 10f, num2 + 30f, num + 0f, 25f), "SkyDome rot");
|
|
Dome_rot = GUI.HorizontalSlider(new Rect(1f * num + 10f, num2 + 30f + 30f, num + 0f, 30f), Dome_rot, 0f, 10f);
|
|
SUNMASTER.Horizontal_factor = Dome_rot;
|
|
}
|
|
if (GUI.Button(new Rect(5f, 0f * num2, num + 5f, 30f), "Enable Controls"))
|
|
{
|
|
if (enable_controls)
|
|
{
|
|
enable_controls = false;
|
|
SUNMASTER.Auto_Cycle_Sky = true;
|
|
}
|
|
else
|
|
{
|
|
enable_controls = true;
|
|
SUNMASTER.Auto_Cycle_Sky = false;
|
|
}
|
|
}
|
|
num2 += 20f;
|
|
float num6 = 50f;
|
|
GUI.TextArea(new Rect(5f, 5f * num2 + num6, 100f, 20f), "Sun Speed");
|
|
SPEED = GUI.HorizontalSlider(new Rect(10f, 5f * num2 + num6 + 30f, 100f, 30f), SPEED, 0.01f, 70f);
|
|
SUNMASTER.SPEED = SPEED;
|
|
if (enable_controls)
|
|
{
|
|
GUI.TextArea(new Rect(5f, 0f * num2 + num6, 150f, 20f), "Increase HDR brightness");
|
|
HDR = GUI.HorizontalSlider(new Rect(10f, 0f * num2 + num6 + 30f, 150f, 30f), HDR, 0.05f, 3f);
|
|
SUNMASTER.m_fExposure = HDR;
|
|
GUI.TextArea(new Rect(5f, 1f * num2 + num6, 150f, 20f), "Esun");
|
|
Esun = GUI.HorizontalSlider(new Rect(10f, 1f * num2 + num6 + 30f, 150f, 30f), Esun, 0.9f, 80f);
|
|
SUNMASTER.m_ESun = Esun;
|
|
GUI.TextArea(new Rect(5f, 2f * num2 + num6, 150f, 20f), "Kr - White to Red factor");
|
|
Kr = GUI.HorizontalSlider(new Rect(10f, 2f * num2 + num6 + 30f, 150f, 30f), Kr, 0.0001f, 0.014f);
|
|
SUNMASTER.m_Kr = Kr;
|
|
GUI.TextArea(new Rect(5f, 3f * num2 + num6, 150f, 20f), "Km - Vertical effect factor");
|
|
Km = GUI.HorizontalSlider(new Rect(10f, 3f * num2 + num6 + 30f, 150f, 30f), Km, 0.0003f, 0.1195f);
|
|
SUNMASTER.m_Km = Km;
|
|
GUI.TextArea(new Rect(5f, 4f * num2 + num6, 150f, 20f), "G - Focus factor");
|
|
GE = GUI.HorizontalSlider(new Rect(10f, 4f * num2 + num6 + 30f, 150f, 30f), GE, -0.69f, -0.9999f);
|
|
SUNMASTER.m_g = GE;
|
|
GUI.TextArea(new Rect(5f, 6f * num2 + num6, 100f, 20f), "Sun Ring factor");
|
|
Ring_factor = GUI.HorizontalSlider(new Rect(10f, 6f * num2 + num6 + 30f, 100f, 30f), Ring_factor, 0f, 0.15f);
|
|
SUNMASTER.Sun_ring_factor = Ring_factor;
|
|
GUI.TextArea(new Rect(5f, 7f * num2 + num6, 150f, 20f), "Samples");
|
|
fSamples = GUI.HorizontalSlider(new Rect(10f, 7f * num2 + num6 + 30f, 150f, 30f), fSamples, 1f, 4f);
|
|
SUNMASTER.m_fSamples = fSamples;
|
|
GUI.TextArea(new Rect(5f, 8f * num2 + num6, 150f, 20f), "Scale depth");
|
|
fScaleDepth = GUI.HorizontalSlider(new Rect(10f, 8f * num2 + num6 + 30f, 150f, 30f), fScaleDepth, 0.1f, 2f);
|
|
SUNMASTER.m_fRayleighScaleDepth = fScaleDepth;
|
|
Rect position = new Rect(num3 + 130f, num4 + 140f - 20f + 70f, 180f, 20f);
|
|
Vector3 cURRENT_Force_color = CURRENT_Force_color;
|
|
GUI.TextArea(position, "Tint: " + cURRENT_Force_color.ToString());
|
|
SUNMASTER.m_fWaveLength.x = GUI.HorizontalSlider(new Rect(num3 + 130f, num4 + 140f + 70f, 100f, 30f), SUNMASTER.m_fWaveLength.x, 0f, 1f);
|
|
CURRENT_Force_color.x = SUNMASTER.m_fWaveLength.x;
|
|
SUNMASTER.m_fWaveLength.y = GUI.HorizontalSlider(new Rect(num3 + 130f, num4 + 172f + 70f, 100f, 30f), SUNMASTER.m_fWaveLength.y, 0f, 1f);
|
|
CURRENT_Force_color.y = SUNMASTER.m_fWaveLength.y;
|
|
SUNMASTER.m_fWaveLength.z = GUI.HorizontalSlider(new Rect(num3 + 130f, num4 + 204f + 70f, 100f, 30f), SUNMASTER.m_fWaveLength.z, 0f, 1f);
|
|
CURRENT_Force_color.z = SUNMASTER.m_fWaveLength.z;
|
|
num3 = 50f;
|
|
num4 = 150f;
|
|
Rect position2 = new Rect(num3 + 130f, num4 + 140f - 20f + 70f, 180f, 20f);
|
|
Vector4 tintColor = TintColor;
|
|
GUI.TextArea(position2, "Global tint: " + tintColor.ToString());
|
|
SUNMASTER.m_TintColor.r = GUI.HorizontalSlider(new Rect(num3 + 130f, num4 + 140f + 70f, 100f, 30f), SUNMASTER.m_TintColor.r, 0f, 1f);
|
|
TintColor.x = SUNMASTER.m_TintColor.r;
|
|
SUNMASTER.m_TintColor.g = GUI.HorizontalSlider(new Rect(num3 + 130f, num4 + 172f + 70f, 100f, 30f), SUNMASTER.m_TintColor.g, 0f, 1f);
|
|
TintColor.y = SUNMASTER.m_TintColor.g;
|
|
SUNMASTER.m_TintColor.b = GUI.HorizontalSlider(new Rect(num3 + 130f, num4 + 204f + 70f, 100f, 30f), SUNMASTER.m_TintColor.b, 0f, 1f);
|
|
TintColor.z = SUNMASTER.m_TintColor.b;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
string text2 = "Spring";
|
|
if (SUNMASTER.Season == 2)
|
|
{
|
|
text2 = "Summer";
|
|
}
|
|
if (SUNMASTER.Season == 3)
|
|
{
|
|
text2 = "Autumn";
|
|
}
|
|
if (SUNMASTER.Season == 4)
|
|
{
|
|
text2 = "Winter";
|
|
}
|
|
GUI.TextArea(new Rect(5f * num + 10f, num2 + 30f + 30f, num, 30f), text2);
|
|
}
|
|
}
|
|
}
|
|
}
|