MUDEngine:

* Door.cs - Now contains a TravelDirection property so rooms can find what travel direction each doorway within uses.
 * Room - Now contains a collection for Installed Doors
 * TravelDirections.cs - Now contains a 'None' enumerable value.

Room Designer:
 * Did some additional work on implementing Installed Doors and handling their changing Installed/Uninstalled values.
This commit is contained in:
Scionwest_cp 2009-11-12 18:49:58 -08:00
parent ab8d46ed3c
commit 4cfd6177bb
5 changed files with 68 additions and 2 deletions

View file

@ -46,5 +46,12 @@ namespace MUDEngine.Objects.Environment
get;
set;
}
[Browsable(false)]
public AvailableTravelDirections TravelDirection
{
get;
set;
}
}
}

View file

@ -56,10 +56,15 @@ namespace MUDEngine.Objects.Environment
public Room()
{
InstalledDoors = new List<Door>();
this.Feel = "You feel nothing.";
this.Listen = "You hear nothing of interest.";
this.Smell = "You don't smell anything unsual.";
this.StatDrainAmount = 0;
}
[Browsable(false)]
public List<Door> InstalledDoors;
}
}

View file

@ -2,11 +2,12 @@
{
public enum AvailableTravelDirections
{
None = 0,
North,
South,
East,
West,
Up,
Down
Down,
}
}

View file

@ -284,6 +284,7 @@
this.propertyDoor.Name = "propertyDoor";
this.propertyDoor.Size = new System.Drawing.Size(350, 183);
this.propertyDoor.TabIndex = 4;
this.propertyDoor.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.propertyDoor_PropertyValueChanged);
//
// groupBox6
//

View file

@ -32,6 +32,7 @@ namespace RoomDesigner
foreach (int Value in Values)
{
string Display = Enum.GetName(type.GetType(), Value);
if (Display != "None")
this.lstDirections.Items.Add(Display);
}
@ -44,7 +45,58 @@ namespace RoomDesigner
private void lstDirections_SelectedIndexChanged(object sender, EventArgs e)
{
bool IsFound = false;
foreach (Door newDoor in room.InstalledDoors)
{
if (newDoor.TravelDirection.ToString() == lstDirections.SelectedItem.ToString())
{
door = newDoor;
IsFound = true;
break;
}
}
if (!IsFound)
door = new Door();
propertyDoor.SelectedObject = door;
}
private void propertyDoor_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
{
if (door.DoorState == Door.AvailableDoorStates.Installed)
{
foreach(Door newDoor in room.InstalledDoors)
{
if (newDoor.TravelDirection == door.TravelDirection)
{
DialogResult result = MessageBox.Show("Door already exists! Overwrite it?", "Room Designer", MessageBoxButtons.YesNo);
if (result == DialogResult.No)
return;
room.InstalledDoors.Remove(newDoor);
room.InstalledDoors.Add(door);
break;
}
else
{
room.InstalledDoors.Add(door);
}
}
//Incase there are no existing doors, the foreach loop gets skipped.
if (room.InstalledDoors.Count == 0)
{/*
foreach (Enum e in door.TravelDirection)
{
if (e.ToString() == lstDirections.SelectedItem.ToString())
{
door.TravelDirection = e;
}
}
*/
}
}
}
}
}