Added MudEngine Project to the Solution. I will slowly be moving the MudDesigner.MudEngine classes out of the Mud Designer Solution and into it's own.
Currently the Mud Designer still contains the old MudEngine classes until migration has been completed.
This commit is contained in:
parent
7d3b6e471d
commit
dc311f5aa5
21 changed files with 1330 additions and 0 deletions
187
MudEngine/GameObjects/Environment/Room.cs
Normal file
187
MudEngine/GameObjects/Environment/Room.cs
Normal file
|
@ -0,0 +1,187 @@
|
|||
//Microsoft .NET Framework
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
using System.IO;
|
||||
|
||||
//MUD Engine
|
||||
using MudEngine.FileSystem;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
[ReadOnly(true)]
|
||||
[Description("This is the Zone that the Room is currently assigned to.")]
|
||||
[Category("Environment Information")]
|
||||
public string Zone
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[ReadOnly(true)]
|
||||
[Description("This is the Realm that the Room belongs to.")]
|
||||
[Category("Environment Information")]
|
||||
public string Realm
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Category("Environment Information")]
|
||||
[DefaultValue(false)]
|
||||
[Description("Determins if the Player can be attacked within this Room or not.")]
|
||||
public bool IsSafe
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public string InstallPath
|
||||
{
|
||||
get
|
||||
{
|
||||
string zonePath = "";
|
||||
if (this.Realm == null || this.Realm == "No Realm Associated.")
|
||||
{
|
||||
zonePath = FileManager.GetDataPath(SaveDataTypes.Zones);
|
||||
zonePath = Path.Combine(zonePath, this.Zone);
|
||||
}
|
||||
else
|
||||
zonePath = FileManager.GetDataPath(this.Realm, this.Zone);
|
||||
|
||||
string roomPath = Path.Combine(zonePath, "Rooms");
|
||||
string filename = Path.Combine(roomPath, this.Filename);
|
||||
return filename;
|
||||
}
|
||||
}
|
||||
|
||||
public Room()
|
||||
{
|
||||
Doorways = new List<Door>();
|
||||
|
||||
IsSafe = false;
|
||||
}
|
||||
|
||||
public bool DoorwayExist(string travelDirection)
|
||||
{
|
||||
foreach (Door door in Doorways)
|
||||
{
|
||||
if (door.TravelDirection.ToString().ToLower() == travelDirection.ToLower())
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public Door GetDoor(AvailableTravelDirections travelDirection)
|
||||
{
|
||||
foreach (Door door in this.Doorways)
|
||||
{
|
||||
if (door.TravelDirection == travelDirection)
|
||||
return door;
|
||||
}
|
||||
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 roomname incase it doesnt contain a file extension
|
||||
if (!roomName.ToLower().EndsWith(".room"))
|
||||
roomName += ".room";
|
||||
|
||||
//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