muddesigner/MudEngine/WinPC_Engine/GameScripts/SampleGame.cs
Scionwest_cp 8639403255 DataPaths now have values for the games Root directory and Script directory.
DataPath class is now completed and includes a new SetExtension() method for setting game object file extensions.
Scripting support fully implemented.
StandardGame now contains a Initialize() method for compiling scripts and searching for sub-classes of StandardGame
Server app will now use a Scripted game class instead of the default StandardGame if one is present.
StandardGame.Start() is now virtual so child classes can override it.
Sample Game script created to show how to create a custom game script, including how to setup the game and create Rooms pragamatically.
ScriptFactory has a new method for searching all scripts and scripts that inherit from a specified class.
Renamed all of the Command scripts.  They no longer start with 'Command'.  Example: "CommandSay" has now become "Say".  There is no need to preceed the command name with the word "Command" anymore.
2012-03-05 20:30:54 -08:00

56 lines
2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MudEngine.Game;
using MudEngine.DAL;
using MudEngine.Game.Environment;
using MudEngine.Game;
namespace MudEngine.GameScripts
{
public class SampleGame : StandardGame
{
public SampleGame(String name)
: base(name)
{
this.Name = "Sample Mud Game";
this.Debugging = true;
this.Description = "A sample MUD game created using the Mud Designer engine.";
this.Website = "http://muddesigner.codeplex.com";
}
public override Boolean Start(Int32 maxPlayers, Int32 maxQueueSize)
{
this.Server.ServerOwner = "Admin";
//Quick demonstration on how to create the initial starting room for new players.
this.World.CreateRealm("Azeroth", "Starting Realm for beginning players");
Zone z = this.World.GetRealm("Azeroth").CreateZone("Bedlam", "Initial Zone for new players.");
Room bedroom = z.CreateRoom("Bedroom", "This is your bedroom.");
Room hallway = z.CreateRoom("Hallway", "This is the hallway.");
//Save if the result of the Linkage.
Boolean linked = bedroom.LinkRooms(AvailableTravelDirections.West, hallway);
//Call our parent Start() method which will start the world and server
//along with compile all of our commands and scripts.
Boolean startOK = base.Start(maxPlayers, maxQueueSize);
//If the parent started ok and our rooms were linked together
//Set the starting location as our new room
if (startOK && linked)
{
this.World.StartLocation = bedroom;
return true;
}
//Otherwise return false and prevent the game from running.
else
{
this.Enabled = false;
return false;
}
}
}
}