MudEngine:
- Fixed the ScriptEngine and CommandEngine not loading Custom game commands from scripts. - BaseCharacter's Create, Initialize, Send and FlushConsole are now overridable via scripts. - Invalid commands are now printed to the player "Invalid Command." MudGame: - Added CommandSay script that adds primitive chatting support. Only players within the same Room can see the messages. - Renamed California script to WorldCalifornia - Renamed MyGame script to EarthGame. - Added Clear command script for and Say command script for showing how to build custom commands for use with the game. The commands can only be added server-side, but used client-side.
This commit is contained in:
parent
bbd411fdd1
commit
93a27ca75f
10 changed files with 72 additions and 19 deletions
10
MudGame/Scripts/CommandClear.cs
Normal file
10
MudGame/Scripts/CommandClear.cs
Normal file
|
@ -0,0 +1,10 @@
|
|||
public class CommandClear : IGameCommand
|
||||
{
|
||||
public Boolean Override { get; set; }
|
||||
public String Name { get; set; }
|
||||
|
||||
public void Execute(String command, BaseCharacter player)
|
||||
{
|
||||
player.FlushConsole();
|
||||
}
|
||||
}
|
26
MudGame/Scripts/CommandSay.cs
Normal file
26
MudGame/Scripts/CommandSay.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
public class CommandSay : IGameCommand
|
||||
{
|
||||
public Boolean Override { get; set; }
|
||||
public String Name { get; set; }
|
||||
|
||||
public void Execute(String command, BaseCharacter player)
|
||||
{
|
||||
if (command.Length <= 4) //user only sent 'Say' or 'Say '
|
||||
{
|
||||
return; //nothing to say, don't say anything at all.
|
||||
}
|
||||
|
||||
String message = command.Substring("Say ".Length);
|
||||
|
||||
foreach (BaseCharacter p in player.ActiveGame.PlayerCollection)
|
||||
{
|
||||
if ((p.CurrentRoom.Realm == player.CurrentRoom.Realm) && (p.CurrentRoom.Zone == player.CurrentRoom.Zone) && (p.CurrentRoom.Filename == player.CurrentRoom.Filename))
|
||||
{
|
||||
p.Send(player.Name + " says: " + message);
|
||||
}
|
||||
}
|
||||
|
||||
player.Send("You say: " + message);
|
||||
|
||||
}
|
||||
}
|
20
MudGame/Scripts/EarthGame.cs
Normal file
20
MudGame/Scripts/EarthGame.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
public class EarthGame : Game
|
||||
{
|
||||
public WorldCalifornia Cali;
|
||||
|
||||
public EarthGame()
|
||||
: base()
|
||||
{
|
||||
GameTitle = "Planet Earth MUD";
|
||||
Story = "The planet Earth reproduced in a MUD for your playing enjoyment!";
|
||||
IsMultiplayer = true;
|
||||
|
||||
CompanyName = "Mud Designer Team";
|
||||
Website = "Visit Http://MudDesigner.Codeplex.com for the latest News, Documentation and Releases.";
|
||||
Version = "Example Game Version 1.0";
|
||||
MaximumPlayers = 5000;
|
||||
|
||||
Cali = new WorldCalifornia(this);
|
||||
Cali.Create();
|
||||
}
|
||||
}
|
50
MudGame/Scripts/WorldCalifornia.cs
Normal file
50
MudGame/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