Initial Check-in for Alpha 2.0 source code.
Includes working Telnet server, working command engine and Character code.
This commit is contained in:
parent
224f754514
commit
3d8051c995
28 changed files with 1495 additions and 0 deletions
30
MudEngine/WinPC_Engine/GameScripts/BaseScript.cs
Normal file
30
MudEngine/WinPC_Engine/GameScripts/BaseScript.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MudEngine.GameScripts
|
||||
{
|
||||
public class BaseScript
|
||||
{
|
||||
public String Name { get; set; }
|
||||
|
||||
public String ID { get; set; }
|
||||
|
||||
public String Description { get; set; }
|
||||
|
||||
public BaseScript(String name, String description)
|
||||
{
|
||||
this.ID = Guid.NewGuid().ToString();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (String.IsNullOrEmpty(this.Name))
|
||||
return this.GetType().Name + " without Name";
|
||||
else
|
||||
return this.Name;
|
||||
}
|
||||
}
|
||||
}
|
47
MudEngine/WinPC_Engine/GameScripts/Commands/CommandSay.cs
Normal file
47
MudEngine/WinPC_Engine/GameScripts/Commands/CommandSay.cs
Normal file
|
@ -0,0 +1,47 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using MudEngine.Core.Interface;
|
||||
using MudEngine.Game;
|
||||
using MudEngine.Game.Characters;
|
||||
using MudEngine.Networking;
|
||||
|
||||
namespace MudEngine.GameScripts.Commands
|
||||
{
|
||||
public class CommandSay : ICommand
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Description { get; set; }
|
||||
|
||||
public List<string> Help { get; set; }
|
||||
|
||||
public CommandSay()
|
||||
{
|
||||
this.Name = "Say";
|
||||
this.Description = "Chat command that allows objects to communicate.";
|
||||
}
|
||||
|
||||
public void Execute(string command, StandardCharacter character)
|
||||
{
|
||||
//Grab a reference to the character for simplifying access.
|
||||
StandardGame game = character.Game;
|
||||
//Remove the command "Say " from the string so we only have it's message
|
||||
String message = command.Substring(3).Trim();
|
||||
|
||||
//Loop through each character on the server and broadcast the message.
|
||||
//TODO: This should only broadcast to characters that are in the same Environment.
|
||||
foreach (StandardCharacter c in ConnectionManager.Connections)
|
||||
{
|
||||
//Only broadcast this message to those that are not the broadcastor.
|
||||
if (c != character)
|
||||
c.SendMessage(character.ToString() + " says: " + message);
|
||||
}
|
||||
|
||||
//Send a different copy of the message to the broadcastor.
|
||||
character.SendMessage("You say: " + message);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue