- Corrected SaveDataTypes.Currency being named incorrectly. Changed to Currencies - ProjectInformation now inherits from the new IFileIO interface. - ProjectInformation.Load can be used instead of the FileManager now (note: Saving of ProjectInformation must still be done using FileManager) - Organizing of BaseObject done - BaseObject now supports BaseObject.Load. Use this instead of FileManager.Load - Fixed UIRealmControl error, attempting to deserialize into a null Zone Field - Program.cs is now encapsulated into a try/catch - IFileIO interface added for providing a blueprint on file I/O operations Designer: - Additional ObjectTypes added to the ObjectTypes enum - Additional commenting provided throughout the source. - Re-organized the source code. - Simplified the Constructor code. Roughly 50% less code now. - Re-wrote the Object Load code to make it easier to read and maintain. - Renamed several menu items to conform to the projects naming conventions
100 lines
3 KiB
C#
100 lines
3 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.ComponentModel;
|
|
using System.Xml.Serialization;
|
|
using System.Drawing.Design;
|
|
|
|
using MudDesigner.MudEngine.FileSystem;
|
|
using MudDesigner.MudEngine.GameObjects;
|
|
using MudDesigner.MudEngine.UITypeEditors;
|
|
|
|
namespace MudDesigner.MudEngine.GameObjects.Environment
|
|
{
|
|
[XmlInclude(typeof(Room))]
|
|
public class Zone : BaseObject
|
|
{
|
|
[Category("Environment Information")]
|
|
[DefaultValue(0)]
|
|
[Description("The amount to drain each stat by if StatDrain is enabled.")]
|
|
public int StatDrainAmount
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
[Category("Environment Information")]
|
|
[Description("Enable or Disable the ability for draining stats while traversing.")]
|
|
[DefaultValue(false)]
|
|
public bool StatDrain
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
[ReadOnly(true)]
|
|
[Category("Environment Information")]
|
|
[Description("The Realm that this Zone is assigned to. It is not required to be contained within a Realm.")]
|
|
public string Realm
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
[Category("Environment Information")]
|
|
[Description("Determins if the Player can be attacked within this Room or not.")]
|
|
[DefaultValue(false)]
|
|
public bool IsSafe
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
[Category("Environment Information")]
|
|
[EditorAttribute(typeof(UIRoomEditor), typeof(UITypeEditor))]
|
|
[Description("Collection of Rooms that have been created. Editing the Rooms Collection lets you manage the Zones rooms.")]
|
|
public List<Room> Rooms { get; set; }
|
|
|
|
public Zone()
|
|
{
|
|
Rooms = new List<Room>();
|
|
IsSafe = false;
|
|
//throw new NotSupportedException("Parameterless constructors of Type " + this.GetType().FullName + " is not supported.");
|
|
}
|
|
|
|
public Room GetRoom(string RoomName)
|
|
{
|
|
foreach (Room r in Rooms)
|
|
{
|
|
if (r.Name == RoomName)
|
|
return r;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public void RefreshRoomList()
|
|
{
|
|
Rooms = new List<Room>();
|
|
//Create our collection of Rooms.
|
|
string realmPath = Path.Combine(FileManager.GetDataPath(SaveDataTypes.Realms), this.Realm);
|
|
string zonePath = Path.Combine(realmPath, this.Name);
|
|
|
|
//incase the zone hasn't been saved yet.
|
|
if (!Directory.Exists(zonePath))
|
|
return;
|
|
|
|
//Zone exists, so it's already been saved.
|
|
string[] rooms = Directory.GetFiles(zonePath, "*.room");
|
|
|
|
foreach (string file in rooms)
|
|
{
|
|
Room r = new Room();
|
|
r = (Room)FileManager.Load(file, r);
|
|
this.Rooms.Add(r);
|
|
}
|
|
}
|
|
}
|
|
}
|