From f51e17af7bd6b6f1171a17acadbfa3b9090c8d07 Mon Sep 17 00:00:00 2001 From: Scionwest_cp Date: Thu, 19 Aug 2010 15:22:14 -0700 Subject: [PATCH] MudEngine: - Removed Game constructor setting default values for GameTime properties as the GameTime constructor does this already. - Finished the GameTime class. Now fully supports custom Day/Time lengths and keeps track of time in sync with the server time. --- MudEngine/GameManagement/Game.cs | 14 -------------- MudEngine/GameManagement/GameTime.cs | 27 +++++++++++++++++---------- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/MudEngine/GameManagement/Game.cs b/MudEngine/GameManagement/Game.cs index 418dad7..80b3b39 100644 --- a/MudEngine/GameManagement/Game.cs +++ b/MudEngine/GameManagement/Game.cs @@ -213,20 +213,6 @@ namespace MudEngine.GameManagement for (Int32 i = 0; i < MaximumPlayers; i++) PlayerCollection[i] = new BaseCharacter(this); - GameTime.Time t = new GameTime.Time(); - t.Hour = 8; - t.Minute = 0; - t.Second = 0; - t.Day = 1; - t.Month = 1; - t.Year = 2010; - WorldTime.InitialGameTime = t; - WorldTime.DaysPerMonth = 7; - WorldTime.MonthsPerYear = 12; - WorldTime.HoursPerDay = 23; - WorldTime.MinutesPerHour = 59; - WorldTime.SecondsPerMinute = 59; - AutoSave = true; AutoSaveInterval = 30; } diff --git a/MudEngine/GameManagement/GameTime.cs b/MudEngine/GameManagement/GameTime.cs index c1e3a5a..61aaa2c 100644 --- a/MudEngine/GameManagement/GameTime.cs +++ b/MudEngine/GameManagement/GameTime.cs @@ -129,8 +129,8 @@ namespace MudEngine.GameManagement Time t = new Time(); t.Second = 0; - t.Minute = 1; - t.Hour = 8; + t.Minute = 0; + t.Hour = 1; t.Day = 1; t.Month = 1; t.Year = 2010; @@ -142,9 +142,9 @@ namespace MudEngine.GameManagement DayTransitions = TimeOfDayOptions.Transition; - SecondsPerMinute = 60; - MinutesPerHour = 60; - HoursPerDay = 24; + SecondsPerMinute = 5; + MinutesPerHour = 5; + HoursPerDay = 5; DaysPerMonth = 31; MonthsPerYear = 12; @@ -155,6 +155,7 @@ namespace MudEngine.GameManagement { Time t = InitialGameTime; CurrentWorldTime = t; + CurrentSystemTime = DateTime.Now; } public virtual void Update() @@ -169,6 +170,7 @@ namespace MudEngine.GameManagement CurrentSystemTime = DateTime.Now; Int32 amount = Math.Abs(ts.Seconds); IncrementSecond(amount); + Log.Write(GetCurrentWorldTime()); } } @@ -179,9 +181,9 @@ namespace MudEngine.GameManagement if (CurrentWorldTime.Second == SecondsPerMinute) { - t.Second = 0; IncrementMinute(1); t = CurrentWorldTime; + t.Second = 0; } else if (CurrentWorldTime.Second > SecondsPerMinute) { @@ -204,8 +206,10 @@ namespace MudEngine.GameManagement if (CurrentWorldTime.Minute == MinutesPerHour) { - t.Minute = 0; IncrementHour(1); + t = CurrentWorldTime; + t.Minute = 0; + } else if (CurrentWorldTime.Minute > MinutesPerHour) { @@ -228,8 +232,9 @@ namespace MudEngine.GameManagement if (CurrentWorldTime.Hour == HoursPerDay) { - t.Hour = 0; IncrementDay(); + t = CurrentWorldTime; + t.Hour = 0; } else if (CurrentWorldTime.Hour > HoursPerDay) { @@ -253,8 +258,9 @@ namespace MudEngine.GameManagement //TODO: Finish GameTime syncing with Server Time. if (CurrentWorldTime.Day == DaysPerMonth) { - t.Day = 1; IncrementMonth(); + t = CurrentWorldTime; + t.Day = 1; } else t.Day++; @@ -269,8 +275,9 @@ namespace MudEngine.GameManagement if (CurrentWorldTime.Month == MonthsPerYear) { - t.Month = 1; IncrementYear(); + t = CurrentWorldTime; + t.Month = 1; } else t.Month++;