MudEngine:
- Deleted GameObjects.Characters.Controlled and GameObjects.Characters.NPC namespaces. - Deleted PlayerBasic & PlayerAdmin classes. - BaseCharacter now contains IsAdmin property for providing admin privileges to users. - BaseCharacter now contains IsControlled property for setting user control or AI controlled - Added startup.dat - This will supply information to the engine as to what Types will be used during runtime. Allowing for custom Types via scripts to be instanced and used (such as a custom player class rather than the default one).
This commit is contained in:
parent
1a4655c30e
commit
0587b4a475
10 changed files with 38 additions and 44 deletions
|
@ -4,7 +4,6 @@ using System.Linq;
|
|||
using System.Text;
|
||||
|
||||
using MudEngine.GameObjects.Characters;
|
||||
using MudEngine.GameObjects.Characters.Controlled;
|
||||
using MudEngine.FileSystem;
|
||||
using MudEngine.Commands;
|
||||
using MudEngine.GameManagement;
|
||||
|
|
|
@ -9,7 +9,6 @@ using System.Net.Sockets;
|
|||
|
||||
//MUD Engine
|
||||
using MudEngine.GameObjects.Characters;
|
||||
using MudEngine.GameObjects.Characters.Controlled;
|
||||
using MudEngine.GameManagement;
|
||||
using MudEngine.GameObjects.Environment;
|
||||
using MudEngine.GameObjects;
|
||||
|
@ -24,7 +23,7 @@ namespace MudEngine.Commands
|
|||
|
||||
public CommandResults Execute(string command, BaseCharacter player, Game project, Room room)
|
||||
{
|
||||
if (player is PlayerAdmin)
|
||||
if (player.IsAdmin)
|
||||
{
|
||||
for (int i = 0; i < project.PlayerCollection.Count; i++)
|
||||
project.PlayerCollection[i].Save(project.PlayerCollection[i].Name + ".dat");
|
||||
|
|
|
@ -14,8 +14,8 @@ using System.Reflection;
|
|||
//MUD Engine
|
||||
using MudEngine.FileSystem;
|
||||
using MudEngine.GameObjects;
|
||||
using MudEngine.GameObjects.Characters;
|
||||
using MudEngine.GameObjects.Environment;
|
||||
using MudEngine.GameObjects.Characters.Controlled;
|
||||
|
||||
namespace MudEngine.GameManagement
|
||||
{
|
||||
|
@ -172,6 +172,9 @@ namespace MudEngine.GameManagement
|
|||
_Filename = "Game.xml";
|
||||
BaseCurrencyAmount = 1;
|
||||
BaseCurrencyName = "Copper";
|
||||
scriptEngine.Initialize();
|
||||
|
||||
//Get the new
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -196,7 +199,7 @@ namespace MudEngine.GameManagement
|
|||
{
|
||||
Scripting.GameObject obj = new Scripting.GameObject();
|
||||
obj = scriptEngine.GetObject(t.Name);
|
||||
PlayerCollection.Add((PlayerBasic)obj.Instance);
|
||||
PlayerCollection.Add((BaseCharacter)obj.Instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -229,7 +232,7 @@ namespace MudEngine.GameManagement
|
|||
}
|
||||
|
||||
|
||||
public List<PlayerBasic> PlayerCollection;
|
||||
public List<BaseCharacter> PlayerCollection;
|
||||
|
||||
public MudEngine.Networking.Server server = new MudEngine.Networking.Server();
|
||||
public ProtocolType ServerType = ProtocolType.Tcp;
|
||||
|
|
|
@ -16,8 +16,21 @@ namespace MudEngine.GameObjects.Characters
|
|||
{
|
||||
public class BaseCharacter : BaseObject
|
||||
{
|
||||
/// <summary>
|
||||
/// The current Room this Character is located at.
|
||||
/// </summary>
|
||||
public Room CurrentRoom { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets if this Character is controlled by the user. If not user controlled then it will be AI controlled.
|
||||
/// </summary>
|
||||
public Boolean IsControlled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets if this user has Admin privileges or not.
|
||||
/// </summary>
|
||||
public Boolean IsAdmin { get; private set; }
|
||||
|
||||
public virtual void OnTravel(AvailableTravelDirections travelDirection)
|
||||
{
|
||||
if (CurrentRoom.DoorwayExist(travelDirection.ToString()))
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MudEngine.GameObjects.Characters.Controlled
|
||||
{
|
||||
public class PlayerAdmin : PlayerBasic
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
//Microsoft .NET Framework
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
//MUD Engine
|
||||
using MudEngine.GameObjects.Characters;
|
||||
|
||||
namespace MudEngine.GameObjects.Characters.Controlled
|
||||
{
|
||||
public class PlayerBasic : BaseCharacter
|
||||
{
|
||||
public PlayerBasic()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -63,8 +63,6 @@
|
|||
<Compile Include="GameObjects\Bag.cs" />
|
||||
<Compile Include="GameObjects\BaseObject.cs" />
|
||||
<Compile Include="GameObjects\Characters\BaseCharacter.cs" />
|
||||
<Compile Include="GameObjects\Characters\Controlled\PlayerAdmin.cs" />
|
||||
<Compile Include="GameObjects\Characters\Controlled\PlayerBasic.cs" />
|
||||
<Compile Include="GameObjects\Environment\Door.cs" />
|
||||
<Compile Include="GameObjects\Environment\Realm.cs" />
|
||||
<Compile Include="GameObjects\Environment\Room.cs" />
|
||||
|
@ -82,8 +80,11 @@
|
|||
<Compile Include="Scripting\ScriptEngine.cs" />
|
||||
<Compile Include="Scripting\StartupObject.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<Folder Include="GameObjects\Characters\NPC\" />
|
||||
<None Include="startup.dat">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
|
|
@ -7,7 +7,6 @@ using System.Net.Sockets;
|
|||
using System.Threading;
|
||||
|
||||
using MudEngine.GameObjects.Characters;
|
||||
using MudEngine.GameObjects.Characters.Controlled;
|
||||
|
||||
/* Usage:
|
||||
* Server MUDServer = new Server();
|
||||
|
@ -35,7 +34,7 @@ namespace MudEngine.Networking
|
|||
}
|
||||
server.CleanUp();
|
||||
}
|
||||
public bool InitializeTCP(int port, ref List<PlayerBasic> pbs)
|
||||
public bool InitializeTCP(int port, ref List<BaseCharacter> pbs)
|
||||
{
|
||||
if (stage != 0)
|
||||
return false;
|
||||
|
@ -50,7 +49,7 @@ namespace MudEngine.Networking
|
|||
stage++;
|
||||
return true;
|
||||
}
|
||||
public bool InitializeUDP(int port, ref List<PlayerBasic> pbs)
|
||||
public bool InitializeUDP(int port, ref List<BaseCharacter> pbs)
|
||||
{
|
||||
if (stage != 0)
|
||||
return false;
|
||||
|
@ -138,7 +137,7 @@ namespace MudEngine.Networking
|
|||
private ServerSocket server;
|
||||
private int stage;
|
||||
|
||||
List<PlayerBasic> players;
|
||||
List<BaseCharacter> players;
|
||||
|
||||
// TCP Stuff:
|
||||
private ClientSocket[] clients;
|
||||
|
|
|
@ -9,6 +9,7 @@ using System.IO;
|
|||
using System.Text;
|
||||
using System.Reflection;
|
||||
|
||||
using MudEngine.GameObjects;
|
||||
|
||||
namespace MudEngine.Scripting
|
||||
{
|
||||
|
@ -97,7 +98,11 @@ namespace MudEngine.Scripting
|
|||
Directory.Delete("temp", true);
|
||||
|
||||
Directory.CreateDirectory("temp");
|
||||
string source = "namespace MudScripts\n{\n}";
|
||||
|
||||
//Setup the additional sourcecode that's needed in the script.
|
||||
string[] usingStatements = new string[] { "using System;", "using MudEngine.GameObjects;", "using MudEngine.FileSystem;" };
|
||||
string source = "\nnamespace MudScripts{\n}";
|
||||
|
||||
foreach (string script in scripts)
|
||||
{
|
||||
string tempPath = "temp";
|
||||
|
@ -108,6 +113,9 @@ namespace MudEngine.Scripting
|
|||
StreamReader sr = new StreamReader(fr, System.Text.Encoding.Default);
|
||||
|
||||
string content = sr.ReadToEnd();
|
||||
foreach (string statement in usingStatements)
|
||||
source = source.Insert(0, statement);
|
||||
|
||||
source = source.Insert(source.Length - 1, content);
|
||||
sw.Write(source);
|
||||
sr.Close();
|
||||
|
@ -135,7 +143,7 @@ namespace MudEngine.Scripting
|
|||
results = codeProvider.CompileAssemblyFromFile(param, scripts);
|
||||
|
||||
//Delete the temp folder
|
||||
Directory.Delete("temp", true);
|
||||
//Directory.Delete("temp", true);
|
||||
ScriptPath = oldPath;
|
||||
|
||||
//if we encountered errors we need to log them to our ErrorMessages property
|
||||
|
|
1
MudEngine/startup.dat
Normal file
1
MudEngine/startup.dat
Normal file
|
@ -0,0 +1 @@
|
|||
PlayerClass=P
|
Loading…
Add table
Add a link
Reference in a new issue