Exemplo n.º 1
0
        public void MoonRiseSetTest()
        {
            //Answers: http://aa.usno.navy.mil/data/docs/RS_OneDay.php

            DateTime date = new DateTime(2009, 10, 12);

            date = date.AddHours(7);
            Coordinate coord = new Coordinate(60, -5.3);
            //MoonRiseResult result = WeatherSystem.CalculateMoonRiseSet(coord, date);
            double jd = date.DtToJulianDay();

            //bool is_rise = true;
            GameConstants.RiseSetType   riseSetType   = GameConstants.RiseSetType.Lunar;
            GameConstants.TideEvent     tideEvent     = GameConstants.TideEvent.MoonSet;
            GameConstants.TideEventType tideEventType = GameConstants.TideEventType.NewMoon; //init only

            double jdout;

            AstronomyHelper.findNextRiseOrSet(date, coord, ref riseSetType, ref tideEvent, out jdout);
            DateTime timeMoonEvent = jdout.JdToDateTime(); //30Sept: Moonrise 17:07

            AstronomyHelper.findNextMoonPhase(date, out tideEventType);
            Debug.Write("Tide event type: " + tideEventType);
            Assert.IsTrue(tideEvent == GameConstants.TideEvent.MoonSet, "MoonSet 18:42ish on 30 sept 2030.");
            //Assert.IsTrue(result.IsMoonRise == true, "Moon rises on this date");
            //Assert.IsNotNull(result, "Result should not be null.");
        }
Exemplo n.º 2
0
        public void RecalculateMoonAndSunInformation()
        {
            if (GameManager.Instance.Game == null || Coordinate == null)
            {
                return;
            }
            DateTime date = GameManager.Instance.Game.GameCurrentTime;

            double jd = date.DtToJulianDay();

            JulianDay = jd;
            //bool is_rise = true;
            GameConstants.RiseSetType riseSetType = GameConstants.RiseSetType.Lunar;
            GameConstants.TideEvent   tideEvent   = GameConstants.TideEvent.MoonSet; //init
            double jdout;

            try
            {
                AstronomyHelper.findNextRiseOrSet(date, Coordinate, ref riseSetType, ref tideEvent, out jdout);
                TimeNextTideEvent = jdout.JdToDateTime();
                NextTideEvent     = tideEvent;
                IsMoonUp          = (NextTideEvent == GameConstants.TideEvent.MoonSet);
            }
            catch (Exception)
            {
                //TODO: Fix
                //GameManager.Instance.Log.LogError(
                //    string.Format("RecalculateMoonPhase failed for Time {0}, Coordinate {1}", date, Coordinate)
                //    + ". " + ex.Message);
            }
            //And now for the sun
            CurrentSunheightDeg      = WeatherSystem.CalculateSunHeightDeg(date, Coordinate);
            CurrentSunDeclinationDeg = WeatherSystem.CalculateSunDeclination(date, Coordinate);
            DateTimeFromTo SunRiseSet = WeatherSystem.CalculateSunRiseSunSet(date, Coordinate);

            if (SunRiseSet.FromTime != null)
            {
                SunriseTime  = (DateTime)SunRiseSet.FromTime;
                IsSunSetting = true;
            }
            else
            {
                IsSunSetting = false;
            }
            if (SunRiseSet.ToTime != null)
            {
                SunsetTime  = (DateTime)SunRiseSet.ToTime;
                IsSunRising = true;
            }
            else
            {
                IsSunSetting = false;
            }
        }