コード例 #1
0
ファイル: Database.cs プロジェクト: draek/circle-sharp
        private void ResetTime()
        {
            if (GlobalSettings.BeginningOfTime == 0)
            {
                GlobalSettings.BeginningOfTime = DateTime.Now.Ticks; // FIXME: Could figure out something that puts the date at something reasonable?
                GlobalSettings.Save();
            }

            _timeInfo = MudTimePassed (DateTime.Now, new DateTime(GlobalSettings.BeginningOfTime));

            if (_timeInfo.Hours <= 4)
                _weatherInfo.Sun = SunState.Dark;
            else if (_timeInfo.Hours == 5)
                _weatherInfo.Sun = SunState.Rise;
            else if (_timeInfo.Hours <= 20)
                _weatherInfo.Sun = SunState.Light;
            else if (_timeInfo.Hours == 21)
                _weatherInfo.Sun = SunState.Set;
            else
                _weatherInfo.Sun = SunState.Dark;

            Log ("  Current Game Time: " + _timeInfo.Hours + "H " + _timeInfo.Day + "D " + _timeInfo.Month + "M " + _timeInfo.Year + "Y.");

            _weatherInfo.Pressure = 960;

            if ((_timeInfo.Month >= 7) && (_timeInfo.Month <= 12))
                _weatherInfo.Pressure += GlobalUtilities.Dice (1, 50);
            else
                _weatherInfo.Pressure += GlobalUtilities.Dice (1, 80);

            _weatherInfo.Change = 0;

            if (_weatherInfo.Pressure <= 980)
                _weatherInfo.Sky = SkyState.Lightning;
            else if (_weatherInfo.Pressure <= 1000)
                _weatherInfo.Sky = SkyState.Raining;
            else if (_weatherInfo.Pressure <= 1020)
                _weatherInfo.Sky = SkyState.Cloudy;
            else
                _weatherInfo.Sky = SkyState.Cloudless;
        }
コード例 #2
0
ファイル: Database.cs プロジェクト: draek/circle-sharp
        private TimeInfoData MudTimePassed(DateTime t2, DateTime t1)
        {
            TimeSpan span = t2 - t1;
            long seconds = span.Seconds + (span.Minutes * 60) + (span.Hours * 3600) + (span.Days * 3600 * 24);

            long mudhours = (seconds / GlobalConstants.SECS_PER_MUD_HOUR) % 24;
            long muddays = (seconds / GlobalConstants.SECS_PER_MUD_DAY) % 35;
            long mudmonths = (seconds / GlobalConstants.SECS_PER_MUD_MONTH) % 17;
            long mudyears = (seconds / GlobalConstants.SECS_PER_MUD_YEAR);

            TimeInfoData now = new TimeInfoData (mudhours, muddays, mudmonths, mudyears);

            return (now);
        }