- Added FileManager.GetDataSpan() method. This allows developers to start at a line and collect the next 'x' number of lines after that starting line. Example: GetDataSpan("MyFile.txt", 5, "DoorwayArrivalRoom", true); This seeks MyFile.txt until it finds "DoorwayArrivalRoom" and then it stores that line and the next 4 lines for a total of 5 lines and returns the collection. The last argument 'true' means that the method will scan the rest of the file after the initial 5 lines and add any other lines that match the "DoorwayArrivalRoom" string as well. - Deleted CommandResults class as it's no longer used by the script engine. - Singleplayer and Multiplayer save data paths are now the same paths by default. - Game.Update() method now checks for auto-saving (instead of MudGame performing this check) - Saving and restoring of Realms, Zones, Rooms and Doorways now fully implemented. - GameTime now supports auto-saving - GameWorld.Update() now calls BaseCharacter.Update() and is ready for future update code. - GameWorld.AddObject and GameWorld.RemoveObject() have been removed. - GameWorld.AddRealm() re-added for adding Realms pre-populated with zones/rooms. Note that Zones and Rooms can be added to a Realm even after it has been added to the GameWorld.RealmCollection - BaseObject now contains a OnStart() event method. - BaseObject.Save() now saves BaseObject.DetailedDescription collection content. - Updated BaseCharacter to retrieve Environments by Filename rather than Object name. - BaseStats.Experience property added. - Door.RoomTravelType enum added for determining if the room is Arrival or Departure - Door.SetRoom() method added for restoring a Rooms Doorway link during world restoration. - Renamed Room.InstallPath to Room.RoomLocation. Contains a MyRealm.Realm>MyZone.Zone>MyRoom.Room path - Added Room.RoomLocationWithoutExtension property for returning the Rooms location without file extensions. Ex: MyRealm>MyZone>MyRoom - Room now saves Doorways. - The GameWorld now restores the link between Rooms once all Environment objects have been instanced and restored from their saved state. MudGame: - Minor clean-up with MudGame loop and shutdown. - Updated scripts to reflect changes made to the engine.
126 lines
3.8 KiB
C#
126 lines
3.8 KiB
C#
//Microsoft .NET Framework
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Xml.Serialization;
|
|
using System.ComponentModel;
|
|
|
|
//MUD Engine
|
|
using MudEngine.GameObjects.Items;
|
|
using MudEngine.GameManagement;
|
|
|
|
namespace MudEngine.GameObjects.Environment
|
|
{
|
|
[XmlInclude(typeof(BaseItem))]
|
|
[Serializable]
|
|
public class Door
|
|
{
|
|
public enum RoomTravelType
|
|
{
|
|
Arrival,
|
|
Departure
|
|
}
|
|
|
|
[Category("Door Settings")]
|
|
[DefaultValue(false)]
|
|
public Boolean IsLocked
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
[Category("Door Settings")]
|
|
[Browsable(false)]
|
|
public BaseItem RequiredKey
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
[Category("Door Settings")]
|
|
[DefaultValue(0)]
|
|
public Int32 LevelRequirement
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
[Category("Door Settings")]
|
|
public AvailableTravelDirections TravelDirection { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or Sets the Room that the player will be arriving.
|
|
/// </summary>
|
|
public Room ArrivalRoom { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or Sets the Room that the user is leaving.
|
|
/// </summary>
|
|
public Room DepartureRoom { get; set; }
|
|
|
|
private Game _Game;
|
|
|
|
public Door(GameManagement.Game game)
|
|
{
|
|
LevelRequirement = 0;
|
|
IsLocked = false;
|
|
RequiredKey = new BaseItem(game);
|
|
|
|
_Game = game;
|
|
}
|
|
|
|
public Boolean SetRoom(RoomTravelType roomType, String roomPath)
|
|
{
|
|
String[] path = roomPath.Split('>');
|
|
|
|
if (path.Length > 3)
|
|
{
|
|
Log.Write("Error in Door.SetRoom(" + roomType.ToString() + ", " + roomPath + ") does not contain a full Room Path.");
|
|
return false;
|
|
}
|
|
|
|
//TODO: Load the Realm via Game.World if it isn't loaded yet. Ensures that the Realm is only ever loaded once.
|
|
if (_Game.World.GetRealm(path[0]) != null)
|
|
{
|
|
Realm r = _Game.World.GetRealm(path[0]);
|
|
|
|
//TODO: Load the Zone via Game.World.GetRealm(). Ensures that only 1 instance of the Realm is loaded.
|
|
if (r.GetZone(path[1]) != null)
|
|
{
|
|
List<Zone> zlist = r.GetZone(path[1]);
|
|
|
|
Zone z = zlist[0];
|
|
|
|
//TODO: Load the Room via Game.World.GetRealm().GetZone(). Ensures that the Room is only loaded once in memory.
|
|
if (z.GetRoomByFilename(path[2]) != null)
|
|
{
|
|
List<Room> rlist = z.GetRoomByFilename(path[2]);
|
|
|
|
if (roomType == RoomTravelType.Arrival)
|
|
ArrivalRoom = rlist[0];
|
|
else
|
|
DepartureRoom = rlist[0];
|
|
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
Log.Write("Error in Door.SetRoom(" + roomType.ToString() + ", " + roomPath + ") does not contain a valid Room");
|
|
return false;
|
|
}//GetRoom
|
|
}//GetZone
|
|
else
|
|
{
|
|
Log.Write("Error in Door.SetRoom(" + roomType.ToString() + ", " + roomPath + ") does not contain a valid zone.");
|
|
return false;
|
|
}
|
|
}//GetRealm
|
|
else
|
|
{
|
|
Log.Write("Error in Door.SetRoom(" + roomType.ToString() + ", " + roomPath + ") does not contain a valid Realm");
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|