/// <summary> /// Switch to/from day to night /// </summary> /// <param name="sender">the day/night button</param> /// <param name="e">the mouse button event args</param> private void OnDay(object sender, MouseButtonEventArgs e) { if (this.isDay) { Night.Begin(); } else { Day.Begin(); } this.isDay = !this.isDay; }
public static Night Create() { Night instance = new Night(); instance.Add(new Steak()); Potato obj = new Potato(); obj.EnableMultipleOrder(); instance.Add(obj); instance.Add(new Wine()); instance.Add(new Cake()); return(instance); }
//------------------------------------------------------------- private void sendCmd(int src, bool fyes, PLAYER_STATE s1) { if (fyes) { var dat = game.net.CreateStoryCode.NightYes(src); dat.src = src; { var o = new Night(); o.run(dat); } } else { var dat = game.net.CreateStoryCode.NightNo(src); dat.src = src; { var o = new Night(); o.run(dat); } } Assert.AreEqual(GameFactory.getGame().shareData.players.getPlayer(src).state, s1); }
public void ReadBinary(ESPReader reader) { try { Sunrise.ReadBinary(reader); Day.ReadBinary(reader); Sunset.ReadBinary(reader); Night.ReadBinary(reader); HighNoon.ReadBinary(reader); Midnight.ReadBinary(reader); } catch { return; } }
public void NightChangeTest() { //expexted string expected = "У валiзi настав день!"; bool called = false; Mock.SetupStatic(typeof(Case)); Mock.Arrange(() => new Day()).DoInstead(() => called = true); //actual Night night = new Night(); string actual = night.Change(); Assert.AreEqual(expected, actual); Assert.IsTrue(called); }
public void NightCallEveryoneTest() { //expexted Mock.SetupStatic(typeof(Case)); List <string> expectedList = new List <string>() { "Усi тварини зараз сплять." }; //actual Night night = new Night(); List <string> actualList = new List <string>(); night.CallEveryone(actualList); Assert.AreEqual(expectedList[0], actualList[0]); }
private List <Night> NewDatesForCottage(List <DateTime> datesToAddList, AddBookingDaysDto allocateDaysDto, int currentUser) { var daysToAdd = new List <Night>(); foreach (var date in datesToAddList) { Night newDay = new Night { BookingDate = date, BookingStatus = BookingStatus.Available, Price = allocateDaysDto.Price, ModifiedBy = currentUser }; daysToAdd.Add(newDay); } return(daysToAdd); }
public void NightTest2() { Game gm = GameTest.createGame(); { var o = new Night(); o.init(); } sendCmd(1, true, PLAYER_STATE.NIGHT_SELECT_OK); sendCmd(2, true, PLAYER_STATE.NIGHT_SELECT_OK); sendCmd(3, false, PLAYER_STATE.NIGHT_SELECT_OK); sendCmd(4, false, PLAYER_STATE.NIGHT_SELECT_END); Assert.AreEqual(gm.shareData.field.yes, 2); Assert.AreEqual(gm.shareData.field.no, 2); Assert.AreEqual(gm.shareData.players.getPlayer(1).state, db.PLAYER_STATE.NIGHT_SELECT_END); Assert.AreEqual(gm.shareData.players.getPlayer(2).state, db.PLAYER_STATE.NIGHT_SELECT_END); Assert.AreEqual(gm.shareData.players.getPlayer(3).state, db.PLAYER_STATE.NIGHT_SELECT_END); Assert.AreEqual(gm.shareData.players.getPlayer(4).state, db.PLAYER_STATE.NIGHT_SELECT_END); }
static void Main(string[] args) { FamilyPayCalculator calc = new FamilyPayCalculator(); Night night = new Night("6:00PM", "11:00PM"); Family family = new FamilyA(); Console.WriteLine(calc.CalculatePay(family, night)); Night night2 = new Night("7:00PM", "1:00AM"); Family familyB = new FamilyB(); Console.WriteLine(calc.CalculatePay(familyB, night2)); Night night3 = new Night("7:00PM", "1:00AM"); Family familyC = new FamilyC(); Console.WriteLine(calc.CalculatePay(familyC, night3)); }
public int sitetaken(Night a) { int taken = 0; Db db = new Db(); SqlConnection conn = openconn(); String sql = "SELECT isnull(sum(case when CEILING(CAST(Applications.GroupSize AS float)/CAST(Campsites.GroupSize AS float)) >=CEILING(CAST(Applications.Tents AS float)/CAST(Campsites.Tents AS float)) then CEILING(CAST(Applications.GroupSize AS float)/CAST(Campsites.GroupSize AS float)) else CEILING(CAST(Applications.Tents AS float)/CAST(Campsites.Tents AS float)) end),0) as siteneeded FROM [PermitDB].[dbo].[Nights] join Applications on Applications.ApplicationId=Nights.ApplicationId join campsites on campsites.CampsiteId=Nights.CampsiteId where Date=@date and Status='Approve' and Campsites.CampsiteId=@campsiteid"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@date", a.Date); cmd.Parameters.AddWithValue("@campsiteid", a.Campsite.CampsiteId); SqlDataReader rdr = cmd.ExecuteReader(); if (rdr.Read()) { taken = Convert.ToInt32(rdr["siteneeded"]); } rdr.Close(); db.closeconn(conn); return(taken); }
public void WriteXML(XElement ele, ElderScrollsPlugin master) { XElement subEle; ele.TryPathTo("Sunrise", true, out subEle); Sunrise.WriteXML(subEle, master); ele.TryPathTo("Day", true, out subEle); Day.WriteXML(subEle, master); ele.TryPathTo("Sunset", true, out subEle); Sunset.WriteXML(subEle, master); ele.TryPathTo("Night", true, out subEle); Night.WriteXML(subEle, master); ele.TryPathTo("HighNoon", true, out subEle); HighNoon.WriteXML(subEle, master); ele.TryPathTo("Midnight", true, out subEle); Midnight.WriteXML(subEle, master); }
public void WriteTestFile() { Nights nights = new Nights(); nights.NightList = new List <Night>(); for (int i = 1; i <= 7; i++) { Night night = new Night() { StartTime = new DateTime(2018, 7, i, 20, 30, 00), EndTime = new DateTime(2018, 7, i + 1, 4 + i, 00, 00), }; night.TimeSleptInMinutes = night.EndTime.Subtract(night.StartTime).TotalMinutes; nights.NightList.Add(night); } FileStream fileStream = new FileStream(filename, FileMode.OpenOrCreate); XmlSerializer writer = new XmlSerializer(typeof(Nights)); writer.Serialize(fileStream, nights); fileStream.Flush(); fileStream.Dispose(); }
public void NightTest() { Game gm = GameTest.createGame(); { AStory night = new Night(); night.init(); } sendCmd(1, true, PLAYER_STATE.NIGHT_SELECT_OK); sendCmd(2, true, PLAYER_STATE.NIGHT_SELECT_OK); sendCmd(3, true, PLAYER_STATE.NIGHT_SELECT_OK); sendCmd(4, false, PLAYER_STATE.NIGHT_VOTE); Assert.AreEqual(gm.shareData.field.yes, 3); Assert.AreEqual(gm.shareData.field.no, 1); Assert.AreEqual(gm.shareData.players.getPlayer(1).state, db.PLAYER_STATE.NIGHT_VOTE); Assert.AreEqual(gm.shareData.players.getPlayer(2).state, db.PLAYER_STATE.NIGHT_VOTE); Assert.AreEqual(gm.shareData.players.getPlayer(3).state, db.PLAYER_STATE.NIGHT_VOTE); Assert.AreEqual(gm.shareData.players.getPlayer(4).state, db.PLAYER_STATE.NIGHT_VOTE); sendCmd2(1, 2, PLAYER_STATE.NIGHT_VOTE_OK); sendCmd2(2, 0, PLAYER_STATE.NIGHT_VOTE_OK); sendCmd2(3, 2, PLAYER_STATE.NIGHT_VOTE_OK); sendCmd2(4, 1, PLAYER_STATE.NIGHT_VOTE_END); Assert.AreEqual(gm.shareData.players.getPlayer(1).dayNightVote, 1); Assert.AreEqual(gm.shareData.players.getPlayer(2).dayNightVote, 2); Assert.AreEqual(gm.shareData.players.getPlayer(3).dayNightVote, 0); Assert.AreEqual(gm.shareData.players.getPlayer(4).dayNightVote, 0); Assert.AreEqual(gm.shareData.field.captivity, 2); // end Assert.IsTrue(gm.shareData.players.isAllPlayerState(PLAYER_STATE.NIGHT_VOTE_END)); }
protected void LateUpdate() { #if UNITY_EDITOR Cycle.CheckRange(); Atmosphere.CheckRange(); Stars.CheckRange(); Day.CheckRange(); Night.CheckRange(); Sun.CheckRange(); Moon.CheckRange(); Light.CheckRange(); Clouds.CheckRange(); World.CheckRange(); Fog.CheckRange(); Ambient.CheckRange(); Reflection.CheckRange(); #endif SetupQualitySettings(); SetupSunAndMoon(); SetupScattering(); SetupRenderSettings(); SetupShaderProperties(); }
private void add_Click(object sender, EventArgs e) { if (City_dpt.Text != "" && Country.Text != "" && Name.Text != "" && Price.Text != "" && Date.Text != "" && Night.Text != "") { DialogResult dr = MessageBox.Show("Добавить запись?", "Добавление", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (dr == DialogResult.OK) { bool flag = false; for (int i = 0; i < tour.Count; i++) { if (City_dpt.Text == tour[i].City && Country.Text == tour[i].Country1 && Name.Text == tour[i].Name1 && Price.Text == tour[i].Price1 && Date.Text == tour[i].dateofdep.ToString() && Night.Text == tour[i].numberofnights) { flag = true; } } if (!flag) { this.Validate(); this.toursBindingSource.EndEdit(); DataRow nRow = tiuDataSet2.Tables[0].NewRow(); nRow["Город отправления"] = City_dpt.Text.ToString(); nRow["Страна назначения"] = Country.Text.ToString(); nRow["Название тура"] = Name.Text.ToString(); CultureInfo MyCultureInfo = new CultureInfo("en-US"); nRow["Стоимость"] = Price.Text.ToString(); nRow["Дата вылета"] = DateTime.ParseExact(Date.Text.ToString(), "dd.M.yyyy", MyCultureInfo); nRow["Количество ночей"] = Night.Text.ToString(); tiuDataSet2.Tables[0].Rows.Add(nRow); toursTableAdapter.Update(tiuDataSet2.Tours); tiuDataSet2.Tables[0].AcceptChanges(); TuiTour.Refresh(); Fn.update(this.TuiTour, this.tour); City_dpt.Clear(); Country.Clear(); Name.Clear(); Price.Clear(); Date.Clear(); Night.Clear(); } if (flag) { DialogResult er = MessageBox.Show("Такая запись уже существует!", "Добавление", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); } } } else { DialogResult dr = MessageBox.Show("Некорректный ввод! Поля пусты.", "Добавление", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } }
void InitSwaps() { Angry.setPosition(new Position(Level.Excluded, Circle.Green)); Blessing.setPosition(new Position(Level.Excluded, Circle.Purple)); Child.setPosition(new Position(Level.Excluded, Circle.Red)); Curse.setPosition(new Position(Level.Excluded, Circle.Cyan)); Heaven.setPosition(new Position(Level.Tertiary, Circle.GreenPurpleRed)); Happiness.setPosition(new Position(Level.Tertiary, Circle.GreenRedCyan)); Dragon.setPosition(new Position(Level.Tertiary, Circle.RedCyanPurple)); Dream.setPosition(new Position(Level.Secondary, Circle.CyanRed)); Energy.setPosition(new Position(Level.Secondary, Circle.GreenRed)); Female.setPosition(new Position(Level.Secondary, Circle.CyanPurple)); Force.setPosition(new Position(Level.Quaternary, Circle.GreenRedCyanPurple)); Forest.setPosition(new Position(Level.Excluded, Circle.Purple)); Friend.setPosition(new Position(Level.Secondary, Circle.GreenPurple)); Hate.setPosition(new Position(Level.Secondary, Circle.GreenPurple)); Hope.setPosition(new Position(Level.Excluded, Circle.Green)); Kindness.setPosition(new Position(Level.Tertiary, Circle.CyanPurpleGreen)); Longevity.setPosition(new Position(Level.Secondary, Circle.CyanPurple)); Love.setPosition(new Position(Level.Secondary, Circle.CyanPurple)); Loyal.setPosition(new Position(Level.Secondary, Circle.GreenRed)); Spirit.setPosition(new Position(Level.Secondary, Circle.CyanRed)); Male.setPosition(new Position(Level.Quaternary, Circle.GreenRedCyanPurple)); Mountain.setPosition(new Position(Level.Secondary, Circle.GreenRed)); Night.setPosition(new Position(Level.Excluded, Circle.Red)); Pure.setPosition(new Position(Level.Secondary, Circle.GreenPurple)); Heart.setPosition(new Position(Level.Secondary, Circle.CyanRed)); River.setPosition(new Position(Level.Excluded, Circle.Cyan)); Emotion.setPosition(new Position(Level.Excluded, Circle.Cyan)); Soul.setPosition(new Position(Level.Excluded, Circle.Purple)); Urgency.setPosition(new Position(Level.Excluded, Circle.Red)); Wind.setPosition(new Position(Level.Excluded, Circle.Green)); Debug.LogFormat("[Dragon Energy #{0}] Before swapping, the displayed words are:", _moduleId); for (int i = 0; i < displayed.Length; i++) { Debug.LogFormat("[Dragon Energy #{0}] {1} = {2}", _moduleId, displayed[i].getWord(), displayed[i].getPosition().getCircle().ToReadable()); } char[] letters = info.GetSerialNumberLetters().ToArray(); int vowelCount = 0; foreach (char letter in letters) { if (letter == 'A' || letter == 'E' || letter == 'I' || letter == 'O' || letter == 'U') { vowelCount++; } } if (info.GetBatteryCount() > 10 && (info.GetSerialNumberNumbers().ToArray()[info.GetSerialNumberNumbers().ToArray().Length - 1] == 5 || info.GetSerialNumberNumbers().ToArray()[info.GetSerialNumberNumbers().ToArray().Length - 1] == 7)) { Swaps(1); } else if (info.GetPortPlateCount() > info.GetBatteryHolderCount() && (modules.Contains("Morse War") || modules.Contains("Double Color"))) { Swaps(2); } else if ((info.IsIndicatorOn(Indicator.SIG) && info.IsIndicatorOn(Indicator.FRK)) || (info.GetOffIndicators().Count() == 3)) { Swaps(3); } else if (info.GetModuleNames().Count() > 8) { Swaps(4); } else if (vowelCount >= 2) { Swaps(5); } else if (info.GetSolvedModuleNames().Count() == 0) { Swaps(6); dependsOnSolvedModules = true; } else { Swaps(7); } Debug.LogFormat("[Dragon Energy #{0}] After swapping, the displayed words are:", _moduleId); for (int i = 0; i < displayed.Length; i++) { Debug.LogFormat("[Dragon Energy #{0}] {1} = {2}", _moduleId, displayed[i].getWord(), displayed[i].getPosition().getCircle().ToReadable()); } }
public void whenCalculatePayHasFractionalEarlyHoursOnlyItPaysOnlyWholeHours() { Night endAtEightThirtyPM = new Night("5:00PM", "8:30PM"); Assert.AreEqual(36.0, calc.CalculatePay(family, endAtEightThirtyPM)); }
public override string ToString() => $"Root: [Symbol: {Symbol.Map(x => x.ToString()).Join(", ")}, Wind: {Winds.Map(x => x.ToString()).Join(", ")}, Day: {Day.Map(x => x.ToString()).Join(", ")}, Night: {Night.Map(x => x.ToString()).Join(", ")}, Cloud: {Cloud.Map(x => x.ToString()).Join(", ")}]";
public Task<Night> InsertNight(Night night) { throw new NotImplementedException(); }
public void whenNightStartsAfterEarlyHoursCalculatesCorrectPay() { Night noEarlyHours = new Night("11:00PM", "1:00AM"); Assert.AreEqual(24.0, calc.CalculatePay(family, noEarlyHours)); }
public void whenCalculatePayHasFractionalLateHoursItPaysOnlyWholeHours() { Night endAtFraction = new Night("9:00PM", "2:37AM"); Assert.AreEqual(60.0, calc.CalculatePay(family, endAtFraction)); }
public void whenCalculatePayHasFractionalMiddleHoursItPaysOnlyWholeHours() { Night endAtElevenThirtyPM = new Night("7:00PM", "11:30PM"); Assert.AreEqual(44.0, calc.CalculatePay(family, endAtElevenThirtyPM)); }
public void AddNewNight(Night night) { XmlDocument document = new XmlDocument(); document.Load(filename); }
protected void Update() { Cycle.CheckRange(); #if UNITY_EDITOR Atmosphere.CheckRange(); Stars.CheckRange(); Day.CheckRange(); Night.CheckRange(); Light.CheckRange(); Clouds.CheckRange(); World.CheckRange(); #endif SetupQualitySettings(); SetupSunAndMoon(); SetupScattering(); // Setup render settings { if (World.SetFogColor) { var fogColor = SampleFogColor(); #if UNITY_EDITOR if (RenderSettings.fogColor != fogColor) #endif { RenderSettings.fogColor = fogColor; } } if (World.SetAmbientLight) { var ambientLight = SampleAmbientColor(); #if UNITY_EDITOR if (RenderSettings.ambientLight != ambientLight) #endif { RenderSettings.ambientLight = ambientLight; } } } // Precalculations Vector4 cloudUV = Components.Animation.CloudUV + Components.Animation.OffsetUV; // Setup global shader parameters { Shader.SetGlobalFloat("TOD_Gamma", Gamma); Shader.SetGlobalFloat("TOD_OneOverGamma", OneOverGamma); Shader.SetGlobalColor("TOD_LightColor", LightColor); Shader.SetGlobalColor("TOD_CloudColor", CloudColor); Shader.SetGlobalColor("TOD_SunColor", SunColor); Shader.SetGlobalColor("TOD_MoonColor", MoonColor); Shader.SetGlobalColor("TOD_AdditiveColor", AdditiveColor); Shader.SetGlobalColor("TOD_MoonHaloColor", MoonHaloColor); Shader.SetGlobalVector("TOD_SunDirection", SunDirection); Shader.SetGlobalVector("TOD_MoonDirection", MoonDirection); Shader.SetGlobalVector("TOD_LightDirection", LightDirection); Shader.SetGlobalVector("TOD_LocalSunDirection", Components.DomeTransform.InverseTransformDirection(SunDirection)); Shader.SetGlobalVector("TOD_LocalMoonDirection", Components.DomeTransform.InverseTransformDirection(MoonDirection)); Shader.SetGlobalVector("TOD_LocalLightDirection", Components.DomeTransform.InverseTransformDirection(LightDirection)); } // Setup atmosphere shader if (Components.AtmosphereShader != null) { Components.AtmosphereShader.SetFloat("_Contrast", Atmosphere.Contrast * OneOverGamma); Components.AtmosphereShader.SetFloat("_Haziness", Atmosphere.Haziness); Components.AtmosphereShader.SetFloat("_Fogginess", Atmosphere.Fogginess); Components.AtmosphereShader.SetFloat("_Horizon", World.HorizonOffset); Components.AtmosphereShader.SetVector("_OpticalDepth", opticalDepth); Components.AtmosphereShader.SetVector("_OneOverBeta", oneOverBeta); Components.AtmosphereShader.SetVector("_BetaRayleigh", betaRayleigh); Components.AtmosphereShader.SetVector("_BetaRayleighTheta", betaRayleighTheta); Components.AtmosphereShader.SetVector("_BetaMie", betaMie); Components.AtmosphereShader.SetVector("_BetaMieTheta", betaMieTheta); Components.AtmosphereShader.SetVector("_BetaMiePhase", betaMiePhase); Components.AtmosphereShader.SetVector("_BetaNight", betaNight); } // Setup cloud shader if (Components.CloudShader != null) { float sunGlow = (1 - Atmosphere.Fogginess) * LerpValue; float moonGlow = (1 - Atmosphere.Fogginess) * 0.6f * (1 - Mathf.Abs(Cycle.MoonPhase)); Components.CloudShader.SetFloat("_SunGlow", sunGlow); Components.CloudShader.SetFloat("_MoonGlow", moonGlow); Components.CloudShader.SetFloat("_CloudDensity", Clouds.Density); Components.CloudShader.SetFloat("_CloudSharpness", Clouds.Sharpness); Components.CloudShader.SetFloat("_CloudScale1", Clouds.Scale1); Components.CloudShader.SetFloat("_CloudScale2", Clouds.Scale2); Components.CloudShader.SetVector("_CloudUV", cloudUV); } // Setup space shader if (Components.SpaceShader != null) { Components.SpaceShader.mainTextureScale = new Vector2(Stars.Tiling, Stars.Tiling); Components.SpaceShader.SetFloat("_Subtract", 1 - Mathf.Pow(Stars.Density, 0.1f)); } // Setup sun shader if (Components.SunShader != null) { Components.SunShader.SetColor("_Color", Day.SunMeshColor * LerpValue * (1 - Atmosphere.Fogginess)); } // Setup moon shader if (Components.MoonShader != null) { Components.MoonShader.SetColor("_Color", Night.MoonMeshColor); Components.MoonShader.SetFloat("_Phase", Cycle.MoonPhase); } // Setup shadow shader if (Components.ShadowShader != null) { float shadowAlpha = Clouds.ShadowStrength * Mathf.Clamp01(1f - LightZenith / 90f); Components.ShadowShader.SetFloat("_Alpha", shadowAlpha); Components.ShadowShader.SetFloat("_CloudDensity", Clouds.Density); Components.ShadowShader.SetFloat("_CloudSharpness", Clouds.Sharpness); Components.ShadowShader.SetFloat("_CloudScale1", Clouds.Scale1); Components.ShadowShader.SetFloat("_CloudScale2", Clouds.Scale2); Components.ShadowShader.SetVector("_CloudUV", cloudUV); } // Setup shadow projector if (Components.ShadowProjector != null) { var enabled = Clouds.ShadowStrength != 0 && Components.ShadowShader != null; var farClipPlane = Radius * 2; var orthographicSize = Radius; #if UNITY_EDITOR if (Components.ShadowProjector.enabled != enabled) #endif { Components.ShadowProjector.enabled = enabled; } #if UNITY_EDITOR if (Components.ShadowProjector.farClipPlane != farClipPlane) #endif { Components.ShadowProjector.farClipPlane = farClipPlane; } #if UNITY_EDITOR if (Components.ShadowProjector.orthographicSize != orthographicSize) #endif { Components.ShadowProjector.orthographicSize = orthographicSize; } } }
protected bool Equals(Temp other) { return(Day.Equals(other.Day) && Min.Equals(other.Min) && Max.Equals(other.Max) && Night.Equals(other.Night) && Eve.Equals(other.Eve) && Morn.Equals(other.Morn)); }
public void whenGetMiddleHoursHasMaxHoursWorkedReturnsHoursWorkedInThatWindow() { Night night = new Night("5:00PM", "1:00AM"); Assert.AreEqual(2.0, calc.getMiddleHoursWorked(family, night)); }
public void whenGetMiddleHoursHasPartialHoursWorkedInThatWindowReturnsPartialHours() { Night night = new Night("5:00PM", "11:00PM"); Assert.AreEqual(1.0, calc.getMiddleHoursWorked(family, night)); }
public void whenCalculatePayIsCalledForFamilyWithEarlyAndMiddleAndLateRateHoursItReturnsCorrectDollars() { Night night = new Night("8:00PM", "2:00AM"); Assert.AreEqual(72.0, calc.CalculatePay(family, night)); }
public void whenNightHasOnlyLateHoursCalculatesCorrectPay() { Night allLateHours = new Night("12:00AM", "3:00AM"); Assert.AreEqual(48.0, calc.CalculatePay(family, allLateHours)); }
public Task<Night> UpdateNight(Night night) { throw new NotImplementedException(); }
public void whenGetEarlyHoursIsGivenEndTimeAfterEarlyCutoffItReturnsOnlyHoursBeforeCutoff() { Night night = new Night("5:00PM", "1:00AM"); Assert.AreEqual(5.0, calc.getEarlyHoursWorked(family, night)); }
protected void Update() { // If sun shafts are being used we have to assure that the alpha values in the render buffer are sane if (Components.SunShafts != null && Components.SunShafts.enabled) { if (!Components.ClearRenderer.enabled) { Components.ClearRenderer.enabled = true; } } else if (Components.ClearRenderer.enabled) { Components.ClearRenderer.enabled = false; } // The cycle should never have insane values Cycle.CheckRange(); // Those parameters only need verification in editor mode #if UNITY_EDITOR Atmosphere.CheckRange(); Stars.CheckRange(); Day.CheckRange(); Night.CheckRange(); Light.CheckRange(); Clouds.CheckRange(); World.CheckRange(); #endif // Setup child objects SetupQualitySettings(); SetupSunAndMoon(); SetupScattering(); // Setup render settings if (World.SetFogColor) { GlobalFogColor = SampleFogColor(); LocalFogColor = Color.Lerp(SampleLocalFogColor(), Color.black, 0.25f); #if UNITY_EDITOR if (RenderSettings.fogColor != GlobalFogColor) //LocalFogColor) #endif { RenderSettings.fogColor = GlobalFogColor; //LocalFogColor; } } if (World.SetAmbientLight) { #if UNITY_EDITOR if (RenderSettings.ambientLight != AmbientColor && !Application.isPlaying) #endif { RenderSettings.ambientLight = AmbientColor; } } // Precalculations Vector4 cloudUV = Components.Animation.CloudUV + Components.Animation.OffsetUV; // Setup global shader parameters { Shader.SetGlobalFloat("TOD_Gamma", Gamma); Shader.SetGlobalFloat("TOD_OneOverGamma", OneOverGamma); Shader.SetGlobalColor("TOD_LightColor", LightColor); Shader.SetGlobalColor("TOD_CloudColor", CloudColor); Shader.SetGlobalColor("TOD_SunColor", SunColor); Shader.SetGlobalColor("TOD_MoonColor", MoonColor); Shader.SetGlobalColor("TOD_AdditiveColor", AdditiveColor); Shader.SetGlobalColor("TOD_MoonHaloColor", MoonHaloColor); Shader.SetGlobalVector("TOD_SunDirection", SunDirection); Shader.SetGlobalVector("TOD_MoonDirection", MoonDirection); Shader.SetGlobalVector("TOD_LightDirection", LightDirection); Shader.SetGlobalVector("TOD_LocalSunDirection", Components.DomeTransform.InverseTransformDirection(SunDirection)); Shader.SetGlobalVector("TOD_LocalMoonDirection", Components.DomeTransform.InverseTransformDirection(MoonDirection)); Shader.SetGlobalVector("TOD_LocalLightDirection", Components.DomeTransform.InverseTransformDirection(LightDirection)); // Components.FogShader.SetFloat("TOD_Gamma", Gamma); // Components.FogShader.SetFloat("TOD_OneOverGamma", OneOverGamma); // Components.FogShader.SetColor("TOD_LightColor", LightColor); // Components.FogShader.SetColor("TOD_CloudColor", CloudColor); // Components.FogShader.SetColor("TOD_SunColor", SunColor); // Components.FogShader.SetColor("TOD_MoonColor", MoonColor); // Components.FogShader.SetColor("TOD_AdditiveColor", AdditiveColor); // Components.FogShader.SetColor("TOD_MoonHaloColor", MoonHaloColor); // // Components.FogShader.SetVector("TOD_SunDirection", SunDirection); // Components.FogShader.SetVector("TOD_MoonDirection", MoonDirection); // Components.FogShader.SetVector("TOD_LightDirection", LightDirection); // // Components.FogShader.SetVector("TOD_LocalSunDirection", // Components.DomeTransform.InverseTransformDirection(SunDirection)); // Components.FogShader.SetVector("TOD_LocalMoonDirection", // Components.DomeTransform.InverseTransformDirection(MoonDirection)); // Components.FogShader.SetVector("TOD_LocalLightDirection", // Components.DomeTransform.InverseTransformDirection(LightDirection)); // Components.FogShader.SetColor ("_FogColor", RenderSettings.fogColor); } // Setup atmosphere shader if (Components.AtmosphereShader != null) { Components.AtmosphereShader.SetFloat("_Contrast", SpaceMode ? 1.5f : Atmosphere.Contrast * OneOverGamma); Components.AtmosphereShader.SetFloat("_Haziness", SpaceMode ? 0f : Atmosphere.Haziness); Components.AtmosphereShader.SetFloat("_Fogginess", SpaceMode ? 0f : Atmosphere.Fogginess); Components.AtmosphereShader.SetFloat("_Horizon", World.HorizonOffset); Components.AtmosphereShader.SetVector("_OpticalDepth", opticalDepth); Components.AtmosphereShader.SetVector("_OneOverBeta", oneOverBeta); Components.AtmosphereShader.SetVector("_BetaRayleigh", betaRayleigh); Components.AtmosphereShader.SetVector("_BetaRayleighTheta", betaRayleighTheta); Components.AtmosphereShader.SetVector("_BetaMie", betaMie); Components.AtmosphereShader.SetVector("_BetaMieTheta", betaMieTheta); Components.AtmosphereShader.SetVector("_BetaMiePhase", betaMiePhase); Components.AtmosphereShader.SetVector("_BetaNight", betaNight); // Components.FogShader.SetFloat("_Contrast", Atmosphere.Contrast * OneOverGamma); // Components.FogShader.SetFloat("_Haziness", Atmosphere.Haziness); // Components.FogShader.SetFloat("_Fogginess", Atmosphere.Fogginess); // Components.FogShader.SetFloat("_Horizon", World.HorizonOffset); // Components.FogShader.SetVector("_OpticalDepth", opticalDepth); // Components.FogShader.SetVector("_OneOverBeta", oneOverBeta); // Components.FogShader.SetVector("_BetaRayleigh", betaRayleigh); // Components.FogShader.SetVector("_BetaRayleighTheta", betaRayleighTheta); // Components.FogShader.SetVector("_BetaMie", betaMie); // Components.FogShader.SetVector("_BetaMieTheta", betaMieTheta); // Components.FogShader.SetVector("_BetaMiePhase", betaMiePhase); // Components.FogShader.SetVector("_BetaNight", betaNight); } // Setup cloud shader if (Components.CloudShader != null) { float sunGlow = (1 - Atmosphere.Fogginess) * LerpValue; float moonGlow = (1 - Atmosphere.Fogginess) * 0.6f * (1 - Mathf.Abs(Cycle.MoonPhase)); Components.CloudShader.SetFloat("_SunGlow", sunGlow); Components.CloudShader.SetFloat("_MoonGlow", moonGlow); Components.CloudShader.SetFloat("_CloudDensity", SpaceMode ? 0f : Clouds.Density); Components.CloudShader.SetFloat("_CloudSharpness", Clouds.Sharpness); Components.CloudShader.SetVector("_CloudScale1", Clouds.Scale1); Components.CloudShader.SetVector("_CloudScale2", Clouds.Scale2); Components.CloudShader.SetVector("_CloudUV", cloudUV); } // Setup space shader if (Components.SpaceShader != null) { var mainTextureScale = new Vector2(Stars.Tiling, Stars.Tiling); #if UNITY_EDITOR if (Components.SpaceShader.mainTextureScale != mainTextureScale) #endif { Components.SpaceShader.mainTextureScale = mainTextureScale; } Components.SpaceShader.SetFloat("_Subtract", 1 - Mathf.Pow(Stars.Density, 0.1f)); } // Setup sun shader if (Components.SunShader != null) { Components.SunShader.SetColor("_Color", Day.SunMeshColor * LerpValue * (1 - Atmosphere.Fogginess)); } // Setup moon shader if (Components.MoonShader != null) { Components.MoonShader.SetColor("_Color", Night.MoonMeshColor); Components.MoonShader.SetFloat("_Phase", Cycle.MoonPhase); } // Setup shadow shader if (Components.ShadowShader != null) { float shadowAlpha = Clouds.ShadowStrength * Mathf.Clamp01(1f - LightZenith / 90f); Components.ShadowShader.SetFloat("_Alpha", shadowAlpha); Components.ShadowShader.SetFloat("_CloudDensity", SpaceMode ? 0f : Clouds.Density); Components.ShadowShader.SetFloat("_CloudSharpness", Clouds.Sharpness); Components.ShadowShader.SetVector("_CloudScale1", Clouds.Scale1); Components.ShadowShader.SetVector("_CloudScale2", Clouds.Scale2); Components.ShadowShader.SetVector("_CloudUV", cloudUV); } // Setup shadow projector if (Components.ShadowProjector != null) { var enabled = Clouds.ShadowStrength != 0 && Components.ShadowShader != null; var farClipPlane = Radius * 2; var orthographicSize = Radius; #if UNITY_EDITOR if (Components.ShadowProjector.enabled != enabled) #endif { Components.ShadowProjector.enabled = enabled; } #if UNITY_EDITOR if (Components.ShadowProjector.farClipPlane != farClipPlane) #endif { Components.ShadowProjector.farClipPlane = farClipPlane; } #if UNITY_EDITOR if (Components.ShadowProjector.orthographicSize != orthographicSize) #endif { Components.ShadowProjector.orthographicSize = orthographicSize; } } }