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.
This commit is contained in:
parent
f3b4c40010
commit
f51e17af7b
2 changed files with 17 additions and 24 deletions
|
@ -213,20 +213,6 @@ namespace MudEngine.GameManagement
|
||||||
for (Int32 i = 0; i < MaximumPlayers; i++)
|
for (Int32 i = 0; i < MaximumPlayers; i++)
|
||||||
PlayerCollection[i] = new BaseCharacter(this);
|
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;
|
AutoSave = true;
|
||||||
AutoSaveInterval = 30;
|
AutoSaveInterval = 30;
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,8 +129,8 @@ namespace MudEngine.GameManagement
|
||||||
|
|
||||||
Time t = new Time();
|
Time t = new Time();
|
||||||
t.Second = 0;
|
t.Second = 0;
|
||||||
t.Minute = 1;
|
t.Minute = 0;
|
||||||
t.Hour = 8;
|
t.Hour = 1;
|
||||||
t.Day = 1;
|
t.Day = 1;
|
||||||
t.Month = 1;
|
t.Month = 1;
|
||||||
t.Year = 2010;
|
t.Year = 2010;
|
||||||
|
@ -142,9 +142,9 @@ namespace MudEngine.GameManagement
|
||||||
|
|
||||||
DayTransitions = TimeOfDayOptions.Transition;
|
DayTransitions = TimeOfDayOptions.Transition;
|
||||||
|
|
||||||
SecondsPerMinute = 60;
|
SecondsPerMinute = 5;
|
||||||
MinutesPerHour = 60;
|
MinutesPerHour = 5;
|
||||||
HoursPerDay = 24;
|
HoursPerDay = 5;
|
||||||
DaysPerMonth = 31;
|
DaysPerMonth = 31;
|
||||||
MonthsPerYear = 12;
|
MonthsPerYear = 12;
|
||||||
|
|
||||||
|
@ -155,6 +155,7 @@ namespace MudEngine.GameManagement
|
||||||
{
|
{
|
||||||
Time t = InitialGameTime;
|
Time t = InitialGameTime;
|
||||||
CurrentWorldTime = t;
|
CurrentWorldTime = t;
|
||||||
|
CurrentSystemTime = DateTime.Now;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Update()
|
public virtual void Update()
|
||||||
|
@ -169,6 +170,7 @@ namespace MudEngine.GameManagement
|
||||||
CurrentSystemTime = DateTime.Now;
|
CurrentSystemTime = DateTime.Now;
|
||||||
Int32 amount = Math.Abs(ts.Seconds);
|
Int32 amount = Math.Abs(ts.Seconds);
|
||||||
IncrementSecond(amount);
|
IncrementSecond(amount);
|
||||||
|
Log.Write(GetCurrentWorldTime());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,9 +181,9 @@ namespace MudEngine.GameManagement
|
||||||
|
|
||||||
if (CurrentWorldTime.Second == SecondsPerMinute)
|
if (CurrentWorldTime.Second == SecondsPerMinute)
|
||||||
{
|
{
|
||||||
t.Second = 0;
|
|
||||||
IncrementMinute(1);
|
IncrementMinute(1);
|
||||||
t = CurrentWorldTime;
|
t = CurrentWorldTime;
|
||||||
|
t.Second = 0;
|
||||||
}
|
}
|
||||||
else if (CurrentWorldTime.Second > SecondsPerMinute)
|
else if (CurrentWorldTime.Second > SecondsPerMinute)
|
||||||
{
|
{
|
||||||
|
@ -204,8 +206,10 @@ namespace MudEngine.GameManagement
|
||||||
|
|
||||||
if (CurrentWorldTime.Minute == MinutesPerHour)
|
if (CurrentWorldTime.Minute == MinutesPerHour)
|
||||||
{
|
{
|
||||||
t.Minute = 0;
|
|
||||||
IncrementHour(1);
|
IncrementHour(1);
|
||||||
|
t = CurrentWorldTime;
|
||||||
|
t.Minute = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (CurrentWorldTime.Minute > MinutesPerHour)
|
else if (CurrentWorldTime.Minute > MinutesPerHour)
|
||||||
{
|
{
|
||||||
|
@ -228,8 +232,9 @@ namespace MudEngine.GameManagement
|
||||||
|
|
||||||
if (CurrentWorldTime.Hour == HoursPerDay)
|
if (CurrentWorldTime.Hour == HoursPerDay)
|
||||||
{
|
{
|
||||||
t.Hour = 0;
|
|
||||||
IncrementDay();
|
IncrementDay();
|
||||||
|
t = CurrentWorldTime;
|
||||||
|
t.Hour = 0;
|
||||||
}
|
}
|
||||||
else if (CurrentWorldTime.Hour > HoursPerDay)
|
else if (CurrentWorldTime.Hour > HoursPerDay)
|
||||||
{
|
{
|
||||||
|
@ -253,8 +258,9 @@ namespace MudEngine.GameManagement
|
||||||
//TODO: Finish GameTime syncing with Server Time.
|
//TODO: Finish GameTime syncing with Server Time.
|
||||||
if (CurrentWorldTime.Day == DaysPerMonth)
|
if (CurrentWorldTime.Day == DaysPerMonth)
|
||||||
{
|
{
|
||||||
t.Day = 1;
|
|
||||||
IncrementMonth();
|
IncrementMonth();
|
||||||
|
t = CurrentWorldTime;
|
||||||
|
t.Day = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
t.Day++;
|
t.Day++;
|
||||||
|
@ -269,8 +275,9 @@ namespace MudEngine.GameManagement
|
||||||
|
|
||||||
if (CurrentWorldTime.Month == MonthsPerYear)
|
if (CurrentWorldTime.Month == MonthsPerYear)
|
||||||
{
|
{
|
||||||
t.Month = 1;
|
|
||||||
IncrementYear();
|
IncrementYear();
|
||||||
|
t = CurrentWorldTime;
|
||||||
|
t.Month = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
t.Month++;
|
t.Month++;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue