MudEngine:

- GameTime updates; Still not fully functioning correctly.

MudGame:
 - Create command received some error checks when creating Realms.
This commit is contained in:
Scionwest_cp 2010-08-17 19:57:33 -07:00
parent 7ad027e9d7
commit f3b4c40010
5 changed files with 86 additions and 24 deletions

View file

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?><ItemProperties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><Properties><Property><Name>svn:ignore</Name><Value>bin
obj
</Value></Property></Properties></ItemProperties>

View file

@ -331,6 +331,7 @@ namespace MudEngine.GameManagement
lastSaveGap++;
}
if (IsMultiplayer)
{
Console.Write(Log.GetMessages());

View file

@ -40,7 +40,7 @@ namespace MudEngine.GameManagement
/// <summary>
/// Gets or Sets the current Time of the System
/// </summary>
private DateTime CurrentTime { get; set; }
private DateTime CurrentSystemTime { get; set; }
/// <summary>
/// Gets or Sets how many Hours it takes to make a full day in the World
@ -126,6 +126,29 @@ namespace MudEngine.GameManagement
MonthNames.Add("October");
MonthNames.Add("November");
MonthNames.Add("December");
Time t = new Time();
t.Second = 0;
t.Minute = 1;
t.Hour = 8;
t.Day = 1;
t.Month = 1;
t.Year = 2010;
InitialGameTime = t;
DawnTime = 19;
SunriseTime = 6;
DayTransitions = TimeOfDayOptions.Transition;
SecondsPerMinute = 60;
MinutesPerHour = 60;
HoursPerDay = 24;
DaysPerMonth = 31;
MonthsPerYear = 12;
CurrentWorldTime = InitialGameTime;
}
public void Initialize()
@ -136,21 +159,20 @@ namespace MudEngine.GameManagement
public virtual void Update()
{
TimeSpan ts = CurrentTime - DateTime.Now;
TimeSpan ts = CurrentSystemTime - DateTime.Now;
//If the seconds that has passed inbetween the last Update call is greater than 0
//Then we need to increment a Second, which will start a domino effect if it needs to
//in order to increment minute/hours/days/months and years.
if (ts.Seconds != 0)
if (ts.Seconds <= -1)
{
IncrementSecond();
CurrentSystemTime = DateTime.Now;
Int32 amount = Math.Abs(ts.Seconds);
IncrementSecond(amount);
}
CurrentTime = DateTime.Now;
}
public void IncrementSecond()
public void IncrementSecond(Int32 amount)
{
Time t = new Time();
t = CurrentWorldTime;
@ -158,15 +180,24 @@ namespace MudEngine.GameManagement
if (CurrentWorldTime.Second == SecondsPerMinute)
{
t.Second = 0;
IncrementMinute();
IncrementMinute(1);
t = CurrentWorldTime;
}
else if (CurrentWorldTime.Second > SecondsPerMinute)
{
Int32 minutes = CurrentWorldTime.Second / SecondsPerMinute;
Int32 seconds = CurrentWorldTime.Second - SecondsPerMinute;
IncrementMinute(minutes);
t = CurrentWorldTime; //Get the updated world time.
t.Second = seconds; //Edit it.
}
else
t.Second++;
t.Second += amount;
CurrentWorldTime = t;
}
public void IncrementMinute()
public void IncrementMinute(Int32 amount)
{
Time t = new Time();
t = CurrentWorldTime;
@ -174,15 +205,23 @@ namespace MudEngine.GameManagement
if (CurrentWorldTime.Minute == MinutesPerHour)
{
t.Minute = 0;
IncrementHour();
IncrementHour(1);
}
else if (CurrentWorldTime.Minute > MinutesPerHour)
{
Int32 hours = CurrentWorldTime.Minute / MinutesPerHour;
Int32 Minutes = CurrentWorldTime.Minute - MinutesPerHour;
IncrementHour(hours);
t = CurrentWorldTime;
t.Minute = Minutes;
}
else
t.Minute++;
t.Minute += amount;
CurrentWorldTime = t;
}
public void IncrementHour()
public void IncrementHour(Int32 amount)
{
Time t = new Time();
t = CurrentWorldTime;
@ -192,6 +231,14 @@ namespace MudEngine.GameManagement
t.Hour = 0;
IncrementDay();
}
else if (CurrentWorldTime.Hour > HoursPerDay)
{
Int32 days = CurrentWorldTime.Hour / HoursPerDay;
Int32 hours = CurrentWorldTime.Hour - HoursPerDay;
IncrementDay();
t = CurrentWorldTime;
t.Hour = hours;
}
else
t.Hour++;
@ -203,6 +250,7 @@ namespace MudEngine.GameManagement
Time t = new Time();
t = CurrentWorldTime;
//TODO: Finish GameTime syncing with Server Time.
if (CurrentWorldTime.Day == DaysPerMonth)
{
t.Day = 1;

View file

@ -4,11 +4,13 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using MudEngine.GameManagement;
namespace MudEngine.GameObjects.Items
{
public class BaseItem : BaseObject
{
public BaseItem(GameManagement.Game game) : base(game)
public BaseItem(Game game) : base(game)
{
}
}

View file

@ -39,21 +39,28 @@
{
//Instance a new Realm.
Realm realm = new Realm(player.ActiveGame);
Boolean isLegalName = false;
//Get the name of this Realm from the player.
player.Send("Realm Name: ", false);
realm.Name = player.ReadInput();
//Check if a Realm with this name already exists.
foreach (Realm r in player.ActiveGame.World.RealmCollection)
while (!isLegalName)
{
if (r.Name == realm.Name)
isLegalName = true;
//Get the name of this Realm from the player.
player.Send("Realm Name: ", false);
realm.Name = player.ReadInput();
//Check if a Realm with this name already exists.
foreach (Realm r in player.ActiveGame.World.RealmCollection)
{
player.Send("Realm already exists!");
if (r.Name == realm.Name)
{
player.Send("Realm already exists!");
isLegalName = false;
}
}
}
player.ActiveGame.World.AddRealm(realm);
Log.Write(player.Name + " has created a Realm called " + realm.Name);
player.Send(realm.Name + " has been created and added to the world.");
}
@ -122,6 +129,7 @@
}
}
Log.Write(player.Name + " has created a Zone called " + zone.Name + " within the Realm " + realm.Name);
player.Send(zone.Name + " has been created and added to Realm " + realm.Name + ".");
}
}