diff --git a/Mud Designer/Designer.Designer.cs b/Mud Designer/Designer.Designer.cs index 26c4680..26c91ff 100644 --- a/Mud Designer/Designer.Designer.cs +++ b/Mud Designer/Designer.Designer.cs @@ -29,7 +29,7 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.Windows.Forms.TreeNode treeNode1 = new System.Windows.Forms.TreeNode("Project"); + System.Windows.Forms.TreeNode treeNode2 = new System.Windows.Forms.TreeNode("Project"); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Designer)); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.mnuFile = new System.Windows.Forms.ToolStripMenuItem(); @@ -71,6 +71,8 @@ this.mnuHelp = new System.Windows.Forms.ToolStripMenuItem(); this.mnuAbout = new System.Windows.Forms.ToolStripMenuItem(); this.containerMain = new System.Windows.Forms.SplitContainer(); + this.statusStrip1 = new System.Windows.Forms.StatusStrip(); + this.lblStatus = new System.Windows.Forms.ToolStripStatusLabel(); this.containerSidebar = new System.Windows.Forms.SplitContainer(); this.treeExplorer = new System.Windows.Forms.TreeView(); this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); @@ -81,6 +83,8 @@ this.mnuEditObject = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator(); this.mnuDeleteSelectedObject = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem7 = new System.Windows.Forms.ToolStripSeparator(); + this.setAsInitialLocationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStrip1 = new System.Windows.Forms.ToolStrip(); this.btnRefreshObjects = new System.Windows.Forms.ToolStripButton(); this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); @@ -91,8 +95,10 @@ this.lblObjectProperties = new System.Windows.Forms.Label(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.menuStrip1.SuspendLayout(); + this.containerMain.Panel1.SuspendLayout(); this.containerMain.Panel2.SuspendLayout(); this.containerMain.SuspendLayout(); + this.statusStrip1.SuspendLayout(); this.containerSidebar.Panel1.SuspendLayout(); this.containerSidebar.Panel2.SuspendLayout(); this.containerSidebar.SuspendLayout(); @@ -356,7 +362,6 @@ this.freshLoginToolStripMenuItem, this.customCharacterToolStripMenuItem, this.playFromCurrentRoomToolStripMenuItem}); - this.testProjectToolStripMenuItem.Enabled = false; this.testProjectToolStripMenuItem.Name = "testProjectToolStripMenuItem"; this.testProjectToolStripMenuItem.Size = new System.Drawing.Size(179, 22); this.testProjectToolStripMenuItem.Text = "Test Project"; @@ -366,15 +371,18 @@ this.freshLoginToolStripMenuItem.Name = "freshLoginToolStripMenuItem"; this.freshLoginToolStripMenuItem.Size = new System.Drawing.Size(205, 22); this.freshLoginToolStripMenuItem.Text = "Fresh Login"; + this.freshLoginToolStripMenuItem.Click += new System.EventHandler(this.freshLoginToolStripMenuItem_Click); // // customCharacterToolStripMenuItem // + this.customCharacterToolStripMenuItem.Enabled = false; this.customCharacterToolStripMenuItem.Name = "customCharacterToolStripMenuItem"; this.customCharacterToolStripMenuItem.Size = new System.Drawing.Size(205, 22); this.customCharacterToolStripMenuItem.Text = "Custom Character"; // // playFromCurrentRoomToolStripMenuItem // + this.playFromCurrentRoomToolStripMenuItem.Enabled = false; this.playFromCurrentRoomToolStripMenuItem.Name = "playFromCurrentRoomToolStripMenuItem"; this.playFromCurrentRoomToolStripMenuItem.Size = new System.Drawing.Size(205, 22); this.playFromCurrentRoomToolStripMenuItem.Text = "Play From Current Room"; @@ -401,6 +409,10 @@ this.containerMain.Location = new System.Drawing.Point(0, 24); this.containerMain.Name = "containerMain"; // + // containerMain.Panel1 + // + this.containerMain.Panel1.Controls.Add(this.statusStrip1); + // // containerMain.Panel2 // this.containerMain.Panel2.Controls.Add(this.containerSidebar); @@ -408,6 +420,23 @@ this.containerMain.SplitterDistance = 511; this.containerMain.TabIndex = 1; // + // statusStrip1 + // + this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.lblStatus}); + this.statusStrip1.Location = new System.Drawing.Point(0, 518); + this.statusStrip1.Name = "statusStrip1"; + this.statusStrip1.Size = new System.Drawing.Size(511, 22); + this.statusStrip1.TabIndex = 4; + this.statusStrip1.Text = "statusStrip1"; + // + // lblStatus + // + this.lblStatus.ForeColor = System.Drawing.Color.Silver; + this.lblStatus.Name = "lblStatus"; + this.lblStatus.Size = new System.Drawing.Size(109, 17); + this.lblStatus.Text = "Nothing To Report."; + // // containerSidebar // this.containerSidebar.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; @@ -436,10 +465,10 @@ this.treeExplorer.Dock = System.Windows.Forms.DockStyle.Fill; this.treeExplorer.Location = new System.Drawing.Point(0, 38); this.treeExplorer.Name = "treeExplorer"; - treeNode1.Name = "nodeProject"; - treeNode1.Text = "Project"; + treeNode2.Name = "nodeProject"; + treeNode2.Text = "Project"; this.treeExplorer.Nodes.AddRange(new System.Windows.Forms.TreeNode[] { - treeNode1}); + treeNode2}); this.treeExplorer.Size = new System.Drawing.Size(267, 204); this.treeExplorer.TabIndex = 5; this.toolTip1.SetToolTip(this.treeExplorer, resources.GetString("treeExplorer.ToolTip")); @@ -451,16 +480,18 @@ this.addObjectToolStripMenuItem, this.mnuEditObject, this.toolStripMenuItem1, - this.mnuDeleteSelectedObject}); + this.mnuDeleteSelectedObject, + this.toolStripMenuItem7, + this.setAsInitialLocationToolStripMenuItem}); this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(146, 76); + this.contextMenuStrip1.Size = new System.Drawing.Size(188, 104); // // addObjectToolStripMenuItem // this.addObjectToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.environmentToolStripMenuItem}); this.addObjectToolStripMenuItem.Name = "addObjectToolStripMenuItem"; - this.addObjectToolStripMenuItem.Size = new System.Drawing.Size(145, 22); + this.addObjectToolStripMenuItem.Size = new System.Drawing.Size(187, 22); this.addObjectToolStripMenuItem.Text = "Add Object"; // // environmentToolStripMenuItem @@ -489,22 +520,34 @@ // mnuEditObject // this.mnuEditObject.Name = "mnuEditObject"; - this.mnuEditObject.Size = new System.Drawing.Size(145, 22); + this.mnuEditObject.Size = new System.Drawing.Size(187, 22); this.mnuEditObject.Text = "Edit Object"; this.mnuEditObject.Click += new System.EventHandler(this.mnuEditObject_Click); // // toolStripMenuItem1 // this.toolStripMenuItem1.Name = "toolStripMenuItem1"; - this.toolStripMenuItem1.Size = new System.Drawing.Size(142, 6); + this.toolStripMenuItem1.Size = new System.Drawing.Size(184, 6); // // mnuDeleteSelectedObject // this.mnuDeleteSelectedObject.Name = "mnuDeleteSelectedObject"; - this.mnuDeleteSelectedObject.Size = new System.Drawing.Size(145, 22); + this.mnuDeleteSelectedObject.Size = new System.Drawing.Size(187, 22); this.mnuDeleteSelectedObject.Text = "Delete Object"; this.mnuDeleteSelectedObject.Click += new System.EventHandler(this.mnuDeleteSelectedObject_Click); // + // toolStripMenuItem7 + // + this.toolStripMenuItem7.Name = "toolStripMenuItem7"; + this.toolStripMenuItem7.Size = new System.Drawing.Size(184, 6); + // + // setAsInitialLocationToolStripMenuItem + // + this.setAsInitialLocationToolStripMenuItem.Name = "setAsInitialLocationToolStripMenuItem"; + this.setAsInitialLocationToolStripMenuItem.Size = new System.Drawing.Size(187, 22); + this.setAsInitialLocationToolStripMenuItem.Text = "Set As Initial Location"; + this.setAsInitialLocationToolStripMenuItem.Click += new System.EventHandler(this.setAsInitialLocationToolStripMenuItem_Click); + // // toolStrip1 // this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -606,8 +649,12 @@ this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); + this.containerMain.Panel1.ResumeLayout(false); + this.containerMain.Panel1.PerformLayout(); this.containerMain.Panel2.ResumeLayout(false); this.containerMain.ResumeLayout(false); + this.statusStrip1.ResumeLayout(false); + this.statusStrip1.PerformLayout(); this.containerSidebar.Panel1.ResumeLayout(false); this.containerSidebar.Panel1.PerformLayout(); this.containerSidebar.Panel2.ResumeLayout(false); @@ -681,6 +728,10 @@ private System.Windows.Forms.ToolStripMenuItem environmentToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem mnuNewRealmShortcut; private System.Windows.Forms.ToolStripMenuItem mnuNewZoneShortcut; + private System.Windows.Forms.ToolStripSeparator toolStripMenuItem7; + private System.Windows.Forms.ToolStripMenuItem setAsInitialLocationToolStripMenuItem; + private System.Windows.Forms.StatusStrip statusStrip1; + private System.Windows.Forms.ToolStripStatusLabel lblStatus; diff --git a/Mud Designer/Designer.cs b/Mud Designer/Designer.cs index 455f71f..a630b80 100644 --- a/Mud Designer/Designer.cs +++ b/Mud Designer/Designer.cs @@ -111,6 +111,8 @@ namespace MudDesigner break; case "Currencies": return ObjectType.Currency; + case "Rooms": + return ObjectType.Room; case "Realms": return ObjectType.Realm; case "Zones": @@ -392,6 +394,11 @@ namespace MudDesigner } } + private void SetStatus(string status) + { + lblStatus.Text = "Status: " + status; + } + /// /// Refreshes the Project Explorer incase the directory structure /// has changed, but was not reflected in the Explorer @@ -588,5 +595,47 @@ namespace MudDesigner if (e.KeyCode == Keys.Enter) FindObject(txtSearch.Text); } + + private void setAsInitialLocationToolStripMenuItem_Click(object sender, EventArgs e) + { + if (GetNodeType(treeExplorer.SelectedNode) == ObjectType.ZoneRoot) + { + StartingLocation location = new StartingLocation(); + + Zone zone = new Zone(); + string filename = ""; + if (Path.GetExtension(treeExplorer.SelectedNode.FullPath) == "") + { + filename = treeExplorer.SelectedNode.Text + ".zone"; + } + else + filename = treeExplorer.SelectedNode.Text; + + string path = Path.Combine(FileManager.GetDataPath(SaveDataTypes.Zones), Path.GetFileNameWithoutExtension(filename)); + path = Path.Combine(path, filename); + zone = (Zone)zone.Load(path); + + location.Realm = "No Realm Associated."; + location.Zone = zone.Name; + location.Room = zone.EntranceRoom; + _Project.InitialLocation = location; + _Project.Save(Path.Combine(FileManager.GetDataPath(SaveDataTypes.Root), "Game.xml")); + SetStatus("Location Assigned successfully."); + } + + else + MessageBox.Show("You must select a Zone File when you set the Initial Location", "Mud Designer"); + } + + private void freshLoginToolStripMenuItem_Click(object sender, EventArgs e) + { + Runtime form = new Runtime(); + form.Show(); + this.Hide(); + while (form.Created) + Application.DoEvents(); + + this.Show(); + } } } diff --git a/Mud Designer/Designer.resx b/Mud Designer/Designer.resx index 09581c8..779a437 100644 --- a/Mud Designer/Designer.resx +++ b/Mud Designer/Designer.resx @@ -120,6 +120,9 @@ 19, 12 + + 603, 17 + 128, 15 @@ -136,6 +139,11 @@ 382, 17 + + The properties of the currently loaded object are editable with the Object Properties window. Object changes are automatically saved. + +Note that new objects are not saved until their Name value is changed. + @@ -151,11 +159,6 @@ NYDrOepdlcysmTWWOrxqbceRWtaLk0VO1XW72D5Vckd2gMBfq8zdpmUG62NJvKM4+XyziDk24xmfWoGE s1c0gHPmbrPTpHNJKOCo2G1mZs20zcwUJ5yp1AB5+8/zEwgF5GMVDxh4AAAAAElFTkSuQmCC - - - The properties of the currently loaded object are editable with the Object Properties window. Object changes are automatically saved. - -Note that new objects are not saved until their Name value is changed. 42 diff --git a/Mud Designer/MudEngine/Characters/BaseCharacter.cs b/Mud Designer/MudEngine/Characters/BaseCharacter.cs index f023a7f..597a65b 100644 --- a/Mud Designer/MudEngine/Characters/BaseCharacter.cs +++ b/Mud Designer/MudEngine/Characters/BaseCharacter.cs @@ -2,13 +2,41 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.IO; using MudDesigner.MudEngine.Interfaces; using MudDesigner.MudEngine.GameObjects; +using MudDesigner.MudEngine.FileSystem; +using MudDesigner.MudEngine.GameCommands; +using MudDesigner.MudEngine.GameManagement; +using MudDesigner.MudEngine.GameObjects.Environment; +using MudDesigner.MudEngine.GameObjects.Items; namespace MudDesigner.MudEngine.Characters { public class BaseCharacter : BaseObject { + public Room CurrentRoom { get; set; } + + public virtual void OnTravel(AvailableTravelDirections travelDirection) + { + if (CurrentRoom.DoorwayExist(travelDirection.ToString())) + { + string fileName = ""; + if (CurrentRoom.Realm == "No Realm Associated.") + { + fileName = Path.Combine(FileManager.GetDataPath(SaveDataTypes.Zones), CurrentRoom.Zone); + fileName = Path.Combine(fileName, "Rooms"); + } + else + { + fileName = Path.Combine(FileManager.GetDataPath(CurrentRoom.Realm, CurrentRoom.Zone), "Rooms"); + } + string connectedRoom = CurrentRoom.GetDoor(travelDirection).ConnectedRoom; + fileName = Path.Combine(fileName, connectedRoom); + fileName += ".room"; + CurrentRoom = (Room)CurrentRoom.Load(fileName); + } + } } } diff --git a/Mud Designer/MudEngine/Characters/Controlled/PlayerBasic.cs b/Mud Designer/MudEngine/Characters/Controlled/PlayerBasic.cs index ef51afb..22249ed 100644 --- a/Mud Designer/MudEngine/Characters/Controlled/PlayerBasic.cs +++ b/Mud Designer/MudEngine/Characters/Controlled/PlayerBasic.cs @@ -5,7 +5,7 @@ using System.Text; namespace MudDesigner.MudEngine.Characters.Controlled { - public class PlayerBasic + public class PlayerBasic : BaseCharacter { } } diff --git a/Mud Designer/MudEngine/GameManagement/GameScript.cs b/Mud Designer/MudEngine/GameManagement/GameScript.cs index b33fc1a..bae218d 100644 --- a/Mud Designer/MudEngine/GameManagement/GameScript.cs +++ b/Mud Designer/MudEngine/GameManagement/GameScript.cs @@ -15,8 +15,6 @@ namespace MudDesigner.MudEngine.GameManagement { public class GameScript { - ScriptObject _ScriptObject; - public GameScript() { } diff --git a/Mud Designer/MudEngine/GameManagement/ProjectInformation.cs b/Mud Designer/MudEngine/GameManagement/ProjectInformation.cs index 1983ff9..cb6354f 100644 --- a/Mud Designer/MudEngine/GameManagement/ProjectInformation.cs +++ b/Mud Designer/MudEngine/GameManagement/ProjectInformation.cs @@ -112,12 +112,9 @@ namespace MudDesigner.MudEngine.GameManagement [Browsable(false)] public string ProjectPath { get; set; } - [Browsable(false)] - public StartingLocation InitialLocation - { - get; - set; - } + [Category("Environment Settings")] + [ReadOnly(true)] + public StartingLocation InitialLocation { get; set; } [Browsable(false)] public string Story @@ -126,6 +123,7 @@ namespace MudDesigner.MudEngine.GameManagement set; } + [Category("Object Setup")] public string Filename { get @@ -142,6 +140,7 @@ namespace MudDesigner.MudEngine.GameManagement _Filename = "Game.xml"; BaseCurrencyAmount = 1; BaseCurrencyName = "Copper"; + InitialLocation = new StartingLocation(); } public void Save(string filename) diff --git a/Mud Designer/MudEngine/GameObjects/Environment/Room.cs b/Mud Designer/MudEngine/GameObjects/Environment/Room.cs index 366f8b3..ef1570c 100644 --- a/Mud Designer/MudEngine/GameObjects/Environment/Room.cs +++ b/Mud Designer/MudEngine/GameObjects/Environment/Room.cs @@ -93,5 +93,15 @@ namespace MudDesigner.MudEngine.GameObjects.Environment return false; } + + public Door GetDoor(AvailableTravelDirections travelDirection) + { + foreach (Door door in this.Doorways) + { + if (door.TravelDirection == travelDirection) + return door; + } + return null; + } } } diff --git a/Mud Designer/MudEngine/GameObjects/Environment/StartingLocation.cs b/Mud Designer/MudEngine/GameObjects/Environment/StartingLocation.cs index 8101723..18ad6cd 100644 --- a/Mud Designer/MudEngine/GameObjects/Environment/StartingLocation.cs +++ b/Mud Designer/MudEngine/GameObjects/Environment/StartingLocation.cs @@ -10,5 +10,23 @@ namespace MudDesigner.MudEngine.GameObjects.Environment public string Room; public string Zone; public string Realm; + + public override string ToString() + { + if (string.IsNullOrEmpty(Room)) + return "No initial location defined."; + else + { + if (Realm == "No Realm Associated.") + { + return Zone + "->" + Room; + } + else + { + return Realm + "->" + Zone + "->" + Room; + } + } + + } } } \ No newline at end of file diff --git a/Mud Designer/MudEngine/GameObjects/Environment/Zone.cs b/Mud Designer/MudEngine/GameObjects/Environment/Zone.cs index 2461217..322d72c 100644 --- a/Mud Designer/MudEngine/GameObjects/Environment/Zone.cs +++ b/Mud Designer/MudEngine/GameObjects/Environment/Zone.cs @@ -57,6 +57,9 @@ namespace MudDesigner.MudEngine.GameObjects.Environment [Description("Collection of Rooms that have been created. Editing the Rooms Collection lets you manage the Zones rooms.")] public List Rooms { get; set; } + [Category("Environment Information")] + public string EntranceRoom { get; set; } + public Zone() { Rooms = new List(); diff --git a/Mud Designer/Runtime.Designer.cs b/Mud Designer/Runtime.Designer.cs index f055130..9439d2f 100644 --- a/Mud Designer/Runtime.Designer.cs +++ b/Mud Designer/Runtime.Designer.cs @@ -29,8 +29,8 @@ private void InitializeComponent() { this.splitContainer1 = new System.Windows.Forms.SplitContainer(); - this.txtCommand = new System.Windows.Forms.TextBox(); this.txtConsole = new System.Windows.Forms.RichTextBox(); + this.txtCommand = new System.Windows.Forms.TextBox(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.SuspendLayout(); @@ -55,15 +55,6 @@ this.splitContainer1.SplitterDistance = 393; this.splitContainer1.TabIndex = 0; // - // txtCommand - // - this.txtCommand.Dock = System.Windows.Forms.DockStyle.Fill; - this.txtCommand.Location = new System.Drawing.Point(0, 0); - this.txtCommand.Name = "txtCommand"; - this.txtCommand.Size = new System.Drawing.Size(693, 20); - this.txtCommand.TabIndex = 1; - this.txtCommand.TextChanged += new System.EventHandler(this.txtCommand_TextChanged); - // // txtConsole // this.txtConsole.Dock = System.Windows.Forms.DockStyle.Fill; @@ -73,6 +64,15 @@ this.txtConsole.TabIndex = 0; this.txtConsole.Text = ""; // + // txtCommand + // + this.txtCommand.Dock = System.Windows.Forms.DockStyle.Fill; + this.txtCommand.Location = new System.Drawing.Point(0, 0); + this.txtCommand.Name = "txtCommand"; + this.txtCommand.Size = new System.Drawing.Size(693, 20); + this.txtCommand.TabIndex = 1; + this.txtCommand.TextChanged += new System.EventHandler(this.txtCommand_TextChanged); + // // Runtime // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -81,6 +81,7 @@ this.Controls.Add(this.splitContainer1); this.Name = "Runtime"; this.Text = "Runtime"; + this.Load += new System.EventHandler(this.Runtime_Load); this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel2.ResumeLayout(false); this.splitContainer1.Panel2.PerformLayout(); diff --git a/Mud Designer/Runtime.cs b/Mud Designer/Runtime.cs index 793df7b..35b7e75 100644 --- a/Mud Designer/Runtime.cs +++ b/Mud Designer/Runtime.cs @@ -10,6 +10,9 @@ using System.Text; using System.Windows.Forms; //Mud Designer +using MudDesigner.MudEngine.Characters; +using MudDesigner.MudEngine.Characters.Controlled; +using MudDesigner.MudEngine.Characters.NPC; using MudDesigner.MudEngine.GameCommands; using MudDesigner.MudEngine.FileSystem; using MudDesigner.MudEngine.GameManagement; @@ -21,15 +24,48 @@ namespace MudDesigner { public partial class Runtime : Form { - + PlayerBasic _Player; + Room _Room; + ProjectInformation _Project; + public Runtime() { InitializeComponent(); + _Player = new PlayerBasic(); + _Project = new ProjectInformation(); + _Room = new Room(); + } + + private void Runtime_Load(object sender, EventArgs e) + { + _Project = (ProjectInformation)_Project.Load(FileManager.GetDataPath(SaveDataTypes.Root)); + if (_Project.InitialLocation.Zone == "") + { + MessageBox.Show("No Initial Zone was defined within the Project Information. Please associated a Zone to the Projects Initial Zone setting in order to launch the game.", + "Mud Designer", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + Application.Exit(); + } + + string filename = FileManager.GetDataPath(SaveDataTypes.Root); + if (_Project.InitialLocation.Realm != "No Realm Associated.") + { + filename = Path.Combine(filename, "Realms"); + filename = Path.Combine(filename, _Project.InitialLocation.Realm); + } + + filename = Path.Combine(filename, "Zones"); + filename = Path.Combine(filename, _Project.InitialLocation.Zone); + filename = Path.Combine(filename, "Rooms"); + filename = Path.Combine(filename, _Project.InitialLocation.Room); + filename += ".room"; + _Room = (Room)_Room.Load(filename); + _Player.CurrentRoom = _Room; + _Player.OnTravel(AvailableTravelDirections.North); } private void txtCommand_TextChanged(object sender, EventArgs e) { - + } } }