Changes project wide with this check-in.
MudCompiler: No longer works. Needs to be re-wrote to support the new Alpha 2.0 engine MudDesigenr: Removed most of the forms since we are not working on it. Only form left is Project Manager, which will be removed shortly as well. MudGame: No longer runs. All of the source code was removed due to MudEngine Alpha 2.0 source changing drastically. MudEngine: Alpha 2.0 source code finally checked-in. It contains the full re-build of the engine. A lot of new abstract classes have been added.
This commit is contained in:
parent
5be2f9bf5b
commit
a365256d53
48 changed files with 2254 additions and 2021 deletions
|
@ -66,10 +66,6 @@
|
|||
<Project>{498943A8-DF5A-4DB0-B506-0BFF44788657}</Project>
|
||||
<Name>MudEngine</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\rScripting\rScripting.csproj">
|
||||
<Project>{BC1B32DA-7209-4B32-8171-A190EF21F5D6}</Project>
|
||||
<Name>rScripting</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="frmCompiler.resx">
|
||||
|
|
|
@ -4,7 +4,6 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using MudEngine.Scripting;
|
||||
|
||||
namespace MUDCompiler
|
||||
{
|
||||
|
|
|
@ -11,16 +11,18 @@ namespace MUDCompiler
|
|||
{
|
||||
public partial class frmCompiler : Form
|
||||
{
|
||||
MudEngine.GameManagement.Game game = new MudEngine.GameManagement.Game();
|
||||
//MudEngine.GameManagement.Game game = new MudEngine.GameManagement.Game();
|
||||
|
||||
public frmCompiler()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
MessageBox.Show("Mud Compiler application needs to be re-wrote to support Alpha 2.0");
|
||||
}
|
||||
|
||||
private void openDirectoryToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
rScripting.CompileEngine engine = new rScripting.CompileEngine();
|
||||
/* rScripting.CompileEngine engine = new rScripting.CompileEngine();
|
||||
|
||||
FolderBrowserDialog browse = new FolderBrowserDialog();
|
||||
browse.ShowDialog();
|
||||
|
@ -37,7 +39,7 @@ namespace MUDCompiler
|
|||
txtConsole.Text = "Compiled without error.";
|
||||
else
|
||||
txtConsole.Text = engine.Errors;
|
||||
}
|
||||
*/ }
|
||||
|
||||
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
@ -46,7 +48,7 @@ namespace MUDCompiler
|
|||
|
||||
private void openScriptToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
rScripting.CompileEngine engine = new rScripting.CompileEngine();
|
||||
/* rScripting.CompileEngine engine = new rScripting.CompileEngine();
|
||||
engine.Compiler = "MudScriptCompiler";
|
||||
|
||||
OpenFileDialog browse = new OpenFileDialog();
|
||||
|
@ -65,6 +67,6 @@ namespace MUDCompiler
|
|||
txtConsole.Text = "Compiled without error.";
|
||||
else
|
||||
txtConsole.Text = engine.Errors;
|
||||
}
|
||||
*/ }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,11 +11,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MudClient", "MudClient\MudC
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MudDesigner", "MudDesigner\MudDesigner.csproj", "{5B18E552-26D0-4491-8BAC-FF80046F0B0F}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "rScripting", "rScripting\rScripting.csproj", "{BC1B32DA-7209-4B32-8171-A190EF21F5D6}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(TeamFoundationVersionControl) = preSolution
|
||||
SccNumberOfProjects = 7
|
||||
SccNumberOfProjects = 6
|
||||
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
|
||||
SccTeamFoundationServer = https://tfs.codeplex.com/tfs/tfs03
|
||||
SccLocalPath0 = .
|
||||
|
@ -34,9 +32,6 @@ Global
|
|||
SccProjectUniqueName5 = MudDesigner\\MudDesigner.csproj
|
||||
SccProjectName5 = MudDesigner
|
||||
SccLocalPath5 = MudDesigner
|
||||
SccProjectUniqueName6 = rScripting\\rScripting.csproj
|
||||
SccProjectName6 = rScripting
|
||||
SccLocalPath6 = rScripting
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -97,16 +92,6 @@ Global
|
|||
{5B18E552-26D0-4491-8BAC-FF80046F0B0F}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||
{5B18E552-26D0-4491-8BAC-FF80046F0B0F}.Release|x86.ActiveCfg = Release|x86
|
||||
{5B18E552-26D0-4491-8BAC-FF80046F0B0F}.Release|x86.Build.0 = Release|x86
|
||||
{BC1B32DA-7209-4B32-8171-A190EF21F5D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BC1B32DA-7209-4B32-8171-A190EF21F5D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BC1B32DA-7209-4B32-8171-A190EF21F5D6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{BC1B32DA-7209-4B32-8171-A190EF21F5D6}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{BC1B32DA-7209-4B32-8171-A190EF21F5D6}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{BC1B32DA-7209-4B32-8171-A190EF21F5D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BC1B32DA-7209-4B32-8171-A190EF21F5D6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BC1B32DA-7209-4B32-8171-A190EF21F5D6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{BC1B32DA-7209-4B32-8171-A190EF21F5D6}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{BC1B32DA-7209-4B32-8171-A190EF21F5D6}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -51,18 +51,6 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Client.cs" />
|
||||
<Compile Include="frmDesigner.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="frmDesigner.Designer.cs">
|
||||
<DependentUpon>frmDesigner.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="frmInputBox.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="frmInputBox.Designer.cs">
|
||||
<DependentUpon>frmInputBox.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="frmProjectManager.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
@ -71,12 +59,6 @@
|
|||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="frmDesigner.resx">
|
||||
<DependentUpon>frmDesigner.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="frmInputBox.resx">
|
||||
<DependentUpon>frmInputBox.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="frmProjectManager.resx">
|
||||
<DependentUpon>frmProjectManager.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
|
320
MudDesigner/frmDesigner.Designer.cs
generated
320
MudDesigner/frmDesigner.Designer.cs
generated
|
@ -1,320 +0,0 @@
|
|||
namespace MudDesigner
|
||||
{
|
||||
partial class frmDesigner
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveProjectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.closeProjectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.cutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.pasteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.preferencesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.createObjectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.environmentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.realmToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.zoneToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.roomToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||
this.txtCommand = new System.Windows.Forms.TextBox();
|
||||
this.txtConsole = new System.Windows.Forms.RichTextBox();
|
||||
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.propertyGrid1 = new System.Windows.Forms.PropertyGrid();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
||||
this.splitContainer1.Panel1.SuspendLayout();
|
||||
this.splitContainer1.Panel2.SuspendLayout();
|
||||
this.splitContainer1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
|
||||
this.splitContainer2.Panel1.SuspendLayout();
|
||||
this.splitContainer2.Panel2.SuspendLayout();
|
||||
this.splitContainer2.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// statusStrip1
|
||||
//
|
||||
this.statusStrip1.Location = new System.Drawing.Point(0, 695);
|
||||
this.statusStrip1.Name = "statusStrip1";
|
||||
this.statusStrip1.Size = new System.Drawing.Size(993, 22);
|
||||
this.statusStrip1.TabIndex = 1;
|
||||
this.statusStrip1.Text = "statusStrip1";
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.fileToolStripMenuItem,
|
||||
this.editToolStripMenuItem,
|
||||
this.createObjectToolStripMenuItem});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
this.menuStrip1.Size = new System.Drawing.Size(993, 24);
|
||||
this.menuStrip1.TabIndex = 2;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// fileToolStripMenuItem
|
||||
//
|
||||
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.saveProjectToolStripMenuItem,
|
||||
this.toolStripMenuItem1,
|
||||
this.closeProjectToolStripMenuItem});
|
||||
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
|
||||
this.fileToolStripMenuItem.Text = "File";
|
||||
//
|
||||
// saveProjectToolStripMenuItem
|
||||
//
|
||||
this.saveProjectToolStripMenuItem.Name = "saveProjectToolStripMenuItem";
|
||||
this.saveProjectToolStripMenuItem.Size = new System.Drawing.Size(143, 22);
|
||||
this.saveProjectToolStripMenuItem.Text = "Save Project";
|
||||
//
|
||||
// toolStripMenuItem1
|
||||
//
|
||||
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
|
||||
this.toolStripMenuItem1.Size = new System.Drawing.Size(140, 6);
|
||||
//
|
||||
// closeProjectToolStripMenuItem
|
||||
//
|
||||
this.closeProjectToolStripMenuItem.Name = "closeProjectToolStripMenuItem";
|
||||
this.closeProjectToolStripMenuItem.Size = new System.Drawing.Size(143, 22);
|
||||
this.closeProjectToolStripMenuItem.Text = "Close Project";
|
||||
//
|
||||
// editToolStripMenuItem
|
||||
//
|
||||
this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.cutToolStripMenuItem,
|
||||
this.copyToolStripMenuItem,
|
||||
this.pasteToolStripMenuItem,
|
||||
this.toolStripMenuItem2,
|
||||
this.preferencesToolStripMenuItem});
|
||||
this.editToolStripMenuItem.Name = "editToolStripMenuItem";
|
||||
this.editToolStripMenuItem.Size = new System.Drawing.Size(39, 20);
|
||||
this.editToolStripMenuItem.Text = "Edit";
|
||||
//
|
||||
// cutToolStripMenuItem
|
||||
//
|
||||
this.cutToolStripMenuItem.Name = "cutToolStripMenuItem";
|
||||
this.cutToolStripMenuItem.Size = new System.Drawing.Size(135, 22);
|
||||
this.cutToolStripMenuItem.Text = "Cut";
|
||||
//
|
||||
// copyToolStripMenuItem
|
||||
//
|
||||
this.copyToolStripMenuItem.Name = "copyToolStripMenuItem";
|
||||
this.copyToolStripMenuItem.Size = new System.Drawing.Size(135, 22);
|
||||
this.copyToolStripMenuItem.Text = "Copy";
|
||||
//
|
||||
// pasteToolStripMenuItem
|
||||
//
|
||||
this.pasteToolStripMenuItem.Name = "pasteToolStripMenuItem";
|
||||
this.pasteToolStripMenuItem.Size = new System.Drawing.Size(135, 22);
|
||||
this.pasteToolStripMenuItem.Text = "Paste";
|
||||
//
|
||||
// toolStripMenuItem2
|
||||
//
|
||||
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
|
||||
this.toolStripMenuItem2.Size = new System.Drawing.Size(132, 6);
|
||||
//
|
||||
// preferencesToolStripMenuItem
|
||||
//
|
||||
this.preferencesToolStripMenuItem.Name = "preferencesToolStripMenuItem";
|
||||
this.preferencesToolStripMenuItem.Size = new System.Drawing.Size(135, 22);
|
||||
this.preferencesToolStripMenuItem.Text = "Preferences";
|
||||
//
|
||||
// createObjectToolStripMenuItem
|
||||
//
|
||||
this.createObjectToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.environmentToolStripMenuItem});
|
||||
this.createObjectToolStripMenuItem.Name = "createObjectToolStripMenuItem";
|
||||
this.createObjectToolStripMenuItem.Size = new System.Drawing.Size(91, 20);
|
||||
this.createObjectToolStripMenuItem.Text = "Create Object";
|
||||
//
|
||||
// environmentToolStripMenuItem
|
||||
//
|
||||
this.environmentToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.realmToolStripMenuItem,
|
||||
this.zoneToolStripMenuItem,
|
||||
this.roomToolStripMenuItem});
|
||||
this.environmentToolStripMenuItem.Name = "environmentToolStripMenuItem";
|
||||
this.environmentToolStripMenuItem.Size = new System.Drawing.Size(142, 22);
|
||||
this.environmentToolStripMenuItem.Text = "Environment";
|
||||
//
|
||||
// realmToolStripMenuItem
|
||||
//
|
||||
this.realmToolStripMenuItem.Name = "realmToolStripMenuItem";
|
||||
this.realmToolStripMenuItem.Size = new System.Drawing.Size(107, 22);
|
||||
this.realmToolStripMenuItem.Text = "Realm";
|
||||
//
|
||||
// zoneToolStripMenuItem
|
||||
//
|
||||
this.zoneToolStripMenuItem.Name = "zoneToolStripMenuItem";
|
||||
this.zoneToolStripMenuItem.Size = new System.Drawing.Size(107, 22);
|
||||
this.zoneToolStripMenuItem.Text = "Zone";
|
||||
//
|
||||
// roomToolStripMenuItem
|
||||
//
|
||||
this.roomToolStripMenuItem.Name = "roomToolStripMenuItem";
|
||||
this.roomToolStripMenuItem.Size = new System.Drawing.Size(107, 22);
|
||||
this.roomToolStripMenuItem.Text = "Room";
|
||||
//
|
||||
// splitContainer1
|
||||
//
|
||||
this.splitContainer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.splitContainer1.Location = new System.Drawing.Point(0, 24);
|
||||
this.splitContainer1.Name = "splitContainer1";
|
||||
//
|
||||
// splitContainer1.Panel1
|
||||
//
|
||||
this.splitContainer1.Panel1.Controls.Add(this.txtCommand);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.txtConsole);
|
||||
//
|
||||
// splitContainer1.Panel2
|
||||
//
|
||||
this.splitContainer1.Panel2.Controls.Add(this.splitContainer2);
|
||||
this.splitContainer1.Size = new System.Drawing.Size(993, 671);
|
||||
this.splitContainer1.SplitterDistance = 714;
|
||||
this.splitContainer1.TabIndex = 3;
|
||||
//
|
||||
// txtCommand
|
||||
//
|
||||
this.txtCommand.Location = new System.Drawing.Point(0, 324);
|
||||
this.txtCommand.Name = "txtCommand";
|
||||
this.txtCommand.Size = new System.Drawing.Size(698, 20);
|
||||
this.txtCommand.TabIndex = 1;
|
||||
this.txtCommand.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtCommand_KeyDown);
|
||||
//
|
||||
// txtConsole
|
||||
//
|
||||
this.txtConsole.Location = new System.Drawing.Point(0, 0);
|
||||
this.txtConsole.Name = "txtConsole";
|
||||
this.txtConsole.Size = new System.Drawing.Size(698, 318);
|
||||
this.txtConsole.TabIndex = 0;
|
||||
this.txtConsole.Text = "";
|
||||
//
|
||||
// splitContainer2
|
||||
//
|
||||
this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.splitContainer2.Location = new System.Drawing.Point(0, 0);
|
||||
this.splitContainer2.Name = "splitContainer2";
|
||||
this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal;
|
||||
//
|
||||
// splitContainer2.Panel1
|
||||
//
|
||||
this.splitContainer2.Panel1.Controls.Add(this.groupBox1);
|
||||
//
|
||||
// splitContainer2.Panel2
|
||||
//
|
||||
this.splitContainer2.Panel2.Controls.Add(this.propertyGrid1);
|
||||
this.splitContainer2.Size = new System.Drawing.Size(273, 669);
|
||||
this.splitContainer2.SplitterDistance = 213;
|
||||
this.splitContainer2.TabIndex = 0;
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.groupBox1.Location = new System.Drawing.Point(0, 0);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(273, 213);
|
||||
this.groupBox1.TabIndex = 0;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Project Settings";
|
||||
//
|
||||
// propertyGrid1
|
||||
//
|
||||
this.propertyGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.propertyGrid1.Location = new System.Drawing.Point(0, 0);
|
||||
this.propertyGrid1.Name = "propertyGrid1";
|
||||
this.propertyGrid1.Size = new System.Drawing.Size(273, 452);
|
||||
this.propertyGrid1.TabIndex = 4;
|
||||
//
|
||||
// frmDesigner
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.ClientSize = new System.Drawing.Size(993, 717);
|
||||
this.Controls.Add(this.splitContainer1);
|
||||
this.Controls.Add(this.statusStrip1);
|
||||
this.Controls.Add(this.menuStrip1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "frmDesigner";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Mud Designer";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmDesigner_FormClosing);
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
this.splitContainer1.Panel1.ResumeLayout(false);
|
||||
this.splitContainer1.Panel1.PerformLayout();
|
||||
this.splitContainer1.Panel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
|
||||
this.splitContainer1.ResumeLayout(false);
|
||||
this.splitContainer2.Panel1.ResumeLayout(false);
|
||||
this.splitContainer2.Panel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
|
||||
this.splitContainer2.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.StatusStrip statusStrip1;
|
||||
private System.Windows.Forms.MenuStrip menuStrip1;
|
||||
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem saveProjectToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
|
||||
private System.Windows.Forms.ToolStripMenuItem closeProjectToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem cutToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem pasteToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem2;
|
||||
private System.Windows.Forms.ToolStripMenuItem preferencesToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem createObjectToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem environmentToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem realmToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem zoneToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem roomToolStripMenuItem;
|
||||
private System.Windows.Forms.SplitContainer splitContainer1;
|
||||
private System.Windows.Forms.SplitContainer splitContainer2;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.PropertyGrid propertyGrid1;
|
||||
private System.Windows.Forms.TextBox txtCommand;
|
||||
private System.Windows.Forms.RichTextBox txtConsole;
|
||||
|
||||
}
|
||||
}
|
|
@ -1,141 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
using MudEngine.GameManagement;
|
||||
using MudEngine.FileSystem;
|
||||
|
||||
namespace MudDesigner
|
||||
{
|
||||
public partial class frmDesigner : Form
|
||||
{
|
||||
private Game _Game;
|
||||
private Client _Client;
|
||||
private Thread _ClientThread;
|
||||
|
||||
private Boolean _IsRenaming;
|
||||
private String _OldName;
|
||||
|
||||
private Boolean _TimeOut;
|
||||
private Object _SelectedObject;
|
||||
|
||||
public frmDesigner(Game game, Client client)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_Game = game;
|
||||
_Client = client;
|
||||
|
||||
MudEngine.GameObjects.Environment.Room r = new MudEngine.GameObjects.Environment.Room(_Game);
|
||||
this.propertyGrid1.SelectedObject = _Game;
|
||||
|
||||
_TimeOut = false;
|
||||
_Client.Send("Hello world", false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the project.
|
||||
/// </summary>
|
||||
public void Save()
|
||||
{
|
||||
if ((String.IsNullOrEmpty(_Game.GameTitle)) || (_Game.GameTitle == new Game().GameTitle))
|
||||
return;
|
||||
|
||||
if ((_IsRenaming) && (Directory.Exists(Path.Combine("Projects", _OldName))))
|
||||
{
|
||||
Directory.Delete(Path.Combine("Projects", _OldName), true);
|
||||
File.Delete(Path.Combine(Environment.CurrentDirectory, _OldName + ".ini"));
|
||||
}
|
||||
_Game.Save();
|
||||
}
|
||||
|
||||
private void frmDesigner_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
DialogResult result = MessageBox.Show("Save Changes?", this.Text, MessageBoxButtons.YesNoCancel);
|
||||
|
||||
if (result == System.Windows.Forms.DialogResult.Cancel)
|
||||
{
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
else if (result == System.Windows.Forms.DialogResult.Yes)
|
||||
this.Save();
|
||||
|
||||
}
|
||||
|
||||
private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
|
||||
{
|
||||
if (e.ChangedItem.Label == "GameTitle")
|
||||
{
|
||||
String Env = _Game.DataPaths.Environment.Replace(e.OldValue.ToString(), e.ChangedItem.Value.ToString());
|
||||
String plyr = _Game.DataPaths.Players.Replace(e.OldValue.ToString(), e.ChangedItem.Value.ToString());
|
||||
String scrpt = _Game.DataPaths.Scripts.Replace(e.OldValue.ToString(), e.ChangedItem.Value.ToString());
|
||||
|
||||
_Game.DataPaths = new SaveDataPaths(Env, plyr,scrpt);
|
||||
|
||||
_IsRenaming = true;
|
||||
_OldName = e.OldValue.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeObject(Object obj)
|
||||
{
|
||||
_SelectedObject = obj;
|
||||
propertyGrid1.SelectedObject = obj;
|
||||
}
|
||||
|
||||
private void btnNewRealm_Click(object sender, EventArgs e)
|
||||
{
|
||||
ChangeObject(new MudEngine.GameObjects.Environment.Realm(_Game));
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
ChangeObject(new MudEngine.GameObjects.Environment.Zone(_Game));
|
||||
}
|
||||
|
||||
private void txtCommand_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Enter)
|
||||
{
|
||||
_Client.Send(txtCommand.Text, true);
|
||||
|
||||
System.Windows.Forms.Timer t = new System.Windows.Forms.Timer();
|
||||
t.Interval = 10000;
|
||||
t.Tick += new EventHandler(timerTick);
|
||||
|
||||
_TimeOut = false;
|
||||
String result;
|
||||
|
||||
while (!_TimeOut)
|
||||
{
|
||||
if (_Client.Receive(out result, 1))
|
||||
{
|
||||
txtConsole.Text += result;
|
||||
}
|
||||
else
|
||||
_TimeOut = true;
|
||||
}
|
||||
|
||||
txtConsole.Text += "\n";
|
||||
}
|
||||
}
|
||||
|
||||
void timerTick(object sender, EventArgs e)
|
||||
{
|
||||
_TimeOut = true;
|
||||
}
|
||||
|
||||
void UpdateConsole(String message)
|
||||
{
|
||||
txtConsole.Text += message;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,126 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>133, 17</value>
|
||||
</metadata>
|
||||
</root>
|
100
MudDesigner/frmInputBox.Designer.cs
generated
100
MudDesigner/frmInputBox.Designer.cs
generated
|
@ -1,100 +0,0 @@
|
|||
namespace MudDesigner
|
||||
{
|
||||
partial class frmInputBox
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.lblDescription = new System.Windows.Forms.Label();
|
||||
this.txtInput = new System.Windows.Forms.TextBox();
|
||||
this.btnCancel = new System.Windows.Forms.Button();
|
||||
this.btnOK = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// lblDescription
|
||||
//
|
||||
this.lblDescription.Location = new System.Drawing.Point(0, 0);
|
||||
this.lblDescription.Name = "lblDescription";
|
||||
this.lblDescription.Size = new System.Drawing.Size(353, 87);
|
||||
this.lblDescription.TabIndex = 0;
|
||||
this.lblDescription.Text = "Place input directions here via frmInputBox.Description";
|
||||
//
|
||||
// txtInput
|
||||
//
|
||||
this.txtInput.Location = new System.Drawing.Point(3, 90);
|
||||
this.txtInput.Name = "txtInput";
|
||||
this.txtInput.Size = new System.Drawing.Size(350, 20);
|
||||
this.txtInput.TabIndex = 1;
|
||||
this.txtInput.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtInput_KeyDown);
|
||||
//
|
||||
// btnCancel
|
||||
//
|
||||
this.btnCancel.Location = new System.Drawing.Point(278, 116);
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Size = new System.Drawing.Size(75, 24);
|
||||
this.btnCancel.TabIndex = 2;
|
||||
this.btnCancel.Text = "Cancel";
|
||||
this.btnCancel.UseVisualStyleBackColor = true;
|
||||
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
|
||||
//
|
||||
// btnOK
|
||||
//
|
||||
this.btnOK.Location = new System.Drawing.Point(197, 116);
|
||||
this.btnOK.Name = "btnOK";
|
||||
this.btnOK.Size = new System.Drawing.Size(75, 24);
|
||||
this.btnOK.TabIndex = 3;
|
||||
this.btnOK.Text = "OK";
|
||||
this.btnOK.UseVisualStyleBackColor = true;
|
||||
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
|
||||
//
|
||||
// frmInputBox
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(356, 145);
|
||||
this.Controls.Add(this.btnOK);
|
||||
this.Controls.Add(this.btnCancel);
|
||||
this.Controls.Add(this.txtInput);
|
||||
this.Controls.Add(this.lblDescription);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "frmInputBox";
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label lblDescription;
|
||||
private System.Windows.Forms.TextBox txtInput;
|
||||
private System.Windows.Forms.Button btnCancel;
|
||||
private System.Windows.Forms.Button btnOK;
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace MudDesigner
|
||||
{
|
||||
public partial class frmInputBox : Form
|
||||
{
|
||||
public bool IsCancel { get; set; }
|
||||
|
||||
public String Description { get { return this.lblDescription.Text; } set { this.lblDescription.Text = value; } }
|
||||
|
||||
public String Input { get { return this.txtInput.Text; } private set { this.txtInput.Text = value; } }
|
||||
|
||||
public frmInputBox(String desc)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.Description = desc;
|
||||
}
|
||||
|
||||
private void btnOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Hide();
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
IsCancel = true;
|
||||
Input = String.Empty;
|
||||
}
|
||||
|
||||
private void txtInput_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Enter)
|
||||
btnOK_Click(sender, null);
|
||||
else if (e.KeyCode == Keys.Escape)
|
||||
btnCancel_Click(sender, null);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,120 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
|
@ -9,10 +9,6 @@ using System.Windows.Forms;
|
|||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
using MudEngine.FileSystem;
|
||||
using MudEngine.GameManagement;
|
||||
using MudEngine.Scripting;
|
||||
|
||||
namespace MudDesigner
|
||||
{
|
||||
public partial class frmProjectManager : Form
|
||||
|
@ -20,8 +16,6 @@ namespace MudDesigner
|
|||
public frmProjectManager()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void RefreshProjects()
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MudEngine.GameObjects.Characters
|
||||
{
|
||||
/// <summary>
|
||||
/// This class is the base class that handles the managing of a Characters stats.
|
||||
/// It was decided to place stats within their own class, to allow for developers to easily add additional
|
||||
/// stats or adjust how stats are used within their MUD's without having to modify the Character code themselves.
|
||||
/// </summary>
|
||||
public class BaseStats
|
||||
{
|
||||
/// <summary>
|
||||
/// Strength is a measure of muscle, endurance and stamina combined.
|
||||
/// Strength affects the ability of characters to lift and carry weights, melee attack rolls,
|
||||
/// damage rolls (for both melee and ranged weapons,) the Jump, Climb, and Swim skills,
|
||||
/// several combat actions, and general checks involving moving or breaking stubborn objects.
|
||||
/// </summary>
|
||||
public Int32 Strength { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Dexterity encompasses a number of physical attributes including hand-eye coordination, agility,
|
||||
/// reflexes, fine motor skills, balance and speed of movement; a high dexterity score indicates
|
||||
/// superiority in all these attributes. Dexterity affects characters with regard to initiative in combat,
|
||||
/// ranged attack rolls, Armor Class, Reflex saves, and the Balance, Escape Artist, Hide, Move Silently,
|
||||
/// Open Lock, Ride, Sleight of Hand, Tumble, and Use Rope skills. It also affects the number of additional
|
||||
/// attacks of opportunity granted by the Combat Reflexes feat. Dexterity is the ability most influenced by
|
||||
/// outside influences (such as armor).
|
||||
/// </summary>
|
||||
public Int32 Dexterity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constitution is a term which encompasses the character's physique, toughness, health and resistance to disease and poison.
|
||||
/// The higher a character's Constitution, the more hit points that character will have.
|
||||
/// Constitution also is important for Fortitude saves, the Concentration skill, and fatigue-based general checks.
|
||||
/// Constitution also determines the duration of a barbarian's rage.
|
||||
/// Unlike the other ability scores, which render the character unconscious or immobile when they hit 0,
|
||||
/// having 0 Constitution is fatal.
|
||||
/// </summary>
|
||||
public Int32 Constitution { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Intelligence is similar to IQ, but also includes mnemonic ability, reasoning and learning ability outside
|
||||
/// those measured by the written word. Intelligence dictates the number of languages a character can learn,
|
||||
/// and it influences the number of spells a preparation-based arcane spellcaster (like a Wizard) may cast per
|
||||
/// day, and the effectiveness of said spells. It also affects how many skill points a character gains per level,
|
||||
/// the Appraise, Craft, Decipher Script, Disable Device, Forgery, Knowledge, Search, and Spellcraft skills,
|
||||
/// and bardic knowledge checks.
|
||||
/// </summary>
|
||||
public Int32 Intelligence { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Wisdom is a composite term for the characters enlightenment, judgement, wile, willpower and intuitiveness.
|
||||
/// Wisdom influences the number of spells a divine spellcaster (like clerics, druids, paladins, and rangers)
|
||||
/// can cast per day, and the effectiveness of said spells. It also affects Will saving throws, the Heal, Listen,
|
||||
/// Profession, Sense Motive, Spot, and Survival skills, the effectiveness of the Stunning Fist feat, and a
|
||||
/// monk's quivering palm attack.
|
||||
/// </summary>
|
||||
public Int32 Wisdom { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Charisma is the measure of the character's combined physical attractiveness, persuasiveness, and personal magnetism.
|
||||
/// A generally non-beautiful character can have a very high charisma due to strong measures of the other two aspects of charisma.
|
||||
/// Charisma influences how many spells spontaneous arcane spellcasters (like sorcerers and bards) can cast per day, and the
|
||||
/// effectiveness of said spells. It also affects Bluff, Diplomacy, Disguise, Gather Information, Handle Animal,
|
||||
/// Intimidate, Perform, and Use Magic Device checks, how often and how effectively clerics and paladins can turn
|
||||
/// undead, the wild empathy of druids and rangers, and a paladin's lay on hands ability.
|
||||
/// </summary>
|
||||
public Int32 Charisma { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Experience is given to the player based off activities that they perform.
|
||||
/// </summary>
|
||||
public Int32 Experience { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -1,489 +0,0 @@
|
|||
//Microsoft .NET Framework
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.Xml.Serialization;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Reflection;
|
||||
|
||||
//MUD Engine
|
||||
using MudEngine.FileSystem;
|
||||
using MudEngine.GameObjects;
|
||||
using MudEngine.GameObjects.Characters;
|
||||
using MudEngine.GameObjects.Environment;
|
||||
using MudEngine.Scripting;
|
||||
using MudEngine.Networking;
|
||||
using MudEngine.Core;
|
||||
|
||||
namespace MudEngine.GameManagement
|
||||
{
|
||||
/// <summary>
|
||||
/// Manages all of the projects settings.
|
||||
/// </summary>
|
||||
[XmlInclude(typeof(StartingLocation))]
|
||||
[XmlInclude(typeof(Currency))]
|
||||
public class Game : BaseGame
|
||||
{
|
||||
#region ==== Properties & Types ====
|
||||
|
||||
#region Game Object Setup
|
||||
/// <summary>
|
||||
/// Gets or Sets if this game is running in debug mode. Additional information is sent to the log if enabled.
|
||||
/// </summary>
|
||||
public static Boolean IsDebug { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets if the game will run with a server or not.
|
||||
/// </summary>
|
||||
public Boolean IsMultiplayer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets if this game is currently running.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public Boolean IsRunning { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets the paths to various project related objects.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public SaveDataPaths DataPaths { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public rScripting.CompileEngine Scripting { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets the path to the current project
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public String ProjectPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets if all objects will be laoded during server startup. Enabling this results in a slower server start time, but faster object access.
|
||||
/// </summary>
|
||||
[Category("Project Settings")]
|
||||
[Description("If enabled, all objects will be loaded during server startup resulting in a slower server start time, but faster load time during gameplay")]
|
||||
[Browsable(false)]
|
||||
public Boolean PreCacheObjects { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a copy of all identifiers being used in the game.
|
||||
/// </summary>
|
||||
internal List<BaseObject> WorldObjects { get; private set; }
|
||||
#endregion
|
||||
|
||||
#region Game Information
|
||||
[Category("Company Settings")]
|
||||
[Description("The name of the Company or Author building the game.")]
|
||||
/// <summary>
|
||||
/// Gets or Sets the name of the company
|
||||
/// </summary>
|
||||
public String CompanyName { get; set; }
|
||||
|
||||
[Category("Company Settings")]
|
||||
[Description("The website URL that a player can visit to view additional information related to the game")]
|
||||
/// <summary>
|
||||
/// Gets or Sets the companies website for this project
|
||||
/// </summary>
|
||||
public String Website { get; set; }
|
||||
|
||||
[Category("Project Settings")]
|
||||
[Description("The name of the game displayed to the users, and title bar of the runtime.")]
|
||||
public String GameTitle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets the current working version of the game.
|
||||
/// </summary>
|
||||
[Category("Project Settings")]
|
||||
[Description("The current working version of the game.")]
|
||||
public String Version { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public List<Currency> CurrencyList { get; set; }
|
||||
|
||||
[Category("Environment Settings")]
|
||||
[ReadOnly(true)]
|
||||
public Realm InitialRealm
|
||||
{
|
||||
get;
|
||||
internal set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Story that is displayed on initial player entry into the game
|
||||
/// </summary>
|
||||
public String Story { get; set; }
|
||||
|
||||
[Category("Project Settings")]
|
||||
[Description("Enable or Disable Auto-saving of players when the player travels")]
|
||||
/// <summary>
|
||||
/// Gets or Sets if the Game world is automatically saved at a specified interval.
|
||||
/// Players will be saved every-time they change location.
|
||||
/// </summary>
|
||||
public Boolean AutoSave { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets the interval in which the Game will automatically save every game object.
|
||||
/// </summary>
|
||||
public Int32 AutoSaveInterval { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets the minimum number of characters required to create a 'legal' password.
|
||||
/// Default value is 6 characters required for a password during character creation.
|
||||
/// </summary>
|
||||
public Int32 MinimumPasswordSize { get; set; }
|
||||
|
||||
[Category("Project Settings")]
|
||||
[Description("Hide Room names from being outputted to the console.")]
|
||||
/// <summary>
|
||||
/// Gets or Sets if room names are hidden during console output.
|
||||
/// </summary>
|
||||
public Boolean HideRoomNames { get; set; }
|
||||
|
||||
[Category("Game Currency")]
|
||||
[DefaultValue(1)]
|
||||
[Description("Sets the amount that the base currency is valued at.")]
|
||||
public Int32 BaseCurrencyAmount { get; set; }
|
||||
|
||||
|
||||
[Category("Game Currency")]
|
||||
[DefaultValue("Copper")]
|
||||
public String BaseCurrencyName { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public GameTime WorldTime { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public GameWorld World { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Networking
|
||||
/// <summary>
|
||||
/// Collection of players currently running on the server.
|
||||
/// </summary>
|
||||
protected BaseCharacter[] PlayerCollection;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current running Server object.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public Server Server { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets the protocol used by the server.
|
||||
/// </summary>
|
||||
public ProtocolType ServerType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets the port that the server will run on
|
||||
/// </summary>
|
||||
public Int32 ServerPort { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets the maximum number of Players permitted to run on this Games server.
|
||||
/// </summary>
|
||||
public Int32 MaximumPlayers { get; set; }
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region ==== Constructors ====
|
||||
public Game()
|
||||
{
|
||||
//Instance all of the Games Objects.
|
||||
CurrencyList = new List<Currency>();
|
||||
Scripting = new rScripting.CompileEngine(".cs");
|
||||
World = new GameWorld(this);
|
||||
WorldTime = new GameTime(this);
|
||||
InitialRealm = new Realm(this);
|
||||
|
||||
//Prepare the Save Paths for all of our Game objects.
|
||||
DataPaths = new SaveDataPaths("World", "Players", "Scripts");
|
||||
|
||||
//Setup default settings for the Game
|
||||
GameTitle = "New Game";
|
||||
BaseCurrencyAmount = 1;
|
||||
BaseCurrencyName = "Copper";
|
||||
Version = "1.0";
|
||||
Story = "";
|
||||
|
||||
//Setup default Networking settings
|
||||
IsMultiplayer = true;
|
||||
ServerType = ProtocolType.Tcp;
|
||||
ServerPort = 555;
|
||||
MaximumPlayers = 1000;
|
||||
|
||||
//Setup the player arrays
|
||||
//used to be in Start
|
||||
PlayerCollection = new BaseCharacter[MaximumPlayers];
|
||||
for (Int32 i = 0; i < MaximumPlayers; i++)
|
||||
PlayerCollection[i] = new BaseCharacter(this);
|
||||
|
||||
AutoSave = true;
|
||||
AutoSaveInterval = 60;
|
||||
|
||||
MinimumPasswordSize = 6;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ==== Methods ====
|
||||
/// <summary>
|
||||
/// Starts the game and runs the server if IsMultiplayer is true
|
||||
/// </summary>
|
||||
public virtual Boolean Start()
|
||||
{
|
||||
Log.Write("Game Initializing...");
|
||||
if (!Directory.Exists(DataPaths.Players))
|
||||
Directory.CreateDirectory(DataPaths.Players);
|
||||
|
||||
Scripting.Compiler = "MudScriptCompiler";
|
||||
|
||||
//Check for compiler errors after script compiling completes.
|
||||
if (!Scripting.Compile(DataPaths.Scripts))
|
||||
{
|
||||
Log.Write("CRITICAL ERROR: Game Script Repository failed to compile!");
|
||||
Log.Write(Scripting.Errors);
|
||||
}
|
||||
|
||||
/*
|
||||
* If a custom player script is loaded in the script engine, then the base commands are
|
||||
* loaded when the script is instanced automatically. If there is no script then these
|
||||
* don't get loaded and will need to be forced.
|
||||
* This prevents a duplicate "Loading Commands" message in the server console if the
|
||||
* player script exists and pre-loads the commands during script instancing in ScriptEngine.Initialize()
|
||||
*/
|
||||
Log.Write("Initializing Command Engine...");
|
||||
if ((CommandEngine.CommandCollection == null) || (CommandEngine.CommandCollection.Count == 0))
|
||||
CommandEngine.LoadBaseCommands();
|
||||
|
||||
if (IsDebug)
|
||||
{
|
||||
foreach (String command in CommandEngine.CommandCollection.Keys)
|
||||
Log.Write("Command Loaded: " + command);
|
||||
}
|
||||
|
||||
World.Start();
|
||||
|
||||
//Start the Telnet server
|
||||
if (IsMultiplayer)
|
||||
{
|
||||
Log.Write("Starting Server...");
|
||||
this.StartServer();
|
||||
}
|
||||
else //Not multiplayer so we change the save locations
|
||||
{
|
||||
SaveDataPaths paths = new SaveDataPaths("World", "Player", "Scripts");
|
||||
DataPaths = paths;
|
||||
PlayerCollection[0].Initialize();
|
||||
}
|
||||
|
||||
WorldTime.Initialize();
|
||||
|
||||
//Game is running now.
|
||||
IsRunning = true;
|
||||
|
||||
//Load the game and world if it was previously saved.
|
||||
Load();
|
||||
|
||||
String[] env = InitialRealm.InitialZone.InitialRoom.RoomLocation.Split('>');
|
||||
if (env.Length == 3)
|
||||
{
|
||||
if ((String.IsNullOrEmpty(env[0])) || (String.IsNullOrEmpty(env[1])) || (String.IsNullOrEmpty(env[2])))
|
||||
{
|
||||
Log.Write("Error: No starting location defined!");
|
||||
}
|
||||
}
|
||||
else
|
||||
Log.Write("Error: No starting location defined!");
|
||||
|
||||
Log.Write("Game startup complete.");
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shuts down the Game and Server.
|
||||
/// </summary>
|
||||
public virtual void Shutdown()
|
||||
{
|
||||
Log.Write("Server shutdown requested...");
|
||||
|
||||
if (IsMultiplayer)
|
||||
Server.EndServer();
|
||||
|
||||
Save();
|
||||
|
||||
IsRunning = false;
|
||||
|
||||
Log.Write("Shutdown completed...");
|
||||
}
|
||||
|
||||
public virtual void Update()
|
||||
{
|
||||
WorldTime.Update();
|
||||
|
||||
World.Update();
|
||||
|
||||
if (IsMultiplayer)
|
||||
{
|
||||
Console.Write(Log.GetMessages());
|
||||
Log.FlushMessages();
|
||||
System.Threading.Thread.Sleep(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerCollection[0].ExecuteCommand(Console.ReadLine());
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Save()
|
||||
{
|
||||
Log.Write("Saving Game world....");
|
||||
|
||||
Log.Write("Saving Game Players...");
|
||||
for (Int32 i = 0; i <= PlayerCollection.Length - 1; i++)
|
||||
{
|
||||
if (PlayerCollection[i].Name == "New BaseCharacter")
|
||||
continue;
|
||||
PlayerCollection[i].Save();
|
||||
}
|
||||
|
||||
//Delete the last saved version of the World. We will dump the current version onto disk.
|
||||
if (Directory.Exists(DataPaths.Environment))
|
||||
Directory.Delete(DataPaths.Environment, true);
|
||||
|
||||
//Re-create the environment directory
|
||||
Directory.CreateDirectory(DataPaths.Environment);
|
||||
|
||||
//Save the Game World.
|
||||
World.Save();
|
||||
|
||||
//Save the Game
|
||||
String filename = GameTitle + ".ini";
|
||||
|
||||
if (File.Exists(filename))
|
||||
File.Delete(filename);
|
||||
|
||||
FileManager.WriteLine(filename, this.AutoSave.ToString(), "AutoSave");
|
||||
FileManager.WriteLine(filename, this.AutoSaveInterval.ToString(), "AutoSaveInterval");
|
||||
FileManager.WriteLine(filename, this.BaseCurrencyAmount.ToString(), "BaseCurrencyAmount");
|
||||
FileManager.WriteLine(filename, this.BaseCurrencyName, "BaseCurrencyName");
|
||||
FileManager.WriteLine(filename, this.CompanyName, "CompanyName");
|
||||
FileManager.WriteLine(filename, this.DataPaths.Environment, "DataPathEnvironment");
|
||||
FileManager.WriteLine(filename, this.DataPaths.Players, "DataPathPlayers");
|
||||
FileManager.WriteLine(filename, this.DataPaths.Scripts, "DataPathScripts");
|
||||
|
||||
FileManager.WriteLine(filename, this.GameTitle, "GameTitle");
|
||||
FileManager.WriteLine(filename, this.HideRoomNames.ToString(), "HideRoomNames");
|
||||
|
||||
if ((this.InitialRealm != null) && (this.InitialRealm.Name != "New Realm"))
|
||||
FileManager.WriteLine(filename, this.InitialRealm.Filename, "InitialRealm");
|
||||
|
||||
FileManager.WriteLine(filename, this.IsMultiplayer.ToString(), "IsMultiplayer");
|
||||
FileManager.WriteLine(filename, this.MaximumPlayers.ToString(), "MaximumPlayers");
|
||||
FileManager.WriteLine(filename, this.PreCacheObjects.ToString(), "PreCacheObjects");
|
||||
FileManager.WriteLine(filename, this.ServerPort.ToString(), "ServerPort");
|
||||
FileManager.WriteLine(filename, this.ServerType.ToString(), "ServerType");
|
||||
FileManager.WriteLine(filename, this.Version, "Version");
|
||||
FileManager.WriteLine(filename, this.Website, "Website");
|
||||
|
||||
foreach (Realm r in World.RealmCollection)
|
||||
{
|
||||
FileManager.WriteLine(filename, r.Filename, "RealmCollection");
|
||||
}
|
||||
|
||||
//TODO: Save WorldTime
|
||||
//TODO: Save Story
|
||||
//TODO: Save Server Information
|
||||
//TODO: Save Currency Lists
|
||||
//TODO: Save Script Engine information
|
||||
}
|
||||
|
||||
public virtual void Load()
|
||||
{
|
||||
String filename = GameTitle + ".ini";
|
||||
|
||||
this.Load(filename);
|
||||
}
|
||||
|
||||
public virtual void Load(String filename)
|
||||
{
|
||||
if (!File.Exists(filename))
|
||||
return;
|
||||
|
||||
Log.Write("Restoring Game Settings...");
|
||||
try
|
||||
{
|
||||
this.AutoSave = Convert.ToBoolean(FileManager.GetData(filename, "AutoSave"));
|
||||
this.AutoSaveInterval = Convert.ToInt32(FileManager.GetData(filename, "AutoSaveInterval"));
|
||||
this.BaseCurrencyAmount = Convert.ToInt32(FileManager.GetData(filename, "BaseCurrencyAmount"));
|
||||
this.BaseCurrencyName = FileManager.GetData(filename, "BaseCurrencyName");
|
||||
this.CompanyName = FileManager.GetData(filename, "CompanyName");
|
||||
this.DataPaths = new SaveDataPaths(FileManager.GetData(filename, "DataPathEnvironment"), FileManager.GetData(filename, "DataPathPlayers"), FileManager.GetData(filename, "DataPathScripts"));
|
||||
this.GameTitle = FileManager.GetData(filename, "GameTitle");
|
||||
this.HideRoomNames = Convert.ToBoolean(FileManager.GetData(filename, "HideRoomNames"));
|
||||
this.InitialRealm = new Realm(this);
|
||||
this.IsMultiplayer = Convert.ToBoolean(FileManager.GetData(filename, "IsMultiplayer"));
|
||||
this.MaximumPlayers = Convert.ToInt32(FileManager.GetData(filename, "MaximumPlayers"));
|
||||
this.PreCacheObjects = Convert.ToBoolean(FileManager.GetData(filename, "PreCacheObjects"));
|
||||
this.ServerPort = Convert.ToInt32(FileManager.GetData(filename, "ServerPort"));
|
||||
this.Version = FileManager.GetData(filename, "Version");
|
||||
this.Website = FileManager.GetData(filename, "Webite");
|
||||
|
||||
//Need to re-assign the enumerator value that was previously assigned to the ServerType property
|
||||
Array values = Enum.GetValues(typeof(ProtocolType));
|
||||
foreach (Int32 value in values)
|
||||
{
|
||||
//Since enum values are not strings, we can't simply just assign the String to the enum
|
||||
String displayName = Enum.GetName(typeof(ProtocolType), value);
|
||||
|
||||
//If the value = the String saved, then perform the needed conversion to get our data back
|
||||
if (displayName.ToLower() == FileManager.GetData(filename, "ServerType").ToLower())
|
||||
{
|
||||
ServerType = (ProtocolType)Enum.Parse(typeof(ProtocolType), displayName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Log.Write("Critical Error: Unable to complete Game.Load() due to error during loading of file data.");
|
||||
return;
|
||||
}
|
||||
|
||||
//Restore the world.
|
||||
World.Load();
|
||||
|
||||
//Check if any the initial room exists or not.
|
||||
if ((this.InitialRealm == null) || (this.InitialRealm.InitialZone == null) || (this.InitialRealm.InitialZone.InitialRoom == null))
|
||||
{
|
||||
Log.Write("ERROR: No initial location defined. Game startup failed!");
|
||||
Log.Write("Players will start in the Abyss. Each player will contain their own instance of this room.");
|
||||
//return false;
|
||||
}
|
||||
else
|
||||
Log.Write("Initial Location loaded: " + this.InitialRealm.InitialZone.InitialRoom.RoomLocationWithoutExtension);
|
||||
|
||||
Log.Write("Game Restore complete.");
|
||||
}
|
||||
|
||||
public BaseCharacter[] GetPlayerCollection()
|
||||
{
|
||||
return PlayerCollection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts the Server.
|
||||
/// </summary>
|
||||
private void StartServer()
|
||||
{
|
||||
Server = new Networking.Server();
|
||||
Server.Initialize(ServerPort, ref PlayerCollection);
|
||||
Server.Start();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -1,380 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MudEngine.GameManagement
|
||||
{
|
||||
public class GameTime
|
||||
{
|
||||
public struct Time
|
||||
{
|
||||
public Int32 Year { get; set; }
|
||||
public Int32 Month { get; set; }
|
||||
public Int32 Day { get; set; }
|
||||
public Int32 Hour { get; set; }
|
||||
public Int32 Minute { get; set; }
|
||||
public Int32 Second { get; set; }
|
||||
private GameTime gameTime;
|
||||
}
|
||||
|
||||
public enum TimeOfDayOptions
|
||||
{
|
||||
AlwaysDay,
|
||||
AlwaysNight,
|
||||
Transition,
|
||||
}
|
||||
|
||||
internal Game ActiveGame { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time of day that the server actually started up.
|
||||
/// </summary>
|
||||
internal DateTime ServerStartTime { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current World Time.
|
||||
/// </summary>
|
||||
public Time CurrentWorldTime { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets the current Time of the System
|
||||
/// </summary>
|
||||
private DateTime CurrentSystemTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets how many Hours it takes to make a full day in the World
|
||||
/// </summary>
|
||||
public Int32 HoursPerDay { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets how many minutes it takes to make a full Hour
|
||||
/// </summary>
|
||||
public Int32 MinutesPerHour { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets how many seconds it takes to make a full minute
|
||||
/// </summary>
|
||||
public Int32 SecondsPerMinute { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets how many Days it takes to make a full month in the world
|
||||
/// </summary>
|
||||
public Int32 DaysPerMonth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets how many Months it takes to make a full Year in the world
|
||||
/// </summary>
|
||||
public Int32 MonthsPerYear { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets the name of each Day in a Week.
|
||||
/// </summary>
|
||||
public List<String> DayNames { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets the name of each Month in a Year.
|
||||
/// </summary>
|
||||
public List<String> MonthNames { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets what time of day the world is currently in.
|
||||
/// </summary>
|
||||
public TimeOfDayOptions DayTransitions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets what time of day that it begins to transition to night.
|
||||
/// </summary>
|
||||
public Int32 DawnTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// /Gets or Sets what time of day that it begins to transition into day time.
|
||||
/// </summary>
|
||||
public Int32 SunriseTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets the initial Time that the world starts in.
|
||||
/// </summary>
|
||||
public Time InitialGameTime { get; set; }
|
||||
|
||||
private Int32 _LastSavedTime = 0;
|
||||
|
||||
public GameTime(Game game)
|
||||
{
|
||||
ActiveGame = game;
|
||||
|
||||
ServerStartTime = DateTime.Now;
|
||||
|
||||
DayNames = new List<String>();
|
||||
MonthNames = new List<String>();
|
||||
|
||||
DayNames.Add("Monday");
|
||||
DayNames.Add("Tuesday");
|
||||
DayNames.Add("Wednesday");
|
||||
DayNames.Add("Thursday");
|
||||
DayNames.Add("Friday");
|
||||
DayNames.Add("Saturday");
|
||||
DayNames.Add("Sunday");
|
||||
|
||||
MonthNames.Add("January");
|
||||
MonthNames.Add("February");
|
||||
MonthNames.Add("March");
|
||||
MonthNames.Add("April");
|
||||
MonthNames.Add("May");
|
||||
MonthNames.Add("June");
|
||||
MonthNames.Add("July");
|
||||
MonthNames.Add("August");
|
||||
MonthNames.Add("September");
|
||||
MonthNames.Add("October");
|
||||
MonthNames.Add("November");
|
||||
MonthNames.Add("December");
|
||||
|
||||
Time t = new Time();
|
||||
t.Second = 0;
|
||||
t.Minute = 0;
|
||||
t.Hour = 1;
|
||||
t.Day = 1;
|
||||
t.Month = 1;
|
||||
t.Year = 2010;
|
||||
|
||||
InitialGameTime = t;
|
||||
|
||||
DawnTime = 19;
|
||||
SunriseTime = 6;
|
||||
|
||||
DayTransitions = TimeOfDayOptions.Transition;
|
||||
|
||||
SecondsPerMinute = 1;
|
||||
MinutesPerHour = 1;
|
||||
HoursPerDay = 1;
|
||||
DaysPerMonth = 3;
|
||||
MonthsPerYear = 3;
|
||||
|
||||
CurrentWorldTime = InitialGameTime;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
Time t = InitialGameTime;
|
||||
CurrentWorldTime = t;
|
||||
CurrentSystemTime = DateTime.Now;
|
||||
}
|
||||
|
||||
public virtual void Update()
|
||||
{
|
||||
TimeSpan ts = CurrentSystemTime - DateTime.Now;
|
||||
|
||||
//If the seconds that has passed inbetween the last Update call is greater than 0
|
||||
//Then we need to increment a Second, which will start a domino effect if it needs to
|
||||
//in order to increment minute/hours/days/months and years.
|
||||
if (ts.Seconds <= -1)
|
||||
{
|
||||
CurrentSystemTime = DateTime.Now;
|
||||
Int32 amount = Math.Abs(ts.Seconds);
|
||||
IncrementSecond(amount);
|
||||
//Log.Write(GetCurrentWorldTime());
|
||||
}
|
||||
|
||||
DateTime systemTime = DateTime.Now;
|
||||
|
||||
if (_LastSavedTime == ActiveGame.AutoSaveInterval)
|
||||
{
|
||||
if (ActiveGame.AutoSave)
|
||||
ActiveGame.Save();
|
||||
_LastSavedTime = 0;
|
||||
}
|
||||
|
||||
//ServerTime holds the last minute prior to our current minute.
|
||||
if (CurrentSystemTime.Minute != DateTime.Now.Minute)
|
||||
{
|
||||
_LastSavedTime++;
|
||||
}
|
||||
|
||||
CurrentSystemTime = DateTime.Now;
|
||||
}
|
||||
|
||||
public void IncrementSecond(Int32 amount)
|
||||
{
|
||||
Time t = new Time();
|
||||
t = CurrentWorldTime;
|
||||
|
||||
if (CurrentWorldTime.Second == SecondsPerMinute)
|
||||
{
|
||||
IncrementMinute(1);
|
||||
t = CurrentWorldTime;
|
||||
t.Second = 0;
|
||||
}
|
||||
else if (CurrentWorldTime.Second > SecondsPerMinute)
|
||||
{
|
||||
Int32 minutes = CurrentWorldTime.Second / SecondsPerMinute;
|
||||
Int32 seconds = CurrentWorldTime.Second - SecondsPerMinute;
|
||||
IncrementMinute(minutes);
|
||||
t = CurrentWorldTime; //Get the updated world time.
|
||||
t.Second = seconds; //Edit it.
|
||||
}
|
||||
else
|
||||
t.Second += amount;
|
||||
|
||||
CurrentWorldTime = t;
|
||||
}
|
||||
|
||||
public void IncrementMinute(Int32 amount)
|
||||
{
|
||||
Time t = new Time();
|
||||
t = CurrentWorldTime;
|
||||
|
||||
if (CurrentWorldTime.Minute == MinutesPerHour)
|
||||
{
|
||||
IncrementHour(1);
|
||||
t = CurrentWorldTime;
|
||||
t.Minute = 0;
|
||||
|
||||
}
|
||||
else if (CurrentWorldTime.Minute > MinutesPerHour)
|
||||
{
|
||||
Int32 hours = CurrentWorldTime.Minute / MinutesPerHour;
|
||||
Int32 Minutes = CurrentWorldTime.Minute - MinutesPerHour;
|
||||
IncrementHour(hours);
|
||||
t = CurrentWorldTime;
|
||||
t.Minute = Minutes;
|
||||
}
|
||||
else
|
||||
t.Minute += amount;
|
||||
|
||||
CurrentWorldTime = t;
|
||||
}
|
||||
|
||||
public void IncrementHour(Int32 amount)
|
||||
{
|
||||
Time t = new Time();
|
||||
t = CurrentWorldTime;
|
||||
|
||||
if (CurrentWorldTime.Hour == HoursPerDay)
|
||||
{
|
||||
IncrementDay();
|
||||
t = CurrentWorldTime;
|
||||
t.Hour = 0;
|
||||
}
|
||||
else if (CurrentWorldTime.Hour > HoursPerDay)
|
||||
{
|
||||
Int32 days = CurrentWorldTime.Hour / HoursPerDay;
|
||||
Int32 hours = CurrentWorldTime.Hour - HoursPerDay;
|
||||
IncrementDay();
|
||||
t = CurrentWorldTime;
|
||||
t.Hour = hours;
|
||||
}
|
||||
else
|
||||
t.Hour++;
|
||||
|
||||
CurrentWorldTime = t;
|
||||
}
|
||||
|
||||
public void IncrementDay()
|
||||
{
|
||||
Time t = new Time();
|
||||
t = CurrentWorldTime;
|
||||
|
||||
//TODO: Finish GameTime syncing with Server Time.
|
||||
if (CurrentWorldTime.Day == DaysPerMonth)
|
||||
{
|
||||
IncrementMonth();
|
||||
t = CurrentWorldTime;
|
||||
t.Day = 1;
|
||||
}
|
||||
else
|
||||
t.Day++;
|
||||
|
||||
CurrentWorldTime = t;
|
||||
}
|
||||
|
||||
public void IncrementMonth()
|
||||
{
|
||||
Time t = new Time();
|
||||
t = CurrentWorldTime;
|
||||
|
||||
if (CurrentWorldTime.Month == MonthsPerYear)
|
||||
{
|
||||
IncrementYear();
|
||||
t = CurrentWorldTime;
|
||||
t.Month = 1;
|
||||
}
|
||||
else
|
||||
t.Month++;
|
||||
|
||||
CurrentWorldTime = t;
|
||||
}
|
||||
|
||||
public void IncrementYear()
|
||||
{
|
||||
Time t = new Time();
|
||||
t = CurrentWorldTime;
|
||||
|
||||
t.Year++;
|
||||
|
||||
CurrentWorldTime = t;
|
||||
}
|
||||
|
||||
public String GetCurrentWorldTime()
|
||||
{
|
||||
if (DayNames.Count < CurrentWorldTime.Day)
|
||||
{
|
||||
return "Not enough Day Names specified to match up with DaysPerMonth property.";
|
||||
}
|
||||
else if (MonthNames.Count < CurrentWorldTime.Month)
|
||||
{
|
||||
return "Not enough Month names specified to match up with MonthsPerYear property.";
|
||||
}
|
||||
|
||||
String day = DayNames[CurrentWorldTime.Day - 1];
|
||||
String month = MonthNames[CurrentWorldTime.Month - 1];
|
||||
|
||||
return day + ", " + month + " " + CurrentWorldTime.Day + ", " + CurrentWorldTime.Year + ": " + CurrentWorldTime.Hour + ":" + CurrentWorldTime.Minute + ":" + CurrentWorldTime.Second;
|
||||
}
|
||||
|
||||
public Int32 GetCurrentSecond()
|
||||
{
|
||||
return CurrentWorldTime.Second;
|
||||
}
|
||||
|
||||
public Int32 GetCurrentMinute()
|
||||
{
|
||||
return CurrentWorldTime.Minute;
|
||||
}
|
||||
|
||||
public Int32 GetCurrentHour()
|
||||
{
|
||||
return CurrentWorldTime.Hour;
|
||||
}
|
||||
|
||||
public Int32 GetCurrentDayNumber()
|
||||
{
|
||||
return CurrentWorldTime.Day;
|
||||
}
|
||||
|
||||
public String GetCurrentDayName()
|
||||
{
|
||||
if (DayNames.Count > CurrentWorldTime.Day)
|
||||
return "No Day Name available for the current Date.";
|
||||
else
|
||||
return DayNames[CurrentWorldTime.Day - 1];//Days start at 1, array index starts at 0
|
||||
}
|
||||
|
||||
public Int32 GetCurrentMonthNumber()
|
||||
{
|
||||
return CurrentWorldTime.Month;
|
||||
}
|
||||
|
||||
public String GetCurrentMonthName()
|
||||
{
|
||||
if (MonthNames.Count > CurrentWorldTime.Month)
|
||||
return "No Month Name available for the current Date.";
|
||||
else
|
||||
return MonthNames[CurrentWorldTime.Month - 1]; //Day starts at 1, array index starts at 0.
|
||||
}
|
||||
|
||||
public Int32 GetCurrentYear()
|
||||
{
|
||||
return CurrentWorldTime.Year;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ using System.Linq;
|
|||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
//MudEngine
|
||||
/*
|
||||
using MudEngine.FileSystem;
|
||||
using MudEngine.GameManagement;
|
||||
using MudEngine.GameObjects;
|
||||
|
@ -200,3 +200,4 @@ namespace MudEngine.GameManagement
|
|||
}
|
||||
}
|
||||
}
|
||||
*/
|
|
@ -1,28 +0,0 @@
|
|||
//Microsoft .NET Framework
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
//MUD Engine
|
||||
using MudEngine.Commands;
|
||||
using MudEngine.GameObjects.Characters;
|
||||
using MudEngine.GameManagement;
|
||||
using MudEngine.GameObjects.Environment;
|
||||
|
||||
namespace MudEngine.GameManagement
|
||||
{
|
||||
public interface IGameCommand
|
||||
{
|
||||
//Name of the command
|
||||
String Name { get; set; }
|
||||
//Used to override commands with the same name
|
||||
Boolean Override { get; set; }
|
||||
|
||||
//Used when the player enters the help command
|
||||
List<String> Help { get; set; }
|
||||
|
||||
//Executes the command.
|
||||
void Execute(String command, BaseCharacter player);
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
/*
|
||||
using MudEngine.FileSystem;
|
||||
|
||||
namespace MudEngine.GameManagement
|
||||
|
@ -67,3 +68,4 @@ namespace MudEngine.GameManagement
|
|||
}
|
||||
}
|
||||
}
|
||||
*/
|
|
@ -1,14 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace MudEngine.GameManagement
|
||||
{
|
||||
public enum SecurityRoles
|
||||
{
|
||||
Admin,
|
||||
Immortal,
|
||||
GM,
|
||||
QuestGiver,
|
||||
Player,
|
||||
NPC
|
||||
}
|
||||
}
|
116
MudEngine/Communication/OldServer.cs
Normal file
116
MudEngine/Communication/OldServer.cs
Normal file
|
@ -0,0 +1,116 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using System.Text;
|
||||
|
||||
using MudEngine.Core;
|
||||
|
||||
namespace MudEngine.Communication
|
||||
{
|
||||
public class OldServer
|
||||
{
|
||||
/*
|
||||
public OldServer()
|
||||
{
|
||||
stage = 0;
|
||||
port = 0;
|
||||
server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
}
|
||||
~OldServer()
|
||||
{
|
||||
stage = 0;
|
||||
port = 0;
|
||||
}
|
||||
public Boolean Initialize(Int32 p, ref BaseCharacter[] pbs)
|
||||
{
|
||||
if (stage != 0)
|
||||
return false;
|
||||
if (p <= 0)
|
||||
return false;
|
||||
port = p;
|
||||
players = pbs;
|
||||
clientThreads = new Thread[players.Length];
|
||||
stage++;
|
||||
return true;
|
||||
}
|
||||
public Boolean Start()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (stage != 1)
|
||||
return false;
|
||||
IPEndPoint ipep = new IPEndPoint(IPAddress.Any, port);
|
||||
server.Bind(ipep);
|
||||
server.Listen(10);
|
||||
stage++;
|
||||
serverThread = new Thread(ServerThread);
|
||||
serverThread.Start();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public void EndServer()
|
||||
{
|
||||
stage = 0;
|
||||
serverThread.Abort();
|
||||
server.Close();
|
||||
}
|
||||
private void ServerThread()
|
||||
{
|
||||
while (stage == 2)
|
||||
{
|
||||
Int32 sub = -1;
|
||||
do
|
||||
{
|
||||
for (Int32 i = 0; i < players.Length; i++)
|
||||
{
|
||||
if (!players[i].IsActive)
|
||||
{
|
||||
sub = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (sub < 0);
|
||||
players[sub].client = server.Accept();
|
||||
players[sub].IsActive = true;
|
||||
players[sub].IsControlled = true;
|
||||
clientThreads[sub] = new Thread(ReceiveThread);
|
||||
clientThreads[sub].Start((object)sub);
|
||||
}
|
||||
}
|
||||
private void ReceiveThread(object obj)
|
||||
{
|
||||
Int32 sub = (Int32)obj;
|
||||
players[sub].Initialize();
|
||||
while (stage == 2 && players[sub].IsActive)
|
||||
{
|
||||
players[sub].Receive(players[sub].ReadInput());
|
||||
}
|
||||
}
|
||||
public void Disconnect(Int32 sub)
|
||||
{
|
||||
if (sub > 0 && sub < players.Length)
|
||||
{
|
||||
clientThreads[sub].Abort();
|
||||
if (players[sub].IsActive)
|
||||
players[sub].Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
private Thread serverThread;
|
||||
private Socket server;
|
||||
private Int32 stage;
|
||||
private Int32 port;
|
||||
|
||||
BaseCharacter[] players;
|
||||
|
||||
private Thread[] clientThreads;
|
||||
*/
|
||||
}
|
||||
}
|
86
MudEngine/Communication/Server.cs
Normal file
86
MudEngine/Communication/Server.cs
Normal file
|
@ -0,0 +1,86 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using System.Text;
|
||||
|
||||
using MudEngine.Core;
|
||||
|
||||
namespace MudEngine.Communication
|
||||
{
|
||||
public class Server : BaseServer
|
||||
{
|
||||
//Listens for incoming connections
|
||||
private TcpListener _Listener;
|
||||
|
||||
//Dedicated thread for accepting and processing new connections
|
||||
private Thread _Connect;
|
||||
|
||||
private Dictionary<BaseCharacter, Thread> _ClientCollection;
|
||||
|
||||
/// <summary>
|
||||
/// Server constructor. Requires a currently active game to start.
|
||||
/// </summary>
|
||||
/// <param name="game"></param>
|
||||
public Server(BaseGame game) : base(game)
|
||||
{
|
||||
this._Listener = new TcpListener(IPAddress.Any, 555);
|
||||
this._Connect = new Thread(new ThreadStart(ListenForConnections));
|
||||
this._ClientCollection = new Dictionary<BaseCharacter, Thread>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Server constructor. Requires a currently active game and desired port number to start.
|
||||
/// </summary>
|
||||
/// <param name="game"></param>
|
||||
/// <param name="port"></param>
|
||||
public Server(BaseGame game, int port)
|
||||
: base(game)
|
||||
{
|
||||
this._Listener = new TcpListener(IPAddress.Any, port);
|
||||
this._Connect = new Thread(new ThreadStart(ListenForConnections));
|
||||
this._ClientCollection = new Dictionary<BaseCharacter, Thread>();
|
||||
}
|
||||
|
||||
//Listens for incoming client connections.
|
||||
private void ListenForConnections()
|
||||
{
|
||||
this._Listener.Start();
|
||||
|
||||
while (true)
|
||||
{
|
||||
TcpClient client = this._Listener.AcceptTcpClient();
|
||||
|
||||
//Someone connects, send them to a new thread.
|
||||
Thread newClient = new Thread(new ParameterizedThreadStart(OnConnect));
|
||||
newClient.Start(client);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
this._Connect.Start();
|
||||
}
|
||||
|
||||
public override void OnConnect(object client)
|
||||
{
|
||||
this.ActiveGame.OnConnect((TcpClient)client);
|
||||
}
|
||||
|
||||
public override void OnDisconnect(object client)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void RecieveData(string data)
|
||||
{
|
||||
//TODO: command needs to be executed.
|
||||
}
|
||||
|
||||
public override void SendData(string data)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
141
MudEngine/Core/BaseCharacter.cs
Normal file
141
MudEngine/Core/BaseCharacter.cs
Normal file
|
@ -0,0 +1,141 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
|
||||
namespace MudEngine.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Collection of Roles that can be assigned to a character, either controlled or non-controlled.
|
||||
/// </summary>
|
||||
public enum CharacterRoles
|
||||
{
|
||||
Admin,
|
||||
Immortal,
|
||||
GM,
|
||||
QuestGiver,
|
||||
Player,
|
||||
NPC
|
||||
}
|
||||
|
||||
public struct CharacterStats
|
||||
{
|
||||
public int Strength { get; set; }
|
||||
public int Dexterity { get; set; }
|
||||
public int Constitution { get; set; }
|
||||
public int Intelligence { get; set; }
|
||||
public int Wisdom { get; set; }
|
||||
public int Charisma { get; set; }
|
||||
public int Experience { get; set; }
|
||||
}
|
||||
|
||||
public abstract class BaseCharacter : BaseObject, ICharacter
|
||||
{
|
||||
private TcpClient _ConnectedClient;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the currently active game.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public BaseGame ActiveGame { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets the Role that this character has in the game.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public CharacterRoles Role { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current stats for this character.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public CharacterStats Stats { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets the password used to log into this character
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public string Password { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets if this character can move about the world or not.
|
||||
/// </summary>
|
||||
public bool IsStatic { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets if this character is controlled by Human or AI
|
||||
/// </summary>
|
||||
public bool IsAI { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current location of this character within the world.
|
||||
/// </summary>
|
||||
public IEnvironment CurrentLocation { get; private set; }
|
||||
|
||||
public BaseCharacter(BaseGame game)
|
||||
{
|
||||
this.ActiveGame = game;
|
||||
this.ID = this.ActiveGame.GetAvailableID();
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void OnConnect(TcpClient client)
|
||||
{
|
||||
this._ConnectedClient = client;
|
||||
|
||||
NetworkStream clientStream = this._ConnectedClient.GetStream();
|
||||
|
||||
//Stores messages recieved from the client
|
||||
byte[] message = new byte[4096];
|
||||
int bytesRead;
|
||||
|
||||
while (true)
|
||||
{
|
||||
bytesRead = 0;
|
||||
|
||||
try
|
||||
{
|
||||
bytesRead = clientStream.Read(message, 0, 4096);
|
||||
}
|
||||
catch
|
||||
{
|
||||
break; //error occured. Re-try
|
||||
}
|
||||
|
||||
if (bytesRead == 0)
|
||||
{
|
||||
break; //Disconnected.
|
||||
}
|
||||
|
||||
ASCIIEncoding encoder = new ASCIIEncoding();
|
||||
string data = encoder.GetString(message, 0, bytesRead);
|
||||
//RecieveData(data);
|
||||
}
|
||||
|
||||
//TODO: Call ActiveGame.OnDisconnect();
|
||||
//newClient.Close(); //Disconnect the client.
|
||||
}
|
||||
|
||||
public void OnTravel(World.AvailableTravelDirections travelDirection)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void OnTalk(string message, ICharacter instigator)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
53
MudEngine/Core/BaseCommand.cs
Normal file
53
MudEngine/Core/BaseCommand.cs
Normal file
|
@ -0,0 +1,53 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MudEngine.Core
|
||||
{
|
||||
public abstract class BaseCommand : ICommand
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or Sets a collection of help topics related to this command.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public List<string> Help { get; set; }
|
||||
|
||||
public BaseCommand()
|
||||
{
|
||||
Help = new List<string>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the command for the character supplied.
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <param name="character"></param>
|
||||
public abstract void Execute(string command, ICharacter character);
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public string Description
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
172
MudEngine/Core/BaseEnvironment.cs
Normal file
172
MudEngine/Core/BaseEnvironment.cs
Normal file
|
@ -0,0 +1,172 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MudEngine.Core
|
||||
{
|
||||
public abstract class BaseEnvironment : BaseObject, IEnvironment
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or Sets if this environment will be safe from harmful objects
|
||||
/// </summary>
|
||||
[Category("Environment Settings")]
|
||||
[Description("Sets if the environment will be safe from harmful objects.")]
|
||||
public bool IsSafe {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection of all occupants, either players or NPC, within this environment.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public List<string> CurrentOccupants {get; private set;}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets the way that the environment smells.
|
||||
/// </summary>
|
||||
[Category("Environment Settings")]
|
||||
[Description("Sets how the environment will smell.")]
|
||||
public string Smell {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets how the environment feels.
|
||||
/// </summary>
|
||||
[Category("Environment Settings")]
|
||||
[Description("Sets how the environment feels.")]
|
||||
public string Feel {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets the sounds that can be heard within this environment.
|
||||
/// </summary>
|
||||
[Category("Environment Settings")]
|
||||
[Description("Sets the sounds that can be heard within this environment")]
|
||||
public string Listen { get; set; }
|
||||
|
||||
protected BaseGame ActiveGame { get; private set; }
|
||||
|
||||
public BaseEnvironment(BaseGame game)
|
||||
{
|
||||
this.ActiveGame = game;
|
||||
this.ID = this.ActiveGame.GetAvailableID();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs any actions needed when a character occupies the environment.
|
||||
/// </summary>
|
||||
/// <param name="character"></param>
|
||||
public virtual void OnOccupantEnter(ICharacter character)
|
||||
{
|
||||
if (!CurrentOccupants.Contains(character.Name))
|
||||
CurrentOccupants.Add(character.Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs needed actions when a character leaves the occupied environment.
|
||||
/// </summary>
|
||||
/// <param name="character"></param>
|
||||
public virtual void OnOccupantExit(ICharacter character)
|
||||
{
|
||||
if (!CurrentOccupants.Contains(character.Name))
|
||||
CurrentOccupants.Remove(character.Name);
|
||||
}
|
||||
|
||||
bool IEnvironment.IsSafe
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
List<string> IEnvironment.CurrentOccupants
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
string IEnvironment.Smell
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
string IEnvironment.Feel
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
string IEnvironment.Listen
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
void IEnvironment.OnOccupantEnter(ICharacter character)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
void IEnvironment.OnOccupantExit(ICharacter character)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
string IObject.Name
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
string IObject.Filename
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
string IObject.Description
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
57
MudEngine/Core/BaseGame.cs
Normal file
57
MudEngine/Core/BaseGame.cs
Normal file
|
@ -0,0 +1,57 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
|
||||
namespace MudEngine.Core
|
||||
{
|
||||
public abstract class BaseGame : BaseObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Enables or Disables the server.
|
||||
/// </summary>
|
||||
[Category("Game Settings")]
|
||||
[Description("Enables or Disabels the server.")]
|
||||
public bool EnableServer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Enables or Disables the Auto Save feature.
|
||||
/// </summary>
|
||||
[Category("Game Settings")]
|
||||
[Description("Enables or Disables the Auto Save feature.")]
|
||||
public bool EnableAutoSave { get; set; }
|
||||
|
||||
public int AutoSaveInterval { get; set; }
|
||||
|
||||
public int PasswordMinimumSize { get; set; }
|
||||
|
||||
public int MaximumPlayers { get; set; }
|
||||
|
||||
public Dictionary<TcpClient, ICharacter> ConnectedPlayers { get; private set; }
|
||||
|
||||
public string Version { get; set; }
|
||||
|
||||
public IEnvironment InitialEnvironment { get; set; }
|
||||
|
||||
public BaseGame()
|
||||
{
|
||||
this.ConnectedPlayers = new Dictionary<TcpClient, ICharacter>();
|
||||
this.ID = 0;
|
||||
}
|
||||
|
||||
public abstract void Initialize();
|
||||
|
||||
public abstract void Update();
|
||||
|
||||
public abstract void Shutdown();
|
||||
|
||||
public abstract void OnConnect(TcpClient client);
|
||||
|
||||
public abstract void OnDisconnect(TcpClient client);
|
||||
|
||||
public abstract int GetAvailableID();
|
||||
}
|
||||
}
|
83
MudEngine/Core/BaseItem.cs
Normal file
83
MudEngine/Core/BaseItem.cs
Normal file
|
@ -0,0 +1,83 @@
|
|||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MudEngine.Core
|
||||
{
|
||||
public abstract class BaseItem : BaseObject, IGameComponent
|
||||
{
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets a reference to the currently active game.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public BaseGame ActiveGame { get; private set; }
|
||||
#endregion
|
||||
|
||||
public BaseItem(BaseGame game)
|
||||
{
|
||||
this.ActiveGame = game;
|
||||
this.ID = this.ActiveGame.GetAvailableID();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the item
|
||||
/// </summary>
|
||||
public abstract void Initialize();
|
||||
|
||||
public abstract void Update();
|
||||
|
||||
BaseGame IGameComponent.ActiveGame
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
void IGameComponent.Initialize()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
void IGameComponent.Update()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
string IObject.Name
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
string IObject.Filename
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
string IObject.Description
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
118
MudEngine/Core/BaseObject.cs
Normal file
118
MudEngine/Core/BaseObject.cs
Normal file
|
@ -0,0 +1,118 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MudEngine.Core
|
||||
{
|
||||
public abstract class BaseObject : IObject
|
||||
{
|
||||
#region Fields
|
||||
//Name of this object
|
||||
string _Name;
|
||||
|
||||
//Object filename
|
||||
string _Filename;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets or Sets the Name for this object. The objects Filename property is automatically set to match the Name.
|
||||
/// </summary>
|
||||
[Category("Object Information")]
|
||||
[Description("Provides a name for this object")]
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Name;
|
||||
}
|
||||
set
|
||||
{
|
||||
_Name = value;
|
||||
if (this.GetType().Name.StartsWith("Base"))
|
||||
Filename = value + "." + this.GetType().Name.Substring("Base".Length);
|
||||
else
|
||||
Filename = value + "." + this.GetType().Name;
|
||||
}
|
||||
}
|
||||
|
||||
public int ID { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets the Filename used to save/load this object. The Filename is automatically set/changed when the Name property changes
|
||||
/// </summary>
|
||||
[Category("Object Information")]
|
||||
[Description("Sets the Filename used to Save/Load this object. The Filename is automatically set/changed when the Name property is changed.")]
|
||||
public string Filename
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Filename;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this.GetType().Name.StartsWith("Base"))
|
||||
{
|
||||
if (value.EndsWith("." + this.GetType().Name.Substring("Base".Length)))
|
||||
{
|
||||
_Filename = value;
|
||||
}
|
||||
else
|
||||
_Filename = value + "." + this.GetType().Name.Substring("Base".Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (value.EndsWith("." + this.GetType().Name))
|
||||
{
|
||||
_Filename = value;
|
||||
}
|
||||
else
|
||||
_Filename = value + "." + this.GetType().Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets a description of what this object is in the game world.
|
||||
/// </summary>
|
||||
[Category("Object Information")]
|
||||
[Description("Sets the description used to explain what this object is within the game world.")]
|
||||
public string Description { get; set; }
|
||||
#endregion
|
||||
|
||||
public BaseObject()
|
||||
{
|
||||
this.Name = DefaultName();
|
||||
}
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Returns the default name generated for this object by the engine.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected virtual string DefaultName()
|
||||
{
|
||||
return "New " + this.GetType().Name;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this.Name;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
public virtual void Load(string objectName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public virtual void Save()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
41
MudEngine/Core/BaseServer.cs
Normal file
41
MudEngine/Core/BaseServer.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace MudEngine.Core
|
||||
{
|
||||
public abstract class BaseServer : BaseObject, ICommunicate
|
||||
{
|
||||
public int Port { get; set; }
|
||||
|
||||
public ICommand LoginCommand { get; set; }
|
||||
|
||||
public BaseGame ActiveGame { get; private set; }
|
||||
|
||||
public BaseServer(BaseGame game)
|
||||
{
|
||||
this.ActiveGame = game;
|
||||
}
|
||||
|
||||
public virtual void Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void Update()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public abstract void OnConnect(object client);
|
||||
|
||||
public abstract void OnDisconnect(object client);
|
||||
|
||||
public abstract void RecieveData(string data);
|
||||
|
||||
public abstract void SendData(string data);
|
||||
}
|
||||
}
|
24
MudEngine/Core/ICharacter.cs
Normal file
24
MudEngine/Core/ICharacter.cs
Normal file
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
|
||||
using MudEngine.World;
|
||||
|
||||
namespace MudEngine.Core
|
||||
{
|
||||
public interface ICharacter : IGameComponent
|
||||
{
|
||||
CharacterRoles Role { get; set; }
|
||||
string Password { get; set; }
|
||||
bool IsStatic { get; set; }
|
||||
bool IsAI { get; }
|
||||
IEnvironment CurrentLocation { get; }
|
||||
|
||||
void OnTravel(AvailableTravelDirections travelDirection);
|
||||
void OnTalk(string message, ICharacter instigator);
|
||||
void OnConnect(TcpClient client);
|
||||
}
|
||||
}
|
16
MudEngine/Core/ICommand.cs
Normal file
16
MudEngine/Core/ICommand.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MudEngine.Core
|
||||
{
|
||||
public interface ICommand
|
||||
{
|
||||
string Name { get; set; }
|
||||
string Description { get; set; }
|
||||
List<string> Help { get; set; }
|
||||
|
||||
void Execute(string command, ICharacter character);
|
||||
}
|
||||
}
|
20
MudEngine/Core/ICommunicate.cs
Normal file
20
MudEngine/Core/ICommunicate.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
|
||||
namespace MudEngine.Core
|
||||
{
|
||||
public interface ICommunicate : IGameComponent
|
||||
{
|
||||
int Port { get; set; }
|
||||
ICommand LoginCommand { get; set; }
|
||||
|
||||
void OnConnect(object client);
|
||||
void OnDisconnect(object client);
|
||||
void RecieveData(string data);
|
||||
void SendData(string data);
|
||||
}
|
||||
}
|
40
MudEngine/Core/ICompiler.cs
Normal file
40
MudEngine/Core/ICompiler.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MudEngine.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to implement a wrapper for an existing compiler.
|
||||
/// </summary>
|
||||
public interface ICompiler
|
||||
{
|
||||
CompilerResults Results { get; set; }
|
||||
/// <summary>
|
||||
/// The file extension used for the script files.
|
||||
/// </summary>
|
||||
String ScriptExtension { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Provides a collection of Assemblies that the compiler will add to its reference list.
|
||||
/// </summary>
|
||||
List<String> AssemblyReferences { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Provides compiling options to various compilers, if they support this feature.
|
||||
/// </summary>
|
||||
Dictionary<String, String> CompilerOptions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Compiles the source files found within the scriptRepository directory matching the ICompiler.ScriptExtension
|
||||
/// The Compiler defaults to the C# 4.0 compiler if none other is supplied via the ICompiler.CompilerOptions argument.
|
||||
/// </summary>
|
||||
/// <param name="param">Compiler Parameters that can be supplied to customize the compilation of the source.</param>
|
||||
/// <returns>Returns true if the compilation was completed without error.</returns>
|
||||
Boolean Compile(CompilerParameters param, String scriptRepository);
|
||||
|
||||
Boolean Compile(CompilerParameters param, System.IO.FileInfo scriptFile);
|
||||
|
||||
Boolean Compile(CompilerParameters param, String[] scriptSource);
|
||||
}
|
||||
}
|
21
MudEngine/Core/IEnvironment.cs
Normal file
21
MudEngine/Core/IEnvironment.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MudEngine.Core
|
||||
{
|
||||
public interface IEnvironment : IObject
|
||||
{
|
||||
bool IsSafe { get; set; }
|
||||
List<string> CurrentOccupants { get; }
|
||||
|
||||
string Smell { get; set; }
|
||||
string Feel { get; set; }
|
||||
string Listen { get; set; }
|
||||
|
||||
void OnOccupantEnter(ICharacter character);
|
||||
|
||||
void OnOccupantExit(ICharacter character);
|
||||
}
|
||||
}
|
16
MudEngine/Core/IGameComponent.cs
Normal file
16
MudEngine/Core/IGameComponent.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MudEngine.Core
|
||||
{
|
||||
public interface IGameComponent : IObject
|
||||
{
|
||||
BaseGame ActiveGame { get; }
|
||||
|
||||
void Initialize();
|
||||
|
||||
void Update();
|
||||
}
|
||||
}
|
16
MudEngine/Core/IObject.cs
Normal file
16
MudEngine/Core/IObject.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MudEngine.Core
|
||||
{
|
||||
public interface IObject
|
||||
{
|
||||
string Name { get; set; }
|
||||
|
||||
string Filename { get; set; }
|
||||
|
||||
string Description { get; set; }
|
||||
}
|
||||
}
|
|
@ -54,20 +54,35 @@
|
|||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ClassesPendingMigration\GameTime.cs" />
|
||||
<Compile Include="ClassesPendingMigration\GameWorld.cs" />
|
||||
<Compile Include="ClassesPendingMigration\Game.cs" />
|
||||
<Compile Include="ClassesPendingMigration\ICommand.cs" />
|
||||
<Compile Include="ClassesPendingMigration\Log.cs" />
|
||||
<Compile Include="ClassesPendingMigration\SecurityRoles.cs" />
|
||||
<Compile Include="ClassesPendingMigration\BaseStats.cs" />
|
||||
<Compile Include="Communication\OldServer.cs" />
|
||||
<Compile Include="Communication\Server.cs" />
|
||||
<Compile Include="Core\BaseCharacter.cs" />
|
||||
<Compile Include="Core\BaseCommand.cs" />
|
||||
<Compile Include="Core\BaseEnvironment.cs" />
|
||||
<Compile Include="Core\BaseGame.cs" />
|
||||
<Compile Include="Core\BaseItem.cs" />
|
||||
<Compile Include="Core\BaseObject.cs" />
|
||||
<Compile Include="Core\BaseServer.cs" />
|
||||
<Compile Include="Core\ICharacter.cs" />
|
||||
<Compile Include="Core\ICommand.cs" />
|
||||
<Compile Include="Core\ICommunicate.cs" />
|
||||
<Compile Include="Core\ICompiler.cs" />
|
||||
<Compile Include="Core\IEnvironment.cs" />
|
||||
<Compile Include="Core\IGameComponent.cs" />
|
||||
<Compile Include="Core\IObject.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\rScripting\rScripting.csproj">
|
||||
<Project>{BC1B32DA-7209-4B32-8171-A190EF21F5D6}</Project>
|
||||
<Name>rScripting</Name>
|
||||
</ProjectReference>
|
||||
<Compile Include="Runtime\CommandSystem.cs" />
|
||||
<Compile Include="Runtime\MudCompiler.cs" />
|
||||
<Compile Include="Runtime\ScriptFactory.cs" />
|
||||
<Compile Include="Runtime\ScriptObject.cs" />
|
||||
<Compile Include="Runtime\ScriptSystem.cs" />
|
||||
<Compile Include="World\Door.cs" />
|
||||
<Compile Include="World\Room.cs" />
|
||||
<Compile Include="World\TerrainType.cs" />
|
||||
<Compile Include="World\TravelDirections.cs" />
|
||||
<Compile Include="World\Zone.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
|
127
MudEngine/Runtime/CommandSystem.cs
Normal file
127
MudEngine/Runtime/CommandSystem.cs
Normal file
|
@ -0,0 +1,127 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Reflection;
|
||||
|
||||
using MudEngine.Core;
|
||||
|
||||
namespace MudEngine.Runtime
|
||||
{
|
||||
public class CommandSystem
|
||||
{
|
||||
public Dictionary<string, ICommand> Commands { get; private set; }
|
||||
|
||||
public CommandSystem()
|
||||
{
|
||||
Commands = new Dictionary<string, ICommand>();
|
||||
LoadCommands();
|
||||
}
|
||||
|
||||
public List<ICommand> GetCommands()
|
||||
{
|
||||
List<ICommand> collection = new List<ICommand>();
|
||||
|
||||
foreach (ICommand c in this.Commands.Values)
|
||||
collection.Add(c);
|
||||
|
||||
return collection;
|
||||
}
|
||||
|
||||
public ICommand GetCommand(string command)
|
||||
{
|
||||
foreach (ICommand c in this.Commands.Values)
|
||||
{
|
||||
if (c.Name.ToLower() == command.ToLower())
|
||||
return c;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool IsValidCommand(string command)
|
||||
{
|
||||
if (this.Commands.ContainsKey(command))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Execute(string command, ICharacter character)
|
||||
{
|
||||
string key = command.Insert(0, "Command");
|
||||
|
||||
foreach (string k in this.Commands.Keys)
|
||||
{
|
||||
if (key.ToLower().Contains(k.ToLower()))
|
||||
{
|
||||
ICommand cmd = this.Commands[k];
|
||||
try
|
||||
{
|
||||
cmd.Execute(command, character);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Inform player that this was not a valid command.
|
||||
}
|
||||
|
||||
private void LoadCommands()
|
||||
{
|
||||
this.LoadCommandLibrary(Assembly.GetExecutingAssembly(), true);
|
||||
}
|
||||
|
||||
public void LoadCommandLibrary(Assembly commandLibrary)
|
||||
{
|
||||
LoadCommandLibrary(commandLibrary, true);
|
||||
}
|
||||
|
||||
public void LoadCommandLibrary(Assembly commandLibrary, bool purgeLoadedCommands)
|
||||
{
|
||||
if (purgeLoadedCommands)
|
||||
PurgeCommands();
|
||||
|
||||
if (commandLibrary == null)
|
||||
return;
|
||||
|
||||
foreach (Type type in commandLibrary.GetTypes())
|
||||
{
|
||||
//All commands implement the ICommand interface.
|
||||
//If that interface is not present on this Type, skip and go to the next one.
|
||||
if (!type.IsInterface)
|
||||
continue;
|
||||
|
||||
if (type.GetInterface("ICommand") == null)
|
||||
continue;
|
||||
|
||||
ICommand cmd = (ICommand)Activator.CreateInstance(type);
|
||||
|
||||
if (cmd != null)
|
||||
{
|
||||
//Fail safe measures. Ensure that we always have a name assigned to the commands.
|
||||
if ((cmd.Name == "") || (cmd.Name == null))
|
||||
cmd.Name = cmd.GetType().Name.ToLower();
|
||||
else
|
||||
cmd.Name = cmd.Name.ToLower(); //Commands are always stored in lower case.
|
||||
|
||||
if (this.Commands.ContainsKey(cmd.Name))
|
||||
continue; //No overriding supported. Skip this command.
|
||||
|
||||
//Everything checks out ok. Add the command to our collection.
|
||||
this.Commands.Add(cmd.Name, cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void PurgeCommands()
|
||||
{
|
||||
this.Commands.Clear();
|
||||
}
|
||||
}
|
||||
}
|
124
MudEngine/Runtime/MudCompiler.cs
Normal file
124
MudEngine/Runtime/MudCompiler.cs
Normal file
|
@ -0,0 +1,124 @@
|
|||
using System;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Microsoft.CSharp;
|
||||
|
||||
using MudEngine.Core;
|
||||
|
||||
namespace MudEngine.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// Standard C# source code compiler.
|
||||
/// </summary>
|
||||
internal class MudCompiler : ICompiler
|
||||
{
|
||||
/// <summary>
|
||||
/// The file extension used for the script files.
|
||||
/// </summary>
|
||||
public String ScriptExtension { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Provides a collection of Assemblies that the compiler will add to its reference list.
|
||||
/// </summary>
|
||||
public List<String> AssemblyReferences { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The results of the compilation
|
||||
/// </summary>
|
||||
public CompilerResults Results { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Provides compiling options to various compilers, if they support this feature.
|
||||
/// </summary>
|
||||
public Dictionary<String, String> CompilerOptions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Compiles the source files found within the scriptRepository directory matching the ICompiler.ScriptExtension
|
||||
/// The Compiler defaults to the C# 4.0 compiler if none other is supplied via the ICompiler.CompilerOptions argument.
|
||||
/// </summary>
|
||||
/// <param name="param">Compiler Parameters that can be supplied to customize the compilation of the source.</param>
|
||||
/// <returns>Returns true if the compilation was completed without error.</returns>
|
||||
public Boolean Compile(CompilerParameters param, String scriptRepository)
|
||||
{
|
||||
//Make sure we have a compiler version supplied.
|
||||
if (!CompilerOptions.ContainsKey("CompilerVersion"))
|
||||
CompilerOptions.Add("CompilerVersion", "v4.0");
|
||||
|
||||
//Instance a reference to the C# code provider, this is what will perform the compiling.
|
||||
CSharpCodeProvider provider = new CSharpCodeProvider(CompilerOptions);
|
||||
//Create an array of script files found within the ScriptRepository matching the ScriptExtension properties.
|
||||
String[] scripts = Directory.GetFiles(scriptRepository, "*" + this.ScriptExtension, SearchOption.AllDirectories);
|
||||
|
||||
//Compile the scripts and provide the Results property with a reference to the compilation results.
|
||||
Results = provider.CompileAssemblyFromFile(param, scripts);
|
||||
|
||||
//if the compiler has errors, return false.
|
||||
if (Results.Errors.HasErrors)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compiles the source files found within the scriptFile argument.
|
||||
/// The Compiler defaults to the C# 4.0 compiler if none other is supplied via the ICompiler.CompilerOptions argument.
|
||||
/// </summary>
|
||||
/// <param name="param"></param>
|
||||
/// <returns></returns>
|
||||
public Boolean Compile(CompilerParameters param, FileInfo scriptFile)
|
||||
{
|
||||
//Make sure we have a compiler version supplied.
|
||||
if (!CompilerOptions.ContainsKey("CompilerVersion"))
|
||||
CompilerOptions.Add("CompilerVersion", "v4.0");
|
||||
|
||||
CSharpCodeProvider provider = new CSharpCodeProvider(CompilerOptions);
|
||||
|
||||
//Make sure the file exists prior to attempting to compile it.
|
||||
if (scriptFile.Exists)
|
||||
{
|
||||
//Compile the script and provide the Results property with a referece to the compilation results.
|
||||
Results = provider.CompileAssemblyFromFile(param, scriptFile.FullName);
|
||||
}
|
||||
else
|
||||
{
|
||||
Results.Errors.Add(new CompilerError(scriptFile.FullName, 0, 0, "rS01", "The supplied filename does not exist."));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Results.Errors.HasErrors)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compiles the source code found within the scriptSourceCode argument
|
||||
/// The Compiler defaults to the C# 4.0 compiler if none other is supplied via the ICompiler.CompilerOptions argument.
|
||||
/// </summary>
|
||||
/// <param name="param"></param>
|
||||
/// <returns></returns>
|
||||
public Boolean Compile(CompilerParameters param, String[] scriptSourceCode)
|
||||
{
|
||||
if (!CompilerOptions.ContainsKey("CompilerVersion"))
|
||||
CompilerOptions.Add("CompilerVersion", "v4.0");
|
||||
|
||||
CSharpCodeProvider provider = new CSharpCodeProvider(CompilerOptions);
|
||||
|
||||
if (scriptSourceCode.Length == 0)
|
||||
{
|
||||
Results.Errors.Add(new CompilerError("None", 0, 0, "rS02", "No Source provided."));
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Results = provider.CompileAssemblyFromSource(param, scriptSourceCode);
|
||||
}
|
||||
|
||||
if (Results.Errors.HasErrors)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
123
MudEngine/Runtime/ScriptFactory.cs
Normal file
123
MudEngine/Runtime/ScriptFactory.cs
Normal file
|
@ -0,0 +1,123 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace MudEngine.Runtime
|
||||
{
|
||||
public class ScriptFactory
|
||||
{
|
||||
//The assembly loaded that will be used.
|
||||
private List<Assembly> _AssemblyCollection;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for a Windows PC Script Factory
|
||||
/// </summary>
|
||||
/// <param name="assembly"></param>
|
||||
public ScriptFactory(String assembly)
|
||||
{
|
||||
Assembly a;
|
||||
_AssemblyCollection = new List<Assembly>();
|
||||
|
||||
//See if a file exists first with this assembly name.
|
||||
if (File.Exists(assembly))
|
||||
{
|
||||
a = Assembly.Load(new AssemblyName(assembly));
|
||||
}
|
||||
//If not, then try and load it differently
|
||||
else
|
||||
{
|
||||
a = Assembly.Load(assembly);
|
||||
}
|
||||
|
||||
if (a == null)
|
||||
return;
|
||||
|
||||
//Add the assembly to our assembly collection.
|
||||
_AssemblyCollection.Add(a);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Alternate Constructor for a Windows PC ScriptFactory
|
||||
/// </summary>
|
||||
/// <param name="assembly"></param>
|
||||
public ScriptFactory(Assembly assembly)
|
||||
{
|
||||
_AssemblyCollection = new List<Assembly>();
|
||||
//Add the supplied assembly to our AssemblyCollection
|
||||
_AssemblyCollection.Add(assembly);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds another assembly to the factories assembly collection.
|
||||
/// </summary>
|
||||
/// <param name="assembly">provides the name of the assembly, or file name that needs to be loaded.</param>
|
||||
public void AddAssembly(String assembly)
|
||||
{
|
||||
Assembly a;
|
||||
|
||||
//See if a file exists first with this assembly name.
|
||||
if (File.Exists(assembly))
|
||||
{
|
||||
a = Assembly.Load(new AssemblyName(assembly));
|
||||
}
|
||||
//If not, then try and load it differently
|
||||
else
|
||||
{
|
||||
a = Assembly.Load(assembly);
|
||||
}
|
||||
|
||||
//Add the assembly to our assembly collection.
|
||||
_AssemblyCollection.Add(a);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds another assembly to the factories assembly collection.
|
||||
/// </summary>
|
||||
/// <param name="assembly">Provides a reference to the assembly that will be added to the collection.</param>
|
||||
public void AddAssembly (Assembly assembly)
|
||||
{
|
||||
//Add the supplied assembly to our AssemblyCollection
|
||||
_AssemblyCollection.Add(assembly);
|
||||
}
|
||||
|
||||
public ScriptObject GetScript(String scriptName)
|
||||
{
|
||||
Type script = typeof(Object);
|
||||
Boolean foundScript = false;
|
||||
|
||||
if (_AssemblyCollection.Count == 0)
|
||||
return new ScriptObject(null);
|
||||
|
||||
try
|
||||
{
|
||||
foreach (Assembly a in _AssemblyCollection)
|
||||
{
|
||||
//The assembly can be null if accessing after a failed compilation.
|
||||
if (a == null)
|
||||
continue;
|
||||
|
||||
foreach (Type t in a.GetTypes())
|
||||
{
|
||||
if (t.Name == scriptName)
|
||||
{
|
||||
script = t;
|
||||
foundScript = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (foundScript)
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw new Exception("Error encounted during factory instancing of script " + scriptName + ".");
|
||||
}
|
||||
|
||||
ScriptObject obj = new ScriptObject(Activator.CreateInstance(script));
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
88
MudEngine/Runtime/ScriptObject.cs
Normal file
88
MudEngine/Runtime/ScriptObject.cs
Normal file
|
@ -0,0 +1,88 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace MudEngine.Runtime
|
||||
{
|
||||
public class ScriptObject
|
||||
{
|
||||
public Object Instance { get; set; }
|
||||
|
||||
public ScriptObject(Object instance)
|
||||
{
|
||||
if (instance == null)
|
||||
Instance = new Object();
|
||||
else
|
||||
Instance = instance;
|
||||
}
|
||||
|
||||
~ScriptObject()
|
||||
{
|
||||
//TODO: Add ability to call a Shutdown() method within this Instance.
|
||||
Instance = null;
|
||||
}
|
||||
|
||||
public void SetProperty(String propertyName, object propertyValue)
|
||||
{
|
||||
PropertyInfo propertyInfo = Instance.GetType().GetProperty(propertyName);
|
||||
|
||||
if (propertyValue is String)
|
||||
{
|
||||
if (propertyInfo.PropertyType.Name is String)
|
||||
{
|
||||
propertyInfo.SetValue(Instance, propertyValue, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public object GetProperty(String propertyName)
|
||||
{
|
||||
String[] tokens = propertyName.Split('.');
|
||||
PropertyInfo previousProperty = Instance.GetType().GetProperty(tokens[0]);
|
||||
|
||||
return previousProperty.GetValue(Instance, null);
|
||||
}
|
||||
|
||||
public dynamic GetProperty()
|
||||
{
|
||||
return Instance;
|
||||
}
|
||||
|
||||
public object GetField(String propertyName)
|
||||
{
|
||||
String[] tokens = propertyName.Split('.');
|
||||
FieldInfo previousField = Instance.GetType().GetField(tokens[0]);
|
||||
|
||||
return previousField.GetValue(Instance);
|
||||
}
|
||||
|
||||
public dynamic GetField()
|
||||
{
|
||||
return Instance;
|
||||
}
|
||||
|
||||
public Object InvokeMethod(String methodName)
|
||||
{
|
||||
return InvokeMethod(methodName, null);
|
||||
}
|
||||
|
||||
public Object InvokeMethod(String methodName, params Object[] parameters)
|
||||
{
|
||||
MethodInfo method = Instance.GetType().GetMethod(methodName);
|
||||
|
||||
try
|
||||
{
|
||||
if (parameters == null || parameters.Length == 0)
|
||||
return method.Invoke(Instance, null);
|
||||
else
|
||||
return method.Invoke(Instance, parameters);
|
||||
}
|
||||
catch
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("Error invoking method. Does the method exist?");
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
403
MudEngine/Runtime/ScriptSystem.cs
Normal file
403
MudEngine/Runtime/ScriptSystem.cs
Normal file
|
@ -0,0 +1,403 @@
|
|||
using System;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using Microsoft.CSharp;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
using MudEngine.Core;
|
||||
|
||||
namespace MudEngine.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides Properties & Methods needed to compile script source code into .NET assemblies.
|
||||
/// </summary>
|
||||
public class ScriptSystem
|
||||
{
|
||||
/// <summary>
|
||||
/// The file extension used for the script files.
|
||||
/// </summary>
|
||||
public String ScriptExtension
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ScriptExtension;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value.StartsWith("."))
|
||||
_ScriptExtension = value;
|
||||
else
|
||||
_ScriptExtension = "." + value;
|
||||
}
|
||||
}
|
||||
private String _ScriptExtension;
|
||||
|
||||
/// <summary>
|
||||
/// Provides a collection of Assemblies that the compiler will add to its reference list.
|
||||
/// </summary>
|
||||
public List<String> AssemblyReferences { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Provides a reference to the assembly generated during script compilation.
|
||||
/// </summary>
|
||||
public Assembly CompiledAssembly { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The compiler that will be used when the contents of ScriptRepository are compiled.
|
||||
/// </summary>
|
||||
protected String Compiler { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Used to supply compiling options to various compilers if they support this feature.
|
||||
/// </summary>
|
||||
protected Dictionary<String, String> CompilerOptions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Used to check if the compilation contained any errors.
|
||||
/// </summary>
|
||||
public Boolean HasErrors { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// String of errors that occurred during compilation, if any.
|
||||
/// </summary>
|
||||
public String Errors
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_CompileMessages.Length == 0)
|
||||
return "No Errors.";
|
||||
else
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
foreach (String error in _CompileMessages)
|
||||
{
|
||||
builder.AppendLine(error);
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Messages stored from the compilers CompilerResults property.
|
||||
private String[] _CompileMessages;
|
||||
|
||||
//Returns all of the assemblies currently loaded in the current domain.
|
||||
private Assembly[] _Assemblies
|
||||
{
|
||||
get
|
||||
{
|
||||
return AppDomain.CurrentDomain.GetAssemblies();
|
||||
}
|
||||
}
|
||||
|
||||
public ScriptSystem() : this(".cs")
|
||||
{
|
||||
//Passes defaults off to the parameterized constructor.
|
||||
}
|
||||
|
||||
public ScriptSystem(String scriptExtensions)
|
||||
{
|
||||
_CompileMessages = new String[] { "No compiler messages available." };
|
||||
|
||||
CompilerOptions = new Dictionary<string, string>();
|
||||
Compiler = "MudCompiler";
|
||||
|
||||
AssemblyReferences = new List<string>();
|
||||
AssemblyReferences.Add("mscorlib.dll");
|
||||
AssemblyReferences.Add("System.dll");
|
||||
AssemblyReferences.Add("System.Core.dll");
|
||||
|
||||
ScriptExtension = scriptExtensions;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a reference to the supplied Assembly name to the compilers reference collection.
|
||||
/// </summary>
|
||||
/// <param name="assembly"></param>
|
||||
public void AddAssemblyReference(String assembly)
|
||||
{
|
||||
if (!AssemblyReferences.Contains(assembly))
|
||||
AssemblyReferences.Add(assembly);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a reference to the supplied Assembly to the compilers reference collection.
|
||||
/// </summary>
|
||||
/// <param name="assembly"></param>
|
||||
public void AddAssemblyReference(Assembly assembly)
|
||||
{
|
||||
if (!AssemblyReferences.Contains(assembly.GetName().Name))
|
||||
AssemblyReferences.Add(assembly.GetName().Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the supplied assembly from the compilers reference collection.
|
||||
/// </summary>
|
||||
/// <param name="assembly"></param>
|
||||
public void RemoveAssemblyReference(String assembly)
|
||||
{
|
||||
if (AssemblyReferences.Contains(assembly))
|
||||
AssemblyReferences.Remove(assembly);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the compilers reference collection, leaving it empty.
|
||||
/// </summary>
|
||||
public void ClearAssemblyReference()
|
||||
{
|
||||
AssemblyReferences.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compiles the scripts found within the CompileEngine.ScriptRepository directory that match the CompileEngine.ScriptExtension file extension.
|
||||
/// The compiler will compile the scripts using the compiler specified with the CompileEngine.Compiler Property.
|
||||
/// </summary>
|
||||
/// <returns>Returns true if compilation was completed without any errors.</returns>
|
||||
public Boolean Compile(String scriptRepository)
|
||||
{
|
||||
//Get the compiler that the developer has selected.
|
||||
//If the developer chooses a compiler that is not part of the engine, the GetCompiler() method
|
||||
//will check all the currently loaded assemblies in memory for a custom compiler implementing
|
||||
//the ICompiler interface.
|
||||
Type compiler = GetCompiler();
|
||||
|
||||
//Incase a non-default compiler was specified and we could not find it in memory, fail.
|
||||
if (compiler.Name == "ICompiler")
|
||||
{
|
||||
this._CompileMessages = new string[] { "Compilation Failed.", "Unable to locate the specified compiler of Type '" + Compiler + "'." };
|
||||
return false;
|
||||
}
|
||||
|
||||
//Get the compiler parameters.
|
||||
CompilerParameters param = GetParameters();
|
||||
|
||||
//Create a Instance of the compiler, either custom or internal.
|
||||
ICompiler com = (ICompiler)Activator.CreateInstance(compiler);
|
||||
|
||||
//Setup it's properties to match that of our CompileEngine.
|
||||
com.AssemblyReferences = AssemblyReferences;
|
||||
com.ScriptExtension = ScriptExtension;
|
||||
com.CompilerOptions = this.CompilerOptions;
|
||||
|
||||
//Compile the scripts.
|
||||
Boolean isSuccess = com.Compile(param, scriptRepository);
|
||||
HasErrors = !isSuccess;
|
||||
|
||||
//If the compilation failed, store all of the compiler errors
|
||||
//into our _CompileMessages string.
|
||||
if (!isSuccess)
|
||||
{
|
||||
List<String> compilerMessages = new List<string>();
|
||||
foreach (String message in com.Results.Output)
|
||||
{
|
||||
compilerMessages.Add(message);
|
||||
}
|
||||
|
||||
_CompileMessages = compilerMessages.ToArray();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Compiling completed without error, so we need to save
|
||||
//a reference to the compiled assembly.
|
||||
CompiledAssembly = com.Results.CompiledAssembly;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compiles the script supplied.
|
||||
/// The compiler will compile the script using the compiler specified with the CompileEngine.Compiler Property.
|
||||
/// </summary>
|
||||
/// <returns>Returns true if compilation was completed without any errors.</returns>
|
||||
public Boolean Compile(FileInfo sourceFile)
|
||||
{
|
||||
if (!sourceFile.Exists)
|
||||
{
|
||||
this._CompileMessages = new String[] { "Error: File " + sourceFile.FullName + " does not exists." };
|
||||
return false;
|
||||
}
|
||||
|
||||
//Get the compiler that the developer has selected.
|
||||
//If the developer chooses a compiler that is not part of the engine, the GetCompiler() method
|
||||
//will check all the currently loaded assemblies in memory for a custom compiler implementing
|
||||
//the ICompiler interface.
|
||||
Type compiler = GetCompiler();
|
||||
|
||||
//Incase a non-default compiler was specified and we could not find it in memory, fail.
|
||||
if (compiler.Name == "ICompiler")
|
||||
{
|
||||
this._CompileMessages = new string[] { "Compilation Failed.", "Unable to locate the specified compiler of Type '" + Compiler + "'." };
|
||||
return false;
|
||||
}
|
||||
|
||||
//Get the compiler parameters.
|
||||
CompilerParameters param = GetParameters();
|
||||
|
||||
//Create a Instance of the compiler, either custom or internal.
|
||||
ICompiler com = (ICompiler)Activator.CreateInstance(compiler);
|
||||
|
||||
//Setup it's properties to match that of our CompileEngine.
|
||||
com.AssemblyReferences = AssemblyReferences;
|
||||
com.ScriptExtension = ScriptExtension;
|
||||
com.CompilerOptions = this.CompilerOptions;
|
||||
|
||||
//Compile the script.
|
||||
Boolean isSuccess = com.Compile(param, sourceFile);
|
||||
HasErrors = !isSuccess;
|
||||
|
||||
//If the compilation failed, store all of the compiler errors
|
||||
//into our _CompileMessages string.
|
||||
if (!isSuccess)
|
||||
{
|
||||
List<String> compilerMessages = new List<string>();
|
||||
foreach (String message in com.Results.Output)
|
||||
{
|
||||
compilerMessages.Add(message);
|
||||
}
|
||||
|
||||
_CompileMessages = compilerMessages.ToArray();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Compiling completed without error, so we need to save
|
||||
//a reference to the compiled assembly.
|
||||
CompiledAssembly = com.Results.CompiledAssembly;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compiles the source code provided.
|
||||
/// The compiler will compile the scripts using the compiler specified with the CompileEngine.Compiler Property.
|
||||
/// </summary>
|
||||
/// <returns>Returns true if compilation was completed without any errors.</returns>
|
||||
public Boolean Compile(String[] sourceCode)
|
||||
{
|
||||
//Get the compiler that the developer has selected.
|
||||
//If the developer chooses a compiler that is not part of the engine, the GetCompiler() method
|
||||
//will check all the currently loaded assemblies in memory for a custom compiler implementing
|
||||
//the ICompiler interface.
|
||||
Type compiler = GetCompiler();
|
||||
|
||||
//Incase a non-default compiler was specified and we could not find it in memory, fail.
|
||||
if (compiler.Name == "ICompiler")
|
||||
{
|
||||
this._CompileMessages = new string[] { "Compilation Failed.", "Unable to locate the specified compiler of Type '" + Compiler + "'." };
|
||||
return false;
|
||||
}
|
||||
|
||||
//Get the compiler parameters.
|
||||
CompilerParameters param = GetParameters();
|
||||
|
||||
//Create a Instance of the compiler, either custom or internal.
|
||||
ICompiler com = (ICompiler)Activator.CreateInstance(compiler);
|
||||
|
||||
//Setup it's properties to match that of our CompileEngine.
|
||||
com.AssemblyReferences = AssemblyReferences;
|
||||
com.ScriptExtension = ScriptExtension;
|
||||
com.CompilerOptions = this.CompilerOptions;
|
||||
|
||||
//Compile the scripts.
|
||||
Boolean isSuccess = com.Compile(param, sourceCode);
|
||||
HasErrors = !isSuccess;
|
||||
|
||||
//If the compilation failed, store all of the compiler errors
|
||||
//into our _CompileMessages string.
|
||||
if (!isSuccess)
|
||||
{
|
||||
List<String> compilerMessages = new List<string>();
|
||||
foreach (String message in com.Results.Output)
|
||||
{
|
||||
compilerMessages.Add(message);
|
||||
}
|
||||
|
||||
_CompileMessages = compilerMessages.ToArray();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Compiling completed without error, so we need to save
|
||||
//a reference to the compiled assembly.
|
||||
CompiledAssembly = com.Results.CompiledAssembly;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets compiler parameters that the compiler will be supplied with.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private CompilerParameters GetParameters()
|
||||
{
|
||||
//Setup some default parameters that will be used by the compilers.
|
||||
CompilerParameters param = new CompilerParameters(this.AssemblyReferences.ToArray());
|
||||
param.GenerateExecutable = false;
|
||||
param.GenerateInMemory = true;
|
||||
|
||||
//Left out, Add as CompileEngine properties in the future.
|
||||
//param.TreatWarningsAsErrors = true;
|
||||
//param.WarningLevel = 0;
|
||||
//param.IncludeDebugInformation = true;
|
||||
return param;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the compiler that will be used during the compilation of the scripts.
|
||||
/// If a custom compiler is used, then the method will check every assembly in memory
|
||||
/// and find the custom one requested. If none are found, then it will return a new
|
||||
/// Object of type ICompiler.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private Type GetCompiler()
|
||||
{
|
||||
Type compiler = typeof(ICompiler);
|
||||
|
||||
//Internal CSharpRaw compiler Type specified, so we'll use that.
|
||||
if ((this.Compiler.ToLower() == "MudCompiler") || (this.Compiler.ToLower() == "mc"))
|
||||
{
|
||||
compiler = typeof(MudCompiler);
|
||||
return compiler;
|
||||
}
|
||||
//Build a collection of available compilers by scanning all the assemblies loaded in memory.
|
||||
//If any of the assemblies contain a Type that uses the ICompiler interface, we will assume that the
|
||||
//assembly is a add-on assembly for rScript, adding a new compiler to the CompileEngine.
|
||||
//Only used if a non-internal compiler is specified
|
||||
else
|
||||
{ //Non-internal compiler supplied, so loop through every assembly loaded in memory
|
||||
foreach (Assembly a in _Assemblies)
|
||||
{
|
||||
Boolean isCompiler = false;
|
||||
|
||||
//Create an array of all Types within this assembly
|
||||
Type[] types = a.GetTypes();
|
||||
|
||||
//Itterate through each Type; See if any implement the ICompiler interface.
|
||||
foreach (Type t in a.GetTypes())
|
||||
{
|
||||
//If this Type implements ICompiler, then our compiler field needs to reference the Type.
|
||||
if ((t.GetInterface("ICompiler") != null) && (t.Name.ToLower() == Compiler.ToLower()))
|
||||
{
|
||||
//compiler needs to reference this custom compiler Type.
|
||||
compiler = t;
|
||||
isCompiler = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//If we found a matching compiler, then exit this loop.
|
||||
if (isCompiler)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return compiler;
|
||||
}
|
||||
}
|
||||
}
|
51
MudEngine/World/Door.cs
Normal file
51
MudEngine/World/Door.cs
Normal file
|
@ -0,0 +1,51 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using MudEngine.Core;
|
||||
|
||||
namespace MudEngine.World
|
||||
{
|
||||
public class Door
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or Sets if this doorway is locked, requiring a key to enter.
|
||||
/// </summary>
|
||||
[Category("Door Settings")]
|
||||
[DefaultValue(false)]
|
||||
public bool IsLocked { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets what item is required to travel through this doorway if IsLocked
|
||||
/// </summary>
|
||||
[Category("Door Settings")]
|
||||
[Browsable(false)]
|
||||
public BaseItem RequiredKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets the minimum level a character must be in order to travel through this doorway
|
||||
/// </summary>
|
||||
[Category("Door Settings")]
|
||||
[DefaultValue(0)]
|
||||
public int LevelRequirement { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets the direction a character must travel in order to move through this doorway
|
||||
/// </summary>
|
||||
[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; }
|
||||
}
|
||||
|
||||
}
|
84
MudEngine/World/Room.cs
Normal file
84
MudEngine/World/Room.cs
Normal file
|
@ -0,0 +1,84 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using MudEngine.Core;
|
||||
|
||||
namespace MudEngine.World
|
||||
{
|
||||
public class Room : BaseEnvironment
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or Sets the type of terrain that this room contains.
|
||||
/// </summary>
|
||||
public TerrainTypes Terrain { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the collection of doorways present within this room
|
||||
/// </summary>
|
||||
public List<Door> Doorways { get; private set; }
|
||||
|
||||
public Room(BaseGame game) : base(game)
|
||||
{
|
||||
Doorways = new List<Door>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Installs a doorway into the room. Multiple doorways for the same travel direction is not allowed.
|
||||
/// </summary>
|
||||
/// <param name="door"></param>
|
||||
/// <returns></returns>
|
||||
public bool InstallDoor(Door door)
|
||||
{
|
||||
//Anonymous method to check if a door already exists for the travel direction supplied.
|
||||
Door dr = Doorways.Find(delegate(Door d)
|
||||
{
|
||||
return d.TravelDirection == door.TravelDirection;
|
||||
}
|
||||
);
|
||||
|
||||
if (dr != null)
|
||||
return false;
|
||||
|
||||
Doorways.Add(door);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a doorway from the room.
|
||||
/// </summary>
|
||||
/// <param name="travelDirection"></param>
|
||||
public void RemoveDoor(AvailableTravelDirections travelDirection)
|
||||
{
|
||||
Door dr = Doorways.Find(delegate(Door d)
|
||||
{
|
||||
return d.TravelDirection == travelDirection;
|
||||
}
|
||||
);
|
||||
|
||||
if (dr != null)
|
||||
Doorways.Remove(dr);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks to see if a doorway exists for the supplied travel direction.
|
||||
/// </summary>
|
||||
/// <param name="travelDirection"></param>
|
||||
/// <returns></returns>
|
||||
public bool DoorwayExists(AvailableTravelDirections travelDirection)
|
||||
{
|
||||
return Doorways.Exists(d => d.TravelDirection == travelDirection);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a reference to an installed doorway, for the supplied travel direction.
|
||||
/// </summary>
|
||||
/// <param name="travelDirection"></param>
|
||||
/// <returns></returns>
|
||||
public Door GetDoorway(AvailableTravelDirections travelDirection)
|
||||
{
|
||||
return Doorways.Find(d => d.TravelDirection == travelDirection);
|
||||
}
|
||||
}
|
||||
}
|
20
MudEngine/World/TerrainType.cs
Normal file
20
MudEngine/World/TerrainType.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MudEngine.World
|
||||
{
|
||||
public enum TerrainTypes
|
||||
{
|
||||
Stone,
|
||||
Dirt,
|
||||
Grass,
|
||||
Rock,
|
||||
Wood,
|
||||
Water,
|
||||
Air,
|
||||
Mud,
|
||||
Other,
|
||||
}
|
||||
}
|
67
MudEngine/World/TravelDirections.cs
Normal file
67
MudEngine/World/TravelDirections.cs
Normal file
|
@ -0,0 +1,67 @@
|
|||
using System;
|
||||
|
||||
namespace MudEngine.World
|
||||
{
|
||||
[System.Flags]
|
||||
public enum AvailableTravelDirections : uint
|
||||
{
|
||||
None = 0,
|
||||
North = 1,
|
||||
South = 2,
|
||||
East = 4,
|
||||
West = 8,
|
||||
Up = 16,
|
||||
Down = 32,
|
||||
Northeast = North | East,
|
||||
Northwest = North | West,
|
||||
Southeast = South | East,
|
||||
Southwest = South | West
|
||||
}
|
||||
|
||||
public static class TravelDirections
|
||||
{
|
||||
public static AvailableTravelDirections GetReverseDirection(AvailableTravelDirections Direction)
|
||||
{
|
||||
switch (Direction)
|
||||
{
|
||||
case AvailableTravelDirections.North:
|
||||
return AvailableTravelDirections.South;
|
||||
case AvailableTravelDirections.South:
|
||||
return AvailableTravelDirections.North;
|
||||
case AvailableTravelDirections.East:
|
||||
return AvailableTravelDirections.West;
|
||||
case AvailableTravelDirections.West:
|
||||
return AvailableTravelDirections.East;
|
||||
case AvailableTravelDirections.Up:
|
||||
return AvailableTravelDirections.Down;
|
||||
case AvailableTravelDirections.Down:
|
||||
return AvailableTravelDirections.Up;
|
||||
case AvailableTravelDirections.Northeast:
|
||||
return AvailableTravelDirections.Southwest;
|
||||
case AvailableTravelDirections.Southwest:
|
||||
return AvailableTravelDirections.Northeast;
|
||||
case AvailableTravelDirections.Northwest:
|
||||
return AvailableTravelDirections.Southeast;
|
||||
case AvailableTravelDirections.Southeast:
|
||||
return AvailableTravelDirections.Northwest;
|
||||
default:
|
||||
return AvailableTravelDirections.None;
|
||||
}
|
||||
}
|
||||
|
||||
public static AvailableTravelDirections GetTravelDirectionValue(String Direction)
|
||||
{
|
||||
Array values = Enum.GetValues(typeof(AvailableTravelDirections));
|
||||
|
||||
foreach (Int32 value in values)
|
||||
{
|
||||
String displayName = Enum.GetName(typeof(AvailableTravelDirections), value);
|
||||
|
||||
if (displayName.ToLower() == Direction.ToLower())
|
||||
return (AvailableTravelDirections)Enum.Parse(typeof(AvailableTravelDirections), displayName);
|
||||
}
|
||||
|
||||
return AvailableTravelDirections.None;
|
||||
}
|
||||
}
|
||||
}
|
108
MudEngine/World/Zone.cs
Normal file
108
MudEngine/World/Zone.cs
Normal file
|
@ -0,0 +1,108 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using MudEngine.Core;
|
||||
|
||||
namespace MudEngine.World
|
||||
{
|
||||
public class Zone : BaseEnvironment
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a reference to the Room collection for this zone
|
||||
/// </summary>
|
||||
public List<Room> Rooms { get; private set; }
|
||||
|
||||
public Zone(BaseGame game)
|
||||
: base(game)
|
||||
{
|
||||
Rooms = new List<Room>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Installs a Room into this Zone, if the Room does not already exists.
|
||||
/// </summary>
|
||||
/// <param name="room"></param>
|
||||
/// <returns></returns>
|
||||
public bool InstallRoom(Room room)
|
||||
{
|
||||
Room rm = Rooms.Find(delegate(Room r)
|
||||
{
|
||||
return r.ID == room.ID;
|
||||
}
|
||||
);
|
||||
|
||||
if (rm != null)
|
||||
return false;
|
||||
|
||||
Rooms.Add(room);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a reference to a room matching the supplied name
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public Room GetRoom(string name)
|
||||
{
|
||||
return Rooms.Find(r => r.Name == name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a reference to a room matching the supplied id.
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public Room GetRoom(int id)
|
||||
{
|
||||
return Rooms.Find(r => r.ID == id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the specified Room exists within this zone.
|
||||
/// </summary>
|
||||
/// <param name="room"></param>
|
||||
/// <returns></returns>
|
||||
public bool RoomExists(Room room)
|
||||
{
|
||||
return Rooms.Exists(r => r.ID == room.ID);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the specified ID exists within this zone.
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public bool RoomExists(int id)
|
||||
{
|
||||
return Rooms.Exists(r => r.ID == id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replaces a room matching the oldID argument with the supplied newRoom.
|
||||
/// </summary>
|
||||
/// <param name="room"></param>
|
||||
/// <returns></returns>
|
||||
public bool ReplaceRoom(Room newRoom, int oldID)
|
||||
{
|
||||
if (!RoomExists(oldID))
|
||||
return false;
|
||||
|
||||
Room rm = Rooms.Find(delegate(Room r)
|
||||
{
|
||||
return r.ID == oldID;
|
||||
}
|
||||
);
|
||||
|
||||
if (rm == null)
|
||||
return false;
|
||||
|
||||
Rooms.Remove(rm);
|
||||
Rooms.Add(newRoom);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -112,10 +112,6 @@
|
|||
<Project>{498943A8-DF5A-4DB0-B506-0BFF44788657}</Project>
|
||||
<Name>MudEngine</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\rScripting\rScripting.csproj">
|
||||
<Project>{BC1B32DA-7209-4B32-8171-A190EF21F5D6}</Project>
|
||||
<Name>rScripting</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
|
|
@ -5,123 +5,13 @@ using System.IO;
|
|||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
|
||||
using MudEngine.FileSystem;
|
||||
using MudEngine.GameManagement;
|
||||
using MudEngine.GameObjects.Characters;
|
||||
using MudEngine.Scripting;
|
||||
|
||||
namespace MudGame
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
const String SettingsFile = "Settings.ini";
|
||||
|
||||
static void Main(String[] args)
|
||||
{
|
||||
Game game = new Game();
|
||||
|
||||
//Re-create the settings file if it is missing. Don't push any log messages until we know that this is
|
||||
//verbose or not
|
||||
Log.Write("Loading Settings...", false);
|
||||
if (!File.Exists(SettingsFile))
|
||||
{
|
||||
Log.Write("Settings.ini missing!", false);
|
||||
FileManager.WriteLine(SettingsFile, "Scripts", "ScriptPath");
|
||||
FileManager.WriteLine(SettingsFile, ".cs", "ScriptExtension");
|
||||
FileManager.WriteLine(SettingsFile, "True", "ServerEnabled");
|
||||
Log.Write("Settings.ini re-created with default values", false);
|
||||
}
|
||||
|
||||
if (FileManager.GetData(SettingsFile, "ServerEnabled").ToLower() == "false")
|
||||
Log.IsVerbose = true;
|
||||
else if (FileManager.GetData(SettingsFile, "ServerEnabled").ToLower() == "")
|
||||
Log.IsVerbose = false;
|
||||
else
|
||||
Log.IsVerbose = false;
|
||||
|
||||
//Get are cached log messages and go forward from here.
|
||||
Console.Write(Log.GetMessages());
|
||||
Log.FlushMessages();
|
||||
|
||||
Log.Write("Launching...", true);
|
||||
|
||||
//Search for a custom Game Type before we launch our game.
|
||||
//Compile the scripts
|
||||
rScripting.CompileEngine compiler = new rScripting.CompileEngine(".cs");
|
||||
compiler.Compiler = "MudScriptCompiler";
|
||||
if (!compiler.Compile("Scripts"))
|
||||
{
|
||||
Log.Write("Failed compiling script files.");
|
||||
Log.Write(compiler.Errors);
|
||||
}
|
||||
|
||||
//If there were errors during compilation, then skip the custom scripts and use the default Game Type.
|
||||
if (!compiler.HasErrors)
|
||||
{
|
||||
//Search the scripts for a Type inheriting from Game
|
||||
rScripting.LateBinding.ScriptFactory factory = new rScripting.LateBinding.ScriptFactory(compiler.CompiledAssembly);
|
||||
foreach (Type t in compiler.CompiledAssembly.GetTypes())
|
||||
{
|
||||
if (t.BaseType.Name == "Game")
|
||||
{
|
||||
rScripting.LateBinding.ScriptObject obj = factory.GetScript(t.Name);
|
||||
game = (Game)obj.Instance;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Server is only enabled if the option is in the settings file
|
||||
//Allows developers to remove the option from the settings file and letting
|
||||
//people host multiplayer games with the singleplayer MUD.
|
||||
//People won't know that it's an option if the option doesn't exist so if no
|
||||
//option is found in the sttings file, then we assume offline play.
|
||||
if (FileManager.GetData(SettingsFile, "ServerEnabled").ToLower() == "false")
|
||||
game.IsMultiplayer = false;
|
||||
else if (FileManager.GetData(SettingsFile, "ServerEnabled").ToLower() == "")
|
||||
game.IsMultiplayer = false;
|
||||
else
|
||||
game.IsMultiplayer = true;
|
||||
|
||||
//Start the game.
|
||||
game.Start();
|
||||
|
||||
//Make sure the Game is in fact running.
|
||||
if (!game.IsRunning)
|
||||
{
|
||||
Log.Write("Error starting game!\nReview Log file for details.", true);
|
||||
return;
|
||||
}
|
||||
|
||||
//If the game isn't in multiplayer mode, then the server doesn't create an instance of the players
|
||||
//We need to make sure that the Game created one. The default game handles this, but inherited Game
|
||||
//scripts might miss this, so we check for it.
|
||||
if (!game.IsMultiplayer)
|
||||
{
|
||||
if ((game.GetPlayerCollection()[0] == null) || (game.GetPlayerCollection()[0].Name == "New BaseCharacter"))
|
||||
{
|
||||
Log.Write("Error! No player available for creation!", true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Console.Title = game.GameTitle;
|
||||
|
||||
if (game.IsMultiplayer)
|
||||
Console.Title += " server running.";
|
||||
|
||||
try
|
||||
{
|
||||
while (game.IsRunning)
|
||||
{
|
||||
game.Update();
|
||||
System.Threading.Thread.Sleep(1);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Write("Critical Error! " + ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue