MudEngine:
- Rooms can now be linked automatically via the new Zone.LinkRooms method. Room linking can no longer be done manually as the Doorways property is now read-only. - Door.Description has been removed. Doorway description will need to be included in Room.Description or Room.DetailedDescription properties. - Added DetailedDescription to make creating multi-line descriptions easier. Not supported by the Look command yet. - Game.IsRunning is now read-only. The Game will manage this property on its own. - BaseCharacter.ExecuteCommand now will always return a string. Simplifying the game loop for users as they no longer need to check what Type was returned by the command. - Doors now contain a DepartureRoom and a ArrivalRoom property allowing for easy access to Rooms that are linked together. - Fixed a bug where Game, Realms and Zones always assigned IsInitial to Realms, Zones and Rooms when added to the collections. Collection would contain multiple IsInitial objects. - Removed Room.InstalledDoorways property as that was used only by the old Designer - Removed Room.Load() as that implementation of it is obsolete. MudGame: - Revised Zeroth to build it's Zone and Rooms using the new Zone.LinkRooms function. - Greatly revised Program.cs and the Game loop to take advantage of many of the automations provided by the Engine now.
This commit is contained in:
parent
7e3cf1eb0c
commit
e145d57682
11 changed files with 138 additions and 184 deletions
|
@ -10,46 +10,19 @@ using System.IO;
|
|||
|
||||
//MUD Engine
|
||||
using MudEngine.FileSystem;
|
||||
using MudEngine.GameObjects.Items;
|
||||
using MudEngine.GameManagement;
|
||||
|
||||
namespace MudEngine.GameObjects.Environment
|
||||
{
|
||||
[XmlInclude(typeof(Door))]
|
||||
public class Room : BaseObject
|
||||
{
|
||||
[Category("Environment Information")]
|
||||
[Description("Shows what rooms are currently created and linked to within this Room.")]
|
||||
[ReadOnly(true)]
|
||||
public string InstalledDoorways
|
||||
{
|
||||
get
|
||||
{
|
||||
string installed = "";
|
||||
if (this.Doorways.Count != 0)
|
||||
{
|
||||
foreach (Door d in Doorways)
|
||||
{
|
||||
installed += d.TravelDirection.ToString() + ",";
|
||||
}
|
||||
if (Doorways.Count >= 2)
|
||||
{
|
||||
installed = installed.Substring(0, installed.Length - 1);
|
||||
}
|
||||
return installed;
|
||||
}
|
||||
else
|
||||
return "None Installed.";
|
||||
}
|
||||
}
|
||||
|
||||
[Category("Environment Information")]
|
||||
[Description("Allows for linking of Rooms together via Doorways")]
|
||||
//[EditorAttribute(typeof(UIDoorwayEditor), typeof(UITypeEditor))]
|
||||
[RefreshProperties(RefreshProperties.All)]
|
||||
public List<Door> Doorways
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public List<Door> Doorways { get; internal set; }
|
||||
|
||||
[ReadOnly(true)]
|
||||
[Description("This is the Zone that the Room is currently assigned to.")]
|
||||
|
@ -116,6 +89,11 @@ namespace MudEngine.GameObjects.Environment
|
|||
IsSafe = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks to see if a doorway in the travelDirection exists.
|
||||
/// </summary>
|
||||
/// <param name="travelDirection"></param>
|
||||
/// <returns></returns>
|
||||
public bool DoorwayExist(AvailableTravelDirections travelDirection)
|
||||
{
|
||||
foreach (Door door in Doorways)
|
||||
|
@ -127,6 +105,11 @@ namespace MudEngine.GameObjects.Environment
|
|||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets reference to the Rooms door connected in the supplied travelDirection
|
||||
/// </summary>
|
||||
/// <param name="travelDirection"></param>
|
||||
/// <returns></returns>
|
||||
public Door GetDoor(AvailableTravelDirections travelDirection)
|
||||
{
|
||||
foreach (Door door in this.Doorways)
|
||||
|
@ -136,63 +119,5 @@ namespace MudEngine.GameObjects.Environment
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load a Room that exists within the same Zone as the current Room
|
||||
/// </summary>
|
||||
/// <param name="roomName"></param>
|
||||
/// <returns></returns>
|
||||
public override object Load(string roomName)
|
||||
{
|
||||
//Correct the filename incase it doesnt contain a file extension
|
||||
if (!roomName.ToLower().EndsWith(this.GetType().Name.ToLower()))
|
||||
roomName.Insert(roomName.Length, this.GetType().Name.ToLower());
|
||||
|
||||
//If the current room does not belong within a Realm, then load it from the
|
||||
//Zones root directory
|
||||
if (this.Realm != null || this.Realm != "No Realm Associated.")
|
||||
{
|
||||
return this.Load(roomName, this.Zone);
|
||||
}
|
||||
//This Zone is contained within a Realm so we have to load it from within the
|
||||
//Realm and not from within the Zones root directory
|
||||
else
|
||||
return this.Load(roomName, this.Zone, this.Realm);
|
||||
}
|
||||
|
||||
public object Load(string roomName, string zoneName)
|
||||
{
|
||||
string filename = "";
|
||||
if (!roomName.ToLower().EndsWith(".room"))
|
||||
roomName += ".room";
|
||||
|
||||
if (this.Realm != null && this.Realm != "No Realm Associated.")
|
||||
{
|
||||
return this.Load(roomName, zoneName, this.Realm);
|
||||
}
|
||||
else
|
||||
filename = FileManager.GetDataPath(SaveDataTypes.Zones);
|
||||
|
||||
filename = Path.Combine(filename, zoneName);
|
||||
filename = Path.Combine(filename, "Rooms");
|
||||
filename = Path.Combine(filename, roomName);
|
||||
|
||||
return base.Load(filename);
|
||||
}
|
||||
|
||||
public object Load(string roomName, string zoneName, string realmName)
|
||||
{
|
||||
if (!roomName.ToLower().EndsWith(".room"))
|
||||
roomName += ".room";
|
||||
|
||||
string filename = FileManager.GetDataPath(realmName, zoneName);
|
||||
filename = Path.Combine(filename, "Rooms");
|
||||
filename = Path.Combine(filename, roomName);
|
||||
|
||||
if (realmName == null || realmName == "No Realm Associated.")
|
||||
return this.Load(roomName, zoneName);
|
||||
|
||||
return base.Load(filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue