MudEngine:
- Script Engine now compiles scripts as C# 4.0 Types instead of 3.5. Scripts can now use Dynamic Types. MudGame: - CommandCreate script added. Provides Admins the ability to create Realms and Zones from within the game during runtime. At the moment Realm creation and Zone creation (and placement within Realms) is implemented.
This commit is contained in:
parent
93a27ca75f
commit
3110b74b58
5 changed files with 187 additions and 1 deletions
|
@ -169,7 +169,7 @@ namespace MudEngine.Scripting
|
||||||
|
|
||||||
//Prepare the compiler.
|
//Prepare the compiler.
|
||||||
Dictionary<String, String> providerOptions = new Dictionary<String,String>();
|
Dictionary<String, String> providerOptions = new Dictionary<String,String>();
|
||||||
providerOptions.Add("CompilerVersion", "v3.5");
|
providerOptions.Add("CompilerVersion", "v4.0");
|
||||||
|
|
||||||
CompilerParameters param = new CompilerParameters(new String[] {"mscorlib.dll", "System.dll", "MudEngine.dll"});
|
CompilerParameters param = new CompilerParameters(new String[] {"mscorlib.dll", "System.dll", "MudEngine.dll"});
|
||||||
param.GenerateExecutable = false;
|
param.GenerateExecutable = false;
|
||||||
|
@ -182,6 +182,7 @@ namespace MudEngine.Scripting
|
||||||
|
|
||||||
//Compile the scripts with the C# CodeProvider
|
//Compile the scripts with the C# CodeProvider
|
||||||
CSharpCodeProvider codeProvider = new CSharpCodeProvider(providerOptions);
|
CSharpCodeProvider codeProvider = new CSharpCodeProvider(providerOptions);
|
||||||
|
//codeProvider.LanguageOptions = LanguageOptions.CaseInsensitive;
|
||||||
CompilerResults results = new CompilerResults(new TempFileCollection());
|
CompilerResults results = new CompilerResults(new TempFileCollection());
|
||||||
scripts = Directory.GetFiles(ScriptPath, "*" + ScriptExtension, SearchOption.AllDirectories);
|
scripts = Directory.GetFiles(ScriptPath, "*" + ScriptExtension, SearchOption.AllDirectories);
|
||||||
results = codeProvider.CompileAssemblyFromFile(param, scripts);
|
results = codeProvider.CompileAssemblyFromFile(param, scripts);
|
||||||
|
|
|
@ -45,6 +45,9 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<None Include="Scripts\CommandCreate.cs">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
<None Include="Scripts\CommandSay.cs">
|
<None Include="Scripts\CommandSay.cs">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
|
127
MudGame/Scripts/CommandCreate.cs
Normal file
127
MudGame/Scripts/CommandCreate.cs
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
public class CommandCreate : IGameCommand
|
||||||
|
{
|
||||||
|
public Boolean Override { get; set; }
|
||||||
|
public String Name { get; set; }
|
||||||
|
|
||||||
|
public void Execute(String command, BaseCharacter player)
|
||||||
|
{
|
||||||
|
if ((player.Role == SecurityRoles.Player) || (player.Role == SecurityRoles.NPC))
|
||||||
|
{
|
||||||
|
return; //Don't let them know this even exists.
|
||||||
|
}
|
||||||
|
|
||||||
|
//Build our create menu.
|
||||||
|
player.Send("");
|
||||||
|
player.Send("Welcome to " + player.ActiveGame.GameTitle + " World Creation Tool.");
|
||||||
|
player.Send("What would you like to create?");
|
||||||
|
player.Send("");
|
||||||
|
player.Send("1: Realm");
|
||||||
|
player.Send("2: Zone");
|
||||||
|
player.Send("3: Room");
|
||||||
|
player.Send("4: Exit Tool");
|
||||||
|
player.Send("Selection: ", false);
|
||||||
|
Int32 selection = Convert.ToInt32(player.ReadInput());
|
||||||
|
|
||||||
|
//Fire off what ever Method we need to, according to the users input.
|
||||||
|
switch (selection)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
CreateRealm(player);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
CreateZone(player);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Creates a Realm.
|
||||||
|
public void CreateRealm(BaseCharacter player)
|
||||||
|
{
|
||||||
|
//Instance a new Realm.
|
||||||
|
Realm realm = new Realm(player.ActiveGame);
|
||||||
|
|
||||||
|
//Get the name of this Realm from the player.
|
||||||
|
player.Send("Realm Name: ", false);
|
||||||
|
realm.Name = player.ReadInput();
|
||||||
|
|
||||||
|
//Check if a Realm with this name already exists.
|
||||||
|
foreach (Realm r in player.ActiveGame.World.RealmCollection)
|
||||||
|
{
|
||||||
|
if (r.Name == realm.Name)
|
||||||
|
{
|
||||||
|
player.Send("Realm already exists!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
player.ActiveGame.World.AddRealm(realm);
|
||||||
|
player.Send(realm.Name + " has been created and added to the world.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateZone(BaseCharacter player)
|
||||||
|
{
|
||||||
|
player.Send("Select which Realm this Zone will belong to.");
|
||||||
|
Boolean isValidRealm = false;
|
||||||
|
String input = "";
|
||||||
|
Realm realm = new Realm(player.ActiveGame);
|
||||||
|
|
||||||
|
while (!isValidRealm)
|
||||||
|
{
|
||||||
|
isValidRealm = true;//Default to true, assume the user entered a valid name.
|
||||||
|
foreach (Realm r in player.ActiveGame.World.RealmCollection)
|
||||||
|
{
|
||||||
|
player.Send(r.Filename + " | ", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
input = player.ReadInput();
|
||||||
|
|
||||||
|
//Ensure it's a valid name, if not then loop back and try again.
|
||||||
|
foreach (Realm r in player.ActiveGame.World.RealmCollection)
|
||||||
|
{
|
||||||
|
if (r.Filename.ToLower() == input.ToLower())
|
||||||
|
{
|
||||||
|
isValidRealm = true;
|
||||||
|
realm = r;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
isValidRealm = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isValidRealm)
|
||||||
|
player.Send("That Realm does not exist! Please try again.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Zone zone = new Zone(player.ActiveGame);
|
||||||
|
realm.AddZone(zone);
|
||||||
|
|
||||||
|
Boolean isValidZone = false;
|
||||||
|
|
||||||
|
while (!isValidZone)
|
||||||
|
{
|
||||||
|
isValidZone = true; //assume the user will enter a correct value.
|
||||||
|
player.Send("Enter a name for this Zone: ", false);
|
||||||
|
String name = player.ReadInput();
|
||||||
|
|
||||||
|
if (String.IsNullOrEmpty(name))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
foreach (Zone z in realm.ZoneCollection)
|
||||||
|
{
|
||||||
|
if (z.Name == name)
|
||||||
|
{
|
||||||
|
isValidZone = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isValidZone)
|
||||||
|
{
|
||||||
|
zone.Name = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
player.Send(zone.Name + " has been created and added to Realm " + realm.Name + ".");
|
||||||
|
}
|
||||||
|
}
|
5
MudGame/bin/Debug/Scripts/..svnbridge/.svnbridge
Normal file
5
MudGame/bin/Debug/Scripts/..svnbridge/.svnbridge
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?><ItemProperties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><Properties><Property><Name>svn:ignore</Name><Value>CommandClear.cs
|
||||||
|
CommandCreate.cs
|
||||||
|
CommandSay.cs
|
||||||
|
EarthGame.cs
|
||||||
|
</Value></Property></Properties></ItemProperties>
|
50
MudGame/bin/Debug/Scripts/WorldCalifornia.cs
Normal file
50
MudGame/bin/Debug/Scripts/WorldCalifornia.cs
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
public class WorldCalifornia
|
||||||
|
{
|
||||||
|
private Game _Game;
|
||||||
|
|
||||||
|
public WorldCalifornia(Game game)
|
||||||
|
{
|
||||||
|
_Game = game;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Create()
|
||||||
|
{
|
||||||
|
//Instance our Realm
|
||||||
|
Realm myRealm = new Realm(_Game);
|
||||||
|
myRealm.Name = "California";
|
||||||
|
myRealm.Description = "The Beaches of California are relaxing and fun to be at.";
|
||||||
|
myRealm.IsInitialRealm = true;
|
||||||
|
_Game.World.AddRealm(myRealm);
|
||||||
|
|
||||||
|
Zone myZone = new Zone(_Game);
|
||||||
|
myZone.Name = "San Diego";
|
||||||
|
myZone.Realm = myRealm.Name;
|
||||||
|
myZone.Description = "San Diego has many attractions, including Sea World!";
|
||||||
|
myZone.IsInitialZone = true;
|
||||||
|
myRealm.AddZone(myZone);
|
||||||
|
|
||||||
|
//Create our HotelRoom
|
||||||
|
Room myRoom = new Room(_Game);
|
||||||
|
myRoom.Name = "Hotel Room B33";
|
||||||
|
myRoom.IsInitialRoom = true;
|
||||||
|
myZone.AddRoom(myRoom);
|
||||||
|
myRoom.DetailedDescription.Add("Your Hotel Room is pretty clean, it is small but not to far off from the beach so you can't complain.");
|
||||||
|
myRoom.DetailedDescription.Add("You can exit your Hotel Room by walking West");
|
||||||
|
|
||||||
|
Room myHallway = new Room(_Game);
|
||||||
|
myHallway.Name = "Hotel Hallway";
|
||||||
|
myHallway.DetailedDescription.Add("The Hotel Hallway is fairly narrow, but there is plenty of room for people to traverse through it.");
|
||||||
|
myHallway.DetailedDescription.Add("Your Hotel Room B33 is to the East.");
|
||||||
|
myHallway.DetailedDescription.Add("Hotel Room B34 is to your West.");
|
||||||
|
myZone.AddRoom(myHallway);
|
||||||
|
myZone.LinkRooms(AvailableTravelDirections.West, myHallway, myRoom);
|
||||||
|
|
||||||
|
Room nextRoom = new Room(_Game);
|
||||||
|
nextRoom.Name = "Hotel Room B34";
|
||||||
|
nextRoom.DetailedDescription.Add("This Hotel Room is pretty dirty, they must not have cleaned it yet.");
|
||||||
|
nextRoom.DetailedDescription.Add("You can exit this room by walking East");
|
||||||
|
myZone.AddRoom(nextRoom);
|
||||||
|
//Link
|
||||||
|
myZone.LinkRooms(AvailableTravelDirections.East, myHallway, nextRoom);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue