MudCompiler:
- Updated to work with ScriptingEngine changes. MudEngine: - Game.PlayerCollection changed to a List<>. Server obtains a array version of it within Server.initialize() via players = pbs.ToArray(). - All BaseObject classes now require a reference to the Game and contain a property called ActiveGame. - Player.Game removed and now uses it's parent objects ActiveGame property. - Player.Role property added. Uses the new SecurityRoles enum that specifies what level of access the player has. - ScriptEngine now loads all libraries found within the specified ScriptsPath directory, instances the scripts and places them into a collection. - Custom character script instancing is now supported, but not fully implemented throughout the engine. They can be loaded, but not used during runtime at this time.
This commit is contained in:
parent
631ce62e73
commit
9b023a2092
24 changed files with 127 additions and 74 deletions
|
@ -46,7 +46,8 @@ namespace MUDCompiler
|
||||||
|
|
||||||
static void CompileScripts()
|
static void CompileScripts()
|
||||||
{
|
{
|
||||||
ScriptEngine se = new ScriptEngine(ScriptEngine.ScriptTypes.SourceFiles);
|
MudEngine.GameManagement.Game game = new MudEngine.GameManagement.Game();
|
||||||
|
ScriptEngine se = new ScriptEngine(game, ScriptEngine.ScriptTypes.SourceFiles);
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
Console.WriteLine("Compiling...");
|
Console.WriteLine("Compiling...");
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace MudEngine.Commands
|
||||||
|
|
||||||
public CommandResults Execute(string command, BaseCharacter player)
|
public CommandResults Execute(string command, BaseCharacter player)
|
||||||
{
|
{
|
||||||
player.Game.Shutdown();
|
player.ActiveGame.Shutdown();
|
||||||
|
|
||||||
return new CommandResults();
|
return new CommandResults();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,12 +23,12 @@ namespace MudEngine.Commands
|
||||||
|
|
||||||
public CommandResults Execute(string command, BaseCharacter player)
|
public CommandResults Execute(string command, BaseCharacter player)
|
||||||
{
|
{
|
||||||
if (player.IsAdmin)
|
if (player.Role == SecurityRoles.Admin)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < player.Game.PlayerCollection./*Count*/Length; i++)
|
for (int i = 0; i < player.ActiveGame.PlayerCollection.Count/*Length*/; i++)
|
||||||
player.Game.PlayerCollection[i].Save(player.Game.PlayerCollection[i].Name + ".dat");
|
player.ActiveGame.PlayerCollection[i].Save(player.ActiveGame.PlayerCollection[i].Name + ".dat");
|
||||||
player.Game.Server.EndServer();
|
player.ActiveGame.Server.EndServer();
|
||||||
player.Game.Server.Initialize(555, ref player.Game.PlayerCollection);
|
player.ActiveGame.Server.Initialize(555, ref player.ActiveGame.PlayerCollection);
|
||||||
return new CommandResults("Server Restarted.");
|
return new CommandResults("Server Restarted.");
|
||||||
}
|
}
|
||||||
return new CommandResults("Access Denied.");
|
return new CommandResults("Access Denied.");
|
||||||
|
|
|
@ -178,9 +178,9 @@ namespace MudEngine.GameManagement
|
||||||
public Game()
|
public Game()
|
||||||
{
|
{
|
||||||
CurrencyList = new List<Currency>();
|
CurrencyList = new List<Currency>();
|
||||||
scriptEngine = new Scripting.ScriptEngine();
|
scriptEngine = new Scripting.ScriptEngine(this);
|
||||||
RealmCollection = new List<Realm>();
|
RealmCollection = new List<Realm>();
|
||||||
//PlayerCollection = new List<BaseCharacter>();
|
PlayerCollection = new List<BaseCharacter>();
|
||||||
|
|
||||||
GameTitle = "New Game";
|
GameTitle = "New Game";
|
||||||
_Filename = "Game.xml";
|
_Filename = "Game.xml";
|
||||||
|
@ -202,7 +202,7 @@ namespace MudEngine.GameManagement
|
||||||
//Loads the MudEngine Game Commands
|
//Loads the MudEngine Game Commands
|
||||||
CommandEngine.LoadBaseCommands();
|
CommandEngine.LoadBaseCommands();
|
||||||
//Loads any commands found in the users custom scripts library loaded by the script engine.
|
//Loads any commands found in the users custom scripts library loaded by the script engine.
|
||||||
CommandEngine.LoadCommandLibrary(scriptEngine.Assembly);
|
//CommandEngine.LoadCommandLibrary(scriptEngine.Assembly);
|
||||||
|
|
||||||
//Ensure custom commands are loaded until everything is fleshed out.
|
//Ensure custom commands are loaded until everything is fleshed out.
|
||||||
if (Game.IsDebug)
|
if (Game.IsDebug)
|
||||||
|
@ -236,6 +236,9 @@ namespace MudEngine.GameManagement
|
||||||
//Start the Telnet server
|
//Start the Telnet server
|
||||||
if (IsMultiplayer)
|
if (IsMultiplayer)
|
||||||
this.StartServer();
|
this.StartServer();
|
||||||
|
else
|
||||||
|
//TODO: Need to load a previously saved character or allow for creation of one by user.
|
||||||
|
//PlayerCollection.Add(new BaseCharacter(this)); //If this is single player, then add a new character to the game.
|
||||||
|
|
||||||
IsRunning = true;
|
IsRunning = true;
|
||||||
|
|
||||||
|
@ -310,8 +313,8 @@ namespace MudEngine.GameManagement
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: This should be internal only; C# property using get; internal set; so only MudEngine.dll may edit this collection
|
//TODO: This should be internal only; C# property using get; internal set; so only MudEngine.dll may edit this collection
|
||||||
//public List<BaseCharacter> PlayerCollection;
|
public List<BaseCharacter> PlayerCollection;
|
||||||
public BaseCharacter[] PlayerCollection;
|
//public BaseCharacter[] PlayerCollection;
|
||||||
|
|
||||||
public MudEngine.Networking.Server Server { get; internal set; }
|
public MudEngine.Networking.Server Server { get; internal set; }
|
||||||
public ProtocolType ServerType = ProtocolType.Tcp;
|
public ProtocolType ServerType = ProtocolType.Tcp;
|
||||||
|
@ -322,10 +325,9 @@ namespace MudEngine.GameManagement
|
||||||
|
|
||||||
private void StartServer()
|
private void StartServer()
|
||||||
{
|
{
|
||||||
|
//This is handled by the Game() Constructor
|
||||||
//PlayerCollection = new List<BaseCharacter>(MaximumPlayers);
|
//PlayerCollection = new List<BaseCharacter>(MaximumPlayers);
|
||||||
PlayerCollection = new BaseCharacter[MaximumPlayers];
|
PlayerCollection.Add(new BaseCharacter(this));
|
||||||
for (int i = 0; i < MaximumPlayers; i++)
|
|
||||||
PlayerCollection[i] = new BaseCharacter(this);
|
|
||||||
Server = new Networking.Server();
|
Server = new Networking.Server();
|
||||||
Server.Initialize(ServerPort, ref PlayerCollection);
|
Server.Initialize(ServerPort, ref PlayerCollection);
|
||||||
Server.Start();
|
Server.Start();
|
||||||
|
|
14
MudEngine/GameManagement/SecurityRoles.cs
Normal file
14
MudEngine/GameManagement/SecurityRoles.cs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace MudEngine.GameManagement
|
||||||
|
{
|
||||||
|
public enum SecurityRoles
|
||||||
|
{
|
||||||
|
Admin,
|
||||||
|
Immortal,
|
||||||
|
GM,
|
||||||
|
QuestGiver,
|
||||||
|
Player,
|
||||||
|
NPC
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,6 +22,10 @@ namespace MudEngine.GameObjects
|
||||||
|
|
||||||
private List<Items.BaseItem> Items { get; set; }
|
private List<Items.BaseItem> Items { get; set; }
|
||||||
|
|
||||||
|
public Bag(GameManagement.Game game) : base(game)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public void Add(BaseItem item)
|
public void Add(BaseItem item)
|
||||||
{
|
{
|
||||||
if (Items.Count < Size)
|
if (Items.Count < Size)
|
||||||
|
|
|
@ -9,6 +9,7 @@ using System.IO;
|
||||||
|
|
||||||
//MUD Engine
|
//MUD Engine
|
||||||
using MudEngine.FileSystem;
|
using MudEngine.FileSystem;
|
||||||
|
using MudEngine.GameManagement;
|
||||||
|
|
||||||
namespace MudEngine.GameObjects
|
namespace MudEngine.GameObjects
|
||||||
{
|
{
|
||||||
|
@ -99,15 +100,17 @@ namespace MudEngine.GameObjects
|
||||||
|
|
||||||
private string _Filename = "";
|
private string _Filename = "";
|
||||||
private string _Name = "";
|
private string _Name = "";
|
||||||
|
internal Game ActiveGame { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes the base object
|
/// Initializes the base object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BaseObject()
|
public BaseObject(Game game)
|
||||||
{
|
{
|
||||||
Script = "";
|
Script = "";
|
||||||
_Name = "New " + this.GetType().Name;
|
_Name = "New " + this.GetType().Name;
|
||||||
_Filename = _Name + "." + this.GetType().Name;
|
_Filename = _Name + "." + this.GetType().Name;
|
||||||
|
ActiveGame = game;
|
||||||
|
|
||||||
this.Feel = "You feel nothing.";
|
this.Feel = "You feel nothing.";
|
||||||
this.Listen = "You hear nothing of interest.";
|
this.Listen = "You hear nothing of interest.";
|
||||||
|
|
|
@ -32,21 +32,16 @@ namespace MudEngine.GameObjects.Characters
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or Sets if this user has Admin privileges or not.
|
/// Gets or Sets if this user has Admin privileges or not.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Boolean IsAdmin { get; private set; }
|
public SecurityRoles Role { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or Sets if this player is active.
|
/// Gets or Sets if this player is active.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Boolean IsActive { get; private set; }
|
public Boolean IsActive { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
public BaseCharacter(Game game) : base(game)
|
||||||
/// Gets a reference to the currently running game.
|
|
||||||
/// </summary>
|
|
||||||
public Game Game { get; private set; }
|
|
||||||
|
|
||||||
public BaseCharacter(Game game)
|
|
||||||
{
|
{
|
||||||
Game = game;
|
ActiveGame = game;
|
||||||
IsActive = false;
|
IsActive = false;
|
||||||
CurrentRoom = game.InitialRealm.InitialZone.InitialRoom;
|
CurrentRoom = game.InitialRealm.InitialZone.InitialRoom;
|
||||||
}
|
}
|
||||||
|
@ -99,7 +94,7 @@ namespace MudEngine.GameObjects.Characters
|
||||||
|
|
||||||
internal void Initialize()
|
internal void Initialize()
|
||||||
{
|
{
|
||||||
CurrentRoom = Game.InitialRealm.InitialZone.InitialRoom;
|
CurrentRoom = ActiveGame.InitialRealm.InitialZone.InitialRoom;
|
||||||
|
|
||||||
IsActive = true;
|
IsActive = true;
|
||||||
}
|
}
|
||||||
|
@ -116,7 +111,7 @@ namespace MudEngine.GameObjects.Characters
|
||||||
// convert the result back to bytes and send it back
|
// convert the result back to bytes and send it back
|
||||||
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
|
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
|
||||||
Send(encoding.GetBytes(str));
|
Send(encoding.GetBytes(str));
|
||||||
if (!Game.IsRunning)
|
if (!ActiveGame.IsRunning)
|
||||||
Clear();
|
Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace MudEngine.GameObjects
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Currency()
|
public Currency(GameManagement.Game game) : base(game)
|
||||||
{
|
{
|
||||||
this.Name = "New Currency";
|
this.Name = "New Currency";
|
||||||
this.Value = 100;
|
this.Value = 100;
|
||||||
|
|
|
@ -52,11 +52,11 @@ namespace MudEngine.GameObjects.Environment
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Room DepartureRoom { get; set; }
|
public Room DepartureRoom { get; set; }
|
||||||
|
|
||||||
public Door()
|
public Door(GameManagement.Game game)
|
||||||
{
|
{
|
||||||
LevelRequirement = 0;
|
LevelRequirement = 0;
|
||||||
IsLocked = false;
|
IsLocked = false;
|
||||||
RequiredKey = new BaseItem();
|
RequiredKey = new BaseItem(game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace MudEngine.GameObjects.Environment
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Zone InitialZone { get; private set; }
|
public Zone InitialZone { get; private set; }
|
||||||
|
|
||||||
public Realm()
|
public Realm(GameManagement.Game game) : base(game)
|
||||||
{
|
{
|
||||||
ZoneCollection = new List<Zone>();
|
ZoneCollection = new List<Zone>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ namespace MudEngine.GameObjects.Environment
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Room()
|
public Room(Game game) :base(game)
|
||||||
{
|
{
|
||||||
Doorways = new List<Door>();
|
Doorways = new List<Door>();
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ namespace MudEngine.GameObjects.Environment
|
||||||
[Category("Environment Information")]
|
[Category("Environment Information")]
|
||||||
public Room InitialRoom { get; private set; }
|
public Room InitialRoom { get; private set; }
|
||||||
|
|
||||||
public Zone()
|
public Zone(GameManagement.Game game) : base(game)
|
||||||
{
|
{
|
||||||
RoomCollection = new List<Room>();
|
RoomCollection = new List<Room>();
|
||||||
IsSafe = false;
|
IsSafe = false;
|
||||||
|
@ -136,7 +136,7 @@ namespace MudEngine.GameObjects.Environment
|
||||||
|
|
||||||
public void LinkRooms(AvailableTravelDirections departureDirection, Room arrivalRoom, Room departureRoom, Int32 requiredLevel, Boolean isLocked, BaseItem requiredKey)
|
public void LinkRooms(AvailableTravelDirections departureDirection, Room arrivalRoom, Room departureRoom, Int32 requiredLevel, Boolean isLocked, BaseItem requiredKey)
|
||||||
{
|
{
|
||||||
Door door = new Door();
|
Door door = new Door(ActiveGame);
|
||||||
door.ArrivalRoom = arrivalRoom;
|
door.ArrivalRoom = arrivalRoom;
|
||||||
door.DepartureRoom = departureRoom;
|
door.DepartureRoom = departureRoom;
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ namespace MudEngine.GameObjects.Environment
|
||||||
departureRoom.Doorways.Add(door);
|
departureRoom.Doorways.Add(door);
|
||||||
|
|
||||||
//Now we set up the door for the opposite room.
|
//Now we set up the door for the opposite room.
|
||||||
door = new Door();
|
door = new Door(ActiveGame);
|
||||||
|
|
||||||
door.DepartureRoom = arrivalRoom;
|
door.DepartureRoom = arrivalRoom;
|
||||||
door.ArrivalRoom = departureRoom;
|
door.ArrivalRoom = departureRoom;
|
||||||
|
|
|
@ -8,6 +8,8 @@ namespace MudEngine.GameObjects.Items
|
||||||
{
|
{
|
||||||
public class BaseItem : BaseObject
|
public class BaseItem : BaseObject
|
||||||
{
|
{
|
||||||
|
public BaseItem(GameManagement.Game game) : base(game)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core">
|
<Reference Include="System.Core">
|
||||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
|
@ -61,6 +62,7 @@
|
||||||
<Compile Include="FileSystem\XmlSerialization.cs" />
|
<Compile Include="FileSystem\XmlSerialization.cs" />
|
||||||
<Compile Include="GameManagement\Game.cs" />
|
<Compile Include="GameManagement\Game.cs" />
|
||||||
<Compile Include="GameManagement\Log.cs" />
|
<Compile Include="GameManagement\Log.cs" />
|
||||||
|
<Compile Include="GameManagement\SecurityRoles.cs" />
|
||||||
<Compile Include="GameObjects\Bag.cs" />
|
<Compile Include="GameObjects\Bag.cs" />
|
||||||
<Compile Include="GameObjects\BaseObject.cs" />
|
<Compile Include="GameObjects\BaseObject.cs" />
|
||||||
<Compile Include="GameObjects\Characters\BaseCharacter.cs" />
|
<Compile Include="GameObjects\Characters\BaseCharacter.cs" />
|
||||||
|
|
|
@ -30,15 +30,15 @@ namespace MudEngine.Networking
|
||||||
stage = 0;
|
stage = 0;
|
||||||
port = 0;
|
port = 0;
|
||||||
}
|
}
|
||||||
public bool Initialize(int p, ref /*List<BaseCharacter>*/BaseCharacter[] pbs)
|
public bool Initialize(int p, ref List<BaseCharacter>/*BaseCharacter[]*/ pbs)
|
||||||
{
|
{
|
||||||
if (stage != 0)
|
if (stage != 0)
|
||||||
return false;
|
return false;
|
||||||
if (p <= 0)
|
if (p <= 0)
|
||||||
return false;
|
return false;
|
||||||
port = p;
|
port = p;
|
||||||
clientThreads = new Thread[pbs./*Capacity*/Length];
|
clientThreads = new Thread[pbs.Capacity/*Length*/];
|
||||||
players = pbs;
|
players = pbs.ToArray();
|
||||||
stage++;
|
stage++;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,12 @@ namespace MudEngine.Scripting
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsActive { get; set; }
|
public bool IsActive { get; set; }
|
||||||
|
|
||||||
|
public GameObject(object instance, string name)
|
||||||
|
{
|
||||||
|
Instance = instance;
|
||||||
|
Name = name;
|
||||||
|
}
|
||||||
|
|
||||||
public object CreateObject()
|
public object CreateObject()
|
||||||
{
|
{
|
||||||
return Instance;
|
return Instance;
|
||||||
|
|
|
@ -30,8 +30,15 @@ namespace MudEngine.Scripting
|
||||||
public string InstallPath { get; private set; }
|
public string InstallPath { get; private set; }
|
||||||
public GameObjectCollection ObjectCollection { get; private set; }
|
public GameObjectCollection ObjectCollection { get; private set; }
|
||||||
|
|
||||||
public Assembly Assembly { get { return _ScriptAssembly; } private set { _ScriptAssembly = value; } }
|
/// <summary>
|
||||||
|
/// Collection of currently loaded objects created from compiled scripts
|
||||||
|
/// </summary>
|
||||||
|
public List<GameObject> GameObjects { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Collection of currently loaded game commecnts that can be used. These must be compiled scripts inheriting from IGameCommand
|
||||||
|
/// </summary>
|
||||||
|
public List<IGameCommand> GameCommands { get; private set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// File Extension for the scripts
|
/// File Extension for the scripts
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -59,11 +66,13 @@ namespace MudEngine.Scripting
|
||||||
|
|
||||||
private ScriptTypes _ScriptTypes;
|
private ScriptTypes _ScriptTypes;
|
||||||
private Assembly _ScriptAssembly;
|
private Assembly _ScriptAssembly;
|
||||||
|
private List<Assembly> _AssemblyCollection;
|
||||||
private string[] _ErrorMessages;
|
private string[] _ErrorMessages;
|
||||||
|
Game _Game;
|
||||||
|
|
||||||
public ScriptEngine() : this(ScriptTypes.Assembly)
|
public ScriptEngine(Game game) : this(game, ScriptTypes.Assembly)
|
||||||
{
|
{
|
||||||
//Empty constructor. Only here for end-user ease of use. ScriptEngine(Game, ScriptTypes) is called from here.
|
_Game = game;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,15 +80,19 @@ namespace MudEngine.Scripting
|
||||||
/// Instances a new copy of the script engine
|
/// Instances a new copy of the script engine
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="scriptTypes">Tells the engine what kind of scripts will be loaded. Source File or assembly based.</param>
|
/// <param name="scriptTypes">Tells the engine what kind of scripts will be loaded. Source File or assembly based.</param>
|
||||||
public ScriptEngine(ScriptTypes scriptTypes)
|
public ScriptEngine(Game game, ScriptTypes scriptTypes)
|
||||||
{
|
{
|
||||||
//Initialize our engine fields
|
//Initialize our engine fields
|
||||||
_ScriptTypes = scriptTypes;
|
_ScriptTypes = scriptTypes;
|
||||||
ScriptExtension = ".cs";
|
ScriptExtension = ".cs";
|
||||||
|
|
||||||
//Get our current install path
|
//Get our current install path
|
||||||
ScriptPath = Environment.CurrentDirectory;
|
ScriptPath = Path.Combine(Environment.CurrentDirectory, "Scripts");
|
||||||
InstallPath = Environment.CurrentDirectory;
|
InstallPath = Environment.CurrentDirectory;
|
||||||
|
GameObjects = new List<GameObject>();
|
||||||
|
_AssemblyCollection = new List<Assembly>();
|
||||||
|
|
||||||
|
_Game = game;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -183,26 +196,48 @@ namespace MudEngine.Scripting
|
||||||
{
|
{
|
||||||
InitializeSourceFiles();
|
InitializeSourceFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (Assembly assembly in _AssemblyCollection)
|
||||||
|
{
|
||||||
|
foreach (Type t in assembly.GetTypes())
|
||||||
|
{
|
||||||
|
if (t.BaseType == null)
|
||||||
|
continue;
|
||||||
|
if (t.BaseType.Name == "BaseObject")
|
||||||
|
{
|
||||||
|
GameObjects.Add(new GameObject(Activator.CreateInstance(t, new object[] {_Game}), t.Name));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (t.BaseType.Name == "BaseCharacter")
|
||||||
|
{
|
||||||
|
GameObject obj = new GameObject(Activator.CreateInstance(t, new object[] {_Game}), t.Name);
|
||||||
|
GameObjects.Add(obj);
|
||||||
|
obj.GetProperty().CurrentRoom = _Game.InitialRealm.InitialZone.InitialRoom;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeAssembly()
|
private void InitializeAssembly()
|
||||||
{
|
{
|
||||||
if (!System.IO.File.Exists("Scripts.dll"))
|
if (!Directory.Exists(ScriptPath))
|
||||||
{
|
{
|
||||||
ErrorMessage = "Failed to load Script Assembly!";
|
Log.Write("Supplied script path does not exist! No scripts loaded.");
|
||||||
Log.Write(ErrorMessage);
|
return;
|
||||||
|
}
|
||||||
|
string[] libraries = Directory.GetFiles(ScriptPath, "*.dll", SearchOption.AllDirectories);
|
||||||
|
|
||||||
|
if (libraries.Length == 0)
|
||||||
|
{
|
||||||
|
Log.Write("Failed to load Script Assembly!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_ScriptAssembly = Assembly.LoadFile(Path.Combine(InstallPath, "Scripts.dll"));
|
foreach (string library in libraries)
|
||||||
|
_AssemblyCollection.Add(Assembly.LoadFile(library));
|
||||||
|
|
||||||
foreach (Type type in _ScriptAssembly.GetTypes())
|
_AssemblyCollection.Add(Assembly.GetExecutingAssembly());
|
||||||
{
|
|
||||||
if (type.BaseType == typeof(BaseCharacter))
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeSourceFiles()
|
private void InitializeSourceFiles()
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace MUDGame
|
||||||
internal Zeroth(Game game)
|
internal Zeroth(Game game)
|
||||||
{
|
{
|
||||||
this.game = game;
|
this.game = game;
|
||||||
realm = new Realm();
|
realm = new Realm(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void BuildZeroth()
|
internal void BuildZeroth()
|
||||||
|
@ -31,7 +31,7 @@ namespace MUDGame
|
||||||
private void BuildHome()
|
private void BuildHome()
|
||||||
{
|
{
|
||||||
//Build Zones
|
//Build Zones
|
||||||
Zone zone = new Zone();
|
Zone zone = new Zone(game);
|
||||||
zone.Name = "Home";
|
zone.Name = "Home";
|
||||||
zone.Description = "Your home is small and does not contain many items, but it's still your home and someplace you can relax after your battles.";
|
zone.Description = "Your home is small and does not contain many items, but it's still your home and someplace you can relax after your battles.";
|
||||||
zone.IsSafe = true;
|
zone.IsSafe = true;
|
||||||
|
@ -40,7 +40,7 @@ namespace MUDGame
|
||||||
zone.Realm = realm.Name;
|
zone.Realm = realm.Name;
|
||||||
realm.AddZone(zone);
|
realm.AddZone(zone);
|
||||||
|
|
||||||
Room bedroom = new Room();
|
Room bedroom = new Room(game);
|
||||||
bedroom.Name = "Bedroom";
|
bedroom.Name = "Bedroom";
|
||||||
bedroom.Description = "This is your bedroom, it's small but comfortable. You have a bed, a book shelf and a rug on the floor.\nYou may walk to the WEST to find you Closet.";
|
bedroom.Description = "This is your bedroom, it's small but comfortable. You have a bed, a book shelf and a rug on the floor.\nYou may walk to the WEST to find you Closet.";
|
||||||
bedroom.Zone = zone.Name;
|
bedroom.Zone = zone.Name;
|
||||||
|
@ -48,7 +48,7 @@ namespace MUDGame
|
||||||
bedroom.IsInitialRoom = true;
|
bedroom.IsInitialRoom = true;
|
||||||
zone.AddRoom(bedroom);
|
zone.AddRoom(bedroom);
|
||||||
|
|
||||||
Room closet = new Room();
|
Room closet = new Room(game);
|
||||||
closet.Name = "Closet";
|
closet.Name = "Closet";
|
||||||
closet.Description = "Your closet contains clothing and some shoes.\nYou may walk to your EAST to find your Room.";
|
closet.Description = "Your closet contains clothing and some shoes.\nYou may walk to your EAST to find your Room.";
|
||||||
closet.Zone = zone.Name;
|
closet.Zone = zone.Name;
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace MUDGame
|
||||||
player = new BaseCharacter(game);
|
player = new BaseCharacter(game);
|
||||||
//Add the player to the game.
|
//Add the player to the game.
|
||||||
//Note once the server is fully implemented the player will be generated automatically by Game.
|
//Note once the server is fully implemented the player will be generated automatically by Game.
|
||||||
//game.PlayerCollection.Add(player);
|
game.PlayerCollection.Add(player);
|
||||||
|
|
||||||
//Send game info to player
|
//Send game info to player
|
||||||
Console.WriteLine(game.GameTitle);
|
Console.WriteLine(game.GameTitle);
|
||||||
|
|
|
@ -39,28 +39,17 @@ namespace MudServer
|
||||||
game.ServerType = ProtocolType.Tcp;
|
game.ServerType = ProtocolType.Tcp;
|
||||||
game.ServerPort = 555;
|
game.ServerPort = 555;
|
||||||
game.MaximumPlayers = 1000;
|
game.MaximumPlayers = 1000;
|
||||||
|
game.PlayerCollection.Add(serverAdmin);
|
||||||
Game.IsDebug = true;
|
Game.IsDebug = true;
|
||||||
|
|
||||||
game.Start();
|
game.Start();
|
||||||
string command = "";
|
|
||||||
|
|
||||||
while (game.IsRunning)
|
while (game.IsRunning)
|
||||||
{
|
|
||||||
if (!Console.KeyAvailable)
|
|
||||||
{
|
{
|
||||||
Console.Write(Log.GetMessages());
|
Console.Write(Log.GetMessages());
|
||||||
Log.FlushMessages();
|
Log.FlushMessages();
|
||||||
System.Threading.Thread.Sleep(1);
|
System.Threading.Thread.Sleep(1);
|
||||||
}
|
}
|
||||||
//TODO: Fix Me D:
|
|
||||||
else if (Console.ReadKey().Key == ConsoleKey.Enter)
|
|
||||||
CommandEngine.ExecuteCommand(command, serverAdmin);
|
|
||||||
else if (Console.ReadKey().Key == ConsoleKey.Backspace)
|
|
||||||
Log.Write("Backspace is not currently supported :(");
|
|
||||||
else
|
|
||||||
command += Console.ReadKey().KeyChar;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
BIN
MudServer/bin/Debug/Scripts/Scripts.dll
Normal file
BIN
MudServer/bin/Debug/Scripts/Scripts.dll
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue