MudEngine:
- GameTime updates; Still not fully functioning correctly. MudGame: - Create command received some error checks when creating Realms.
This commit is contained in:
parent
7ad027e9d7
commit
f3b4c40010
5 changed files with 86 additions and 24 deletions
3
MudClient/..svnbridge/.svnbridge
Normal file
3
MudClient/..svnbridge/.svnbridge
Normal 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>
|
|
@ -331,6 +331,7 @@ namespace MudEngine.GameManagement
|
||||||
lastSaveGap++;
|
lastSaveGap++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (IsMultiplayer)
|
if (IsMultiplayer)
|
||||||
{
|
{
|
||||||
Console.Write(Log.GetMessages());
|
Console.Write(Log.GetMessages());
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace MudEngine.GameManagement
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or Sets the current Time of the System
|
/// Gets or Sets the current Time of the System
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private DateTime CurrentTime { get; set; }
|
private DateTime CurrentSystemTime { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or Sets how many Hours it takes to make a full day in the World
|
/// 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("October");
|
||||||
MonthNames.Add("November");
|
MonthNames.Add("November");
|
||||||
MonthNames.Add("December");
|
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()
|
public void Initialize()
|
||||||
|
@ -136,21 +159,20 @@ namespace MudEngine.GameManagement
|
||||||
|
|
||||||
public virtual void Update()
|
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
|
//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
|
//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.
|
//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(Int32 amount)
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void IncrementSecond()
|
|
||||||
{
|
{
|
||||||
Time t = new Time();
|
Time t = new Time();
|
||||||
t = CurrentWorldTime;
|
t = CurrentWorldTime;
|
||||||
|
@ -158,15 +180,24 @@ namespace MudEngine.GameManagement
|
||||||
if (CurrentWorldTime.Second == SecondsPerMinute)
|
if (CurrentWorldTime.Second == SecondsPerMinute)
|
||||||
{
|
{
|
||||||
t.Second = 0;
|
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
|
else
|
||||||
t.Second++;
|
t.Second += amount;
|
||||||
|
|
||||||
CurrentWorldTime = t;
|
CurrentWorldTime = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void IncrementMinute()
|
public void IncrementMinute(Int32 amount)
|
||||||
{
|
{
|
||||||
Time t = new Time();
|
Time t = new Time();
|
||||||
t = CurrentWorldTime;
|
t = CurrentWorldTime;
|
||||||
|
@ -174,15 +205,23 @@ namespace MudEngine.GameManagement
|
||||||
if (CurrentWorldTime.Minute == MinutesPerHour)
|
if (CurrentWorldTime.Minute == MinutesPerHour)
|
||||||
{
|
{
|
||||||
t.Minute = 0;
|
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
|
else
|
||||||
t.Minute++;
|
t.Minute += amount;
|
||||||
|
|
||||||
CurrentWorldTime = t;
|
CurrentWorldTime = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void IncrementHour()
|
public void IncrementHour(Int32 amount)
|
||||||
{
|
{
|
||||||
Time t = new Time();
|
Time t = new Time();
|
||||||
t = CurrentWorldTime;
|
t = CurrentWorldTime;
|
||||||
|
@ -192,6 +231,14 @@ namespace MudEngine.GameManagement
|
||||||
t.Hour = 0;
|
t.Hour = 0;
|
||||||
IncrementDay();
|
IncrementDay();
|
||||||
}
|
}
|
||||||
|
else if (CurrentWorldTime.Hour > HoursPerDay)
|
||||||
|
{
|
||||||
|
Int32 days = CurrentWorldTime.Hour / HoursPerDay;
|
||||||
|
Int32 hours = CurrentWorldTime.Hour - HoursPerDay;
|
||||||
|
IncrementDay();
|
||||||
|
t = CurrentWorldTime;
|
||||||
|
t.Hour = hours;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
t.Hour++;
|
t.Hour++;
|
||||||
|
|
||||||
|
@ -203,6 +250,7 @@ namespace MudEngine.GameManagement
|
||||||
Time t = new Time();
|
Time t = new Time();
|
||||||
t = CurrentWorldTime;
|
t = CurrentWorldTime;
|
||||||
|
|
||||||
|
//TODO: Finish GameTime syncing with Server Time.
|
||||||
if (CurrentWorldTime.Day == DaysPerMonth)
|
if (CurrentWorldTime.Day == DaysPerMonth)
|
||||||
{
|
{
|
||||||
t.Day = 1;
|
t.Day = 1;
|
||||||
|
|
|
@ -4,11 +4,13 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
|
using MudEngine.GameManagement;
|
||||||
|
|
||||||
namespace MudEngine.GameObjects.Items
|
namespace MudEngine.GameObjects.Items
|
||||||
{
|
{
|
||||||
public class BaseItem : BaseObject
|
public class BaseItem : BaseObject
|
||||||
{
|
{
|
||||||
public BaseItem(GameManagement.Game game) : base(game)
|
public BaseItem(Game game) : base(game)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,11 @@
|
||||||
{
|
{
|
||||||
//Instance a new Realm.
|
//Instance a new Realm.
|
||||||
Realm realm = new Realm(player.ActiveGame);
|
Realm realm = new Realm(player.ActiveGame);
|
||||||
|
Boolean isLegalName = false;
|
||||||
|
|
||||||
|
while (!isLegalName)
|
||||||
|
{
|
||||||
|
isLegalName = true;
|
||||||
//Get the name of this Realm from the player.
|
//Get the name of this Realm from the player.
|
||||||
player.Send("Realm Name: ", false);
|
player.Send("Realm Name: ", false);
|
||||||
realm.Name = player.ReadInput();
|
realm.Name = player.ReadInput();
|
||||||
|
@ -50,10 +54,13 @@
|
||||||
if (r.Name == realm.Name)
|
if (r.Name == realm.Name)
|
||||||
{
|
{
|
||||||
player.Send("Realm already exists!");
|
player.Send("Realm already exists!");
|
||||||
|
isLegalName = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
player.ActiveGame.World.AddRealm(realm);
|
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.");
|
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 + ".");
|
player.Send(zone.Name + " has been created and added to Realm " + realm.Name + ".");
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue