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:
parent
ab8d46ed3c
commit
4cfd6177bb
5 changed files with 68 additions and 2 deletions
|
@ -46,5 +46,12 @@ namespace MUDEngine.Objects.Environment
|
||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
|
public AvailableTravelDirections TravelDirection
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,10 +56,15 @@ namespace MUDEngine.Objects.Environment
|
||||||
|
|
||||||
public Room()
|
public Room()
|
||||||
{
|
{
|
||||||
|
InstalledDoors = new List<Door>();
|
||||||
|
|
||||||
this.Feel = "You feel nothing.";
|
this.Feel = "You feel nothing.";
|
||||||
this.Listen = "You hear nothing of interest.";
|
this.Listen = "You hear nothing of interest.";
|
||||||
this.Smell = "You don't smell anything unsual.";
|
this.Smell = "You don't smell anything unsual.";
|
||||||
this.StatDrainAmount = 0;
|
this.StatDrainAmount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
|
public List<Door> InstalledDoors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,12 @@
|
||||||
{
|
{
|
||||||
public enum AvailableTravelDirections
|
public enum AvailableTravelDirections
|
||||||
{
|
{
|
||||||
|
None = 0,
|
||||||
North,
|
North,
|
||||||
South,
|
South,
|
||||||
East,
|
East,
|
||||||
West,
|
West,
|
||||||
Up,
|
Up,
|
||||||
Down
|
Down,
|
||||||
}
|
}
|
||||||
}
|
}
|
1
RoomDesigner/frmMain.Designer.cs
generated
1
RoomDesigner/frmMain.Designer.cs
generated
|
@ -284,6 +284,7 @@
|
||||||
this.propertyDoor.Name = "propertyDoor";
|
this.propertyDoor.Name = "propertyDoor";
|
||||||
this.propertyDoor.Size = new System.Drawing.Size(350, 183);
|
this.propertyDoor.Size = new System.Drawing.Size(350, 183);
|
||||||
this.propertyDoor.TabIndex = 4;
|
this.propertyDoor.TabIndex = 4;
|
||||||
|
this.propertyDoor.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.propertyDoor_PropertyValueChanged);
|
||||||
//
|
//
|
||||||
// groupBox6
|
// groupBox6
|
||||||
//
|
//
|
||||||
|
|
|
@ -32,6 +32,7 @@ namespace RoomDesigner
|
||||||
foreach (int Value in Values)
|
foreach (int Value in Values)
|
||||||
{
|
{
|
||||||
string Display = Enum.GetName(type.GetType(), Value);
|
string Display = Enum.GetName(type.GetType(), Value);
|
||||||
|
if (Display != "None")
|
||||||
this.lstDirections.Items.Add(Display);
|
this.lstDirections.Items.Add(Display);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +45,58 @@ namespace RoomDesigner
|
||||||
|
|
||||||
private void lstDirections_SelectedIndexChanged(object sender, EventArgs e)
|
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;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue