Beispiel #1
0
    // Start is called before the first frame update
    void Start()
    {
        lightArray       = GameObject.FindGameObjectsWithTag("ActivatableLight");
        lightIntensities = new float[lightArray.Length];

        sunlight  = GetComponent <Light>();
        DawnCall += Afternon;
        DuskCall += Morning;
    }
Beispiel #2
0
 void MakeSunny()
 {
     if (WeatherNow != Weather.Sunny)
     {
         WeatherNow = Weather.Sunny;
         Log("Weather now: Sunny", ConsoleColor.DarkCyan);
         SunEvent?.Invoke();
     }
 }
Beispiel #3
0
        private void set_sun(SunEvent sunevent)
        {
            if (OnSunEvent != null)
            {
                OnSunEvent(sunevent);
            }

            switch (sunevent)
            {
            case SunEvent.Sunrise:
                if (OnSunrise != null)
                {
                    OnSunrise(sunevent);
                }
                break;

            case SunEvent.Sunset:
                if (OnSunset != null)
                {
                    OnSunset(sunevent);
                }
                break;
            }
        }
Beispiel #4
0
 // Start is called before the first frame update
 void Start()
 {
     sunlight  = GetComponent <Light>();
     DawnCall += Afternon;
     DuskCall += Morning;
 }
        /// <summary>
        /// Calculates time of the Equinox and Solstice.
        /// </summary>
        /// <param name="year">Year to calculate for.</param>
        /// <param name="sunEvent">Event to calculate.</param>
        /// <returns>Date and time event occurs as a fractional Julian Day.</returns>
        public static DateTime GetSunEventUtc(this int year, SunEvent sunEvent)
        {
            double y;
            double julianEphemerisDay;

            if (year >= 1000)
            {
                y = (Math.Floor((double)year) - 2000) / 1000;

                switch (sunEvent)
                {
                case SunEvent.VernalEquinox:
                    julianEphemerisDay = 2451623.80984 + 365242.37404 * y + 0.05169 * (y * y) - 0.00411 * (y * y * y) - 0.00057 * (y * y * y * y);
                    break;

                case SunEvent.SummerSolstice:
                    julianEphemerisDay = 2451716.56767 + 365241.62603 * y + 0.00325 * (y * y) - 0.00888 * (y * y * y) - 0.00030 * (y * y * y * y);
                    break;

                case SunEvent.AutumnalEquinox:
                    julianEphemerisDay = 2451810.21715 + 365242.01767 * y + 0.11575 * (y * y) - 0.00337 * (y * y * y) - 0.00078 * (y * y * y * y);
                    break;

                case SunEvent.WinterSolstice:
                    julianEphemerisDay = 2451900.05952 + 365242.74049 * y + 0.06223 * (y * y) - 0.00823 * (y * y * y) - 0.00032 * (y * y * y * y);
                    break;

                default:
                    throw new NotSupportedException();
                }
            }
            else
            {
                y = Math.Floor((double)year) / 1000;

                switch (sunEvent)
                {
                case SunEvent.VernalEquinox:
                    julianEphemerisDay = 1721139.29189 + 365242.13740 * y + 0.06134 * (y * y) - 0.00111 * (y * y * y) - 0.00071 * (y * y * y * y);
                    break;

                case SunEvent.SummerSolstice:
                    julianEphemerisDay = 1721233.25401 + 365241.72562 * y + 0.05323 * (y * y) - 0.00907 * (y * y * y) - 0.00025 * (y * y * y * y);
                    break;

                case SunEvent.AutumnalEquinox:
                    julianEphemerisDay = 1721325.70455 + 365242.49558 * y + 0.11677 * (y * y) - 0.00297 * (y * y * y) - 0.00074 * (y * y * y * y);
                    break;

                case SunEvent.WinterSolstice:
                    julianEphemerisDay = 1721414.39987 + 365242.88257 * y + 0.00769 * (y * y) - 0.00933 * (y * y * y) - 0.00006 * (y * y * y * y);
                    break;

                default:
                    throw new NotSupportedException();
                }
            }

            var julianCenturies = (julianEphemerisDay - 2451545.0) / 36525;

            var w = 35999.373 * julianCenturies - 2.47;

            var lambda = 1 + 0.0334 * Math.Cos(w * Deg2Radian) + 0.0007 * Math.Cos(2 * w * Deg2Radian);

            var sumOfPeriodicTerms = getSumOfPeriodicTerms(julianCenturies);

            return(JulianToUtcDate(julianEphemerisDay + (0.00001 * sumOfPeriodicTerms / lambda)));
        }