Began initial work on the game world. World, Realm, Zone, Room and Doorway classes created but not implemented.

This commit is contained in:
Scionwest_cp 2012-03-04 11:48:11 -08:00
parent b708a63273
commit a3eb1b5fad
18 changed files with 313 additions and 36 deletions

View file

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Reflection; using System.Reflection;
using MudEngine.Core.Interface; using MudEngine.Core.Interfaces;
using MudEngine.Game.Characters; using MudEngine.Game.Characters;
namespace MudEngine.Core namespace MudEngine.Core

View file

@ -5,7 +5,7 @@ using System.Text;
using MudEngine.Game.Characters; using MudEngine.Game.Characters;
namespace MudEngine.Core.Interface namespace MudEngine.Core.Interfaces
{ {
public interface ICommand public interface ICommand
{ {

View file

@ -13,6 +13,7 @@ namespace MudEngine.Game.Characters
Admin, Admin,
Immortal, Immortal,
GM, GM,
Builder,
QuestGiver, QuestGiver,
Player, Player,
NPC NPC

View file

@ -13,6 +13,7 @@ using MudEngine.GameScripts;
using MudEngine.Core.Interfaces; using MudEngine.Core.Interfaces;
using MudEngine.Networking; using MudEngine.Networking;
using MudEngine.Core; using MudEngine.Core;
using MudEngine.Game.Environment;
namespace MudEngine.Game.Characters namespace MudEngine.Game.Characters
{ {
@ -24,7 +25,6 @@ namespace MudEngine.Game.Characters
/// <summary> /// <summary>
/// Gets a reference to the currently active game. /// Gets a reference to the currently active game.
/// </summary> /// </summary>
public StandardGame Game { get; private set; }
public string Filename public string Filename
{ {
@ -87,11 +87,11 @@ namespace MudEngine.Game.Characters
protected CommandSystem Commands { get; private set; } protected CommandSystem Commands { get; private set; }
public Room CurrentRoom { get; private set; }
public StandardCharacter(StandardGame game, String name, String description) public StandardCharacter(StandardGame game, String name, String description)
: base(game, name, description) : base(game, name, description)
{ {
this.Game = game;
this.Role = CharacterRoles.Player; this.Role = CharacterRoles.Player;
//Instance this Characters personal Command System with a copy of the command //Instance this Characters personal Command System with a copy of the command
@ -114,7 +114,7 @@ namespace MudEngine.Game.Characters
this._Writer.AutoFlush = true; //Flushes the stream automatically. this._Writer.AutoFlush = true; //Flushes the stream automatically.
} }
public void Initialize() public virtual void Initialize()
{ {
//throw new NotImplementedException(); //throw new NotImplementedException();
this.Enabled = true; this.Enabled = true;
@ -124,7 +124,7 @@ namespace MudEngine.Game.Characters
/// Destroys any resources used by this character. /// Destroys any resources used by this character.
/// Assumes that Save() has already been invoked. /// Assumes that Save() has already been invoked.
/// </summary> /// </summary>
public void Destroy() public virtual void Destroy()
{ {
this.Commands = null; this.Commands = null;
} }
@ -163,31 +163,12 @@ namespace MudEngine.Game.Characters
this.Role = GetRole(role); this.Role = GetRole(role);
} }
private CharacterRoles GetRole(String role)
{
//Blow all of the available values up into an array.
Array values = Enum.GetValues(typeof(CharacterRoles));
//Loop through each available value, converting it into a string.
foreach (Int32 value in values)
{
//Get the string representation of the current value
String displayName = Enum.GetName(typeof(CharacterRoles), value);
//Check if this value matches that of the supplied one.
//If so, return it as a enum
if (displayName.ToLower() == role.ToLower())
return (CharacterRoles)Enum.Parse(typeof(CharacterRoles), displayName);
}
return CharacterRoles.Player;
}
/// <summary> /// <summary>
/// Executes the specified command if it exists in the Command library. /// Executes the specified command if it exists in the Command library.
/// </summary> /// </summary>
/// <param name="command"></param> /// <param name="command"></param>
/// <returns></returns> /// <returns></returns>
public Boolean ExecuteCommand(string command) public virtual Boolean ExecuteCommand(string command)
{ {
if (this.Enabled && this.Connected) if (this.Enabled && this.Connected)
{ {
@ -209,7 +190,7 @@ namespace MudEngine.Game.Characters
/// </summary> /// </summary>
/// <param name="command"></param> /// <param name="command"></param>
/// <returns></returns> /// <returns></returns>
public Boolean ExecuteSilentCommand(string command) public virtual Boolean ExecuteSilentCommand(string command)
{ {
if (this.Enabled) if (this.Enabled)
{ {
@ -245,12 +226,12 @@ namespace MudEngine.Game.Characters
this.OnDisconnectEvent(); this.OnDisconnectEvent();
} }
public void SendMessage(String data) public virtual void SendMessage(String data)
{ {
this.SendMessage(data, true); this.SendMessage(data, true);
} }
public void SendMessage(String data, Boolean newLine) public virtual void SendMessage(String data, Boolean newLine)
{ {
try try
{ {
@ -393,6 +374,25 @@ namespace MudEngine.Game.Characters
} }
} }
private CharacterRoles GetRole(String role)
{
//Blow all of the available values up into an array.
Array values = Enum.GetValues(typeof(CharacterRoles));
//Loop through each available value, converting it into a string.
foreach (Int32 value in values)
{
//Get the string representation of the current value
String displayName = Enum.GetName(typeof(CharacterRoles), value);
//Check if this value matches that of the supplied one.
//If so, return it as a enum
if (displayName.ToLower() == role.ToLower())
return (CharacterRoles)Enum.Parse(typeof(CharacterRoles), displayName);
}
return CharacterRoles.Player;
}
private Socket _Connection; private Socket _Connection;
private StreamReader _Reader; private StreamReader _Reader;
private StreamWriter _Writer; private StreamWriter _Writer;

View file

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MudEngine.GameScripts;
namespace MudEngine.Game.Environment
{
public class Doorway
{
public Boolean Locked { get; set; }
public BaseScript RequiredKey { get; private set; }
public Int32 LevelRequirement { get; set; }
public AvailableTravelDirections TravelDirection { get; set; }
public Room ArrivalRoom { get; private set; }
public Room DepartureRoom { get; private set; }
public Doorway(StandardGame game)
{
this.LevelRequirement = 0;
}
}
}

View file

@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using MudEngine.Core.Interfaces;
using MudEngine.Game.Characters;
using MudEngine.Game;
using MudEngine.GameScripts;
namespace MudEngine.Game.Environment
{
public class Realm : BaseScript, IGameComponent, ISavable, IUpdatable
{
public string Filename { get; set; }
public Realm(StandardGame game, String name, String description) : base(game, name, description)
{
this._ZoneCollection = new List<Zone>();
}
public void Initialize()
{
}
public void Destroy()
{
throw new NotImplementedException();
}
public bool Save(string filename)
{
throw new NotImplementedException();
}
public bool Save(string filename, bool ignoreFileWrite)
{
throw new NotImplementedException();
}
public void Load(string filename)
{
throw new NotImplementedException();
}
public void Update()
{
throw new NotImplementedException();
}
public void CreateZone(String name, String description)
{
Zone zone = new Zone(this.Game, name, description);
this._ZoneCollection.Add(zone);
}
public Zone GetZone(String name)
{
var v = from zone in this._ZoneCollection
where zone.Name == name
select zone;
return v.First();
}
private List<Zone> _ZoneCollection;
}
}

View file

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MudEngine.Core.Interfaces;
using MudEngine.Core;
using MudEngine.Game;
using MudEngine.Game.Characters;
using MudEngine.GameScripts;
namespace MudEngine.Game.Environment
{
public class Room : BaseScript, IUpdatable
{
public Room(StandardGame game, String name, String description)
: base(game, name, description)
{
this._Doors = new List<Doorway>();
}
public void Update()
{
throw new NotImplementedException();
}
public String[] GetDescription()
{
return new List<String>().ToArray();
}
private List<Doorway> _Doors;
}
}

View file

@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MudEngine.Core.Interfaces;
using MudEngine.GameScripts;
using MudEngine.Game.Characters;
namespace MudEngine.Game.Environment
{
public class Zone : BaseScript, IGameComponent, ISavable, IUpdatable
{
/// <summary>
/// Gets or Sets the what stats
/// </summary>
public CharacterStats StatDrain { get; set; }
public Boolean Safe { get; set; }
public String Realm { get; private set; }
public Zone(StandardGame game, String name, String description) : base(game, name, description)
{
this._RoomCollection = new List<Room>();
}
public void Initialize()
{
throw new NotImplementedException();
}
public void Destroy()
{
throw new NotImplementedException();
}
public string Filename
{
get { throw new NotImplementedException(); }
}
public void Update()
{
throw new NotImplementedException();
}
public void CreateRoom(String name, String description)
{
}
private List<Room> _RoomCollection;
}
}

View file

@ -71,10 +71,15 @@ namespace MudEngine.Game
public Boolean Debugging { get; set; } public Boolean Debugging { get; set; }
/// <summary> /// <summary>
/// Gets or reference to the currently running Server. /// Gets a reference to the currently running Server.
/// </summary> /// </summary>
public Server Server { get; protected set; } public Server Server { get; protected set; }
/// <summary>
/// Gets a reference to the current Game World
/// </summary>
public World World { get; protected set; }
/// <summary> /// <summary>
/// Gets or Sets the paths that content is saved to. /// Gets or Sets the paths that content is saved to.
/// </summary> /// </summary>
@ -113,6 +118,8 @@ namespace MudEngine.Game
this.SavePaths = paths; this.SavePaths = paths;
SetupPaths(); SetupPaths();
this.World = new World(this);
} }
/// <summary> /// <summary>
@ -134,6 +141,7 @@ namespace MudEngine.Game
CommandSystem.LoadCommands(); CommandSystem.LoadCommands();
//Load World //Load World
this.World.CreateRealm("Azeroth", "The realm of Azeroth is full of jungles and small villages");
//Start our server. //Start our server.
this.Server.Start(maxPlayers, maxQueueSize); this.Server.Start(maxPlayers, maxQueueSize);

View file

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MudEngine.Game.Environment;
namespace MudEngine.Game
{
public class World
{
public StandardGame Game { get; private set; }
public World(StandardGame game)
{
this.Game = game;
this._RealmCollection = new List<Realm>();
}
public void CreateRealm(String name, String description)
{
Realm r = new Realm(this.Game, name, description);
this._RealmCollection.Add(r);
}
public Realm GetRealm(String name)
{
var v = from realm in this._RealmCollection
where realm.Name == name
select realm;
Realm r = v.First();
return r;
}
private List<Realm> _RealmCollection;
}
}

View file

@ -23,10 +23,13 @@ namespace MudEngine.GameScripts
public XMLData SaveData { get; protected set; } public XMLData SaveData { get; protected set; }
public StandardGame Game { get; private set; }
public BaseScript(StandardGame game, String name, String description) public BaseScript(StandardGame game, String name, String description)
{ {
this.Name = name; this.Name = name;
this.Description = description; this.Description = description;
this.Game = game;
this.ID = Guid.NewGuid().ToString(); this.ID = Guid.NewGuid().ToString();

View file

@ -6,7 +6,7 @@ using System.Text.RegularExpressions;
using System.IO; using System.IO;
using System.Diagnostics; using System.Diagnostics;
using MudEngine.Core.Interface; using MudEngine.Core.Interfaces;
using MudEngine.Game; using MudEngine.Game;
using MudEngine.Game.Characters; using MudEngine.Game.Characters;
using MudEngine.Game.Environment; using MudEngine.Game.Environment;

View file

@ -5,7 +5,7 @@ using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.IO; using System.IO;
using MudEngine.Core.Interface; using MudEngine.Core.Interfaces;
using MudEngine.Game; using MudEngine.Game;
using MudEngine.Game.Characters; using MudEngine.Game.Characters;
using MudEngine.Game.Environment; using MudEngine.Game.Environment;

View file

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MudEngine.Game;
using MudEngine.Game.Characters;
using MudEngine.Game.Environment;
using MudEngine.Core.Interfaces;
namespace MudEngine.GameScripts.Commands
{
public class CommandLook : ICommand
{
public string Name { get; set; }
public string Description { get; set; }
public List<string> Help { get; set; }
public CommandLook()
{
this.Name = "Look";
}
public bool Execute(string command, StandardCharacter character)
{
return false;
}
}
}

View file

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using MudEngine.Core.Interface; using MudEngine.Core.Interfaces;
using MudEngine.Game; using MudEngine.Game;
using MudEngine.Game.Characters; using MudEngine.Game.Characters;
using MudEngine.Networking; using MudEngine.Networking;

View file

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using MudEngine.Core.Interface; using MudEngine.Core.Interfaces;
using MudEngine.Game; using MudEngine.Game;
using MudEngine.Game.Characters; using MudEngine.Game.Characters;
using MudEngine.Networking; using MudEngine.Networking;

View file

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using MudEngine.Core.Interface; using MudEngine.Core.Interfaces;
using MudEngine.Game; using MudEngine.Game;
using MudEngine.Game.Characters; using MudEngine.Game.Characters;
using MudEngine.Networking; using MudEngine.Networking;

View file

@ -55,6 +55,7 @@
<Compile Include="Core\ObjectCollection.cs" /> <Compile Include="Core\ObjectCollection.cs" />
<Compile Include="DAL\DataPaths.cs" /> <Compile Include="DAL\DataPaths.cs" />
<Compile Include="DAL\XMLData.cs" /> <Compile Include="DAL\XMLData.cs" />
<Compile Include="GameScripts\Commands\CommandLook.cs" />
<Compile Include="GameScripts\Commands\CommandLogin.cs" /> <Compile Include="GameScripts\Commands\CommandLogin.cs" />
<Compile Include="GameScripts\Commands\CommandSay.cs" /> <Compile Include="GameScripts\Commands\CommandSay.cs" />
<Compile Include="GameScripts\Commands\CommandStop.cs" /> <Compile Include="GameScripts\Commands\CommandStop.cs" />
@ -65,8 +66,13 @@
<Compile Include="Game\Characters\MyCharacter.cs" /> <Compile Include="Game\Characters\MyCharacter.cs" />
<Compile Include="Game\Characters\StandardCharacter.cs" /> <Compile Include="Game\Characters\StandardCharacter.cs" />
<Compile Include="GameScripts\BaseScript.cs" /> <Compile Include="GameScripts\BaseScript.cs" />
<Compile Include="Game\Environment\Doorway.cs" />
<Compile Include="Game\Environment\Realm.cs" />
<Compile Include="Game\Environment\Room.cs" />
<Compile Include="Game\Environment\Zone.cs" />
<Compile Include="Game\StandardGame.cs" /> <Compile Include="Game\StandardGame.cs" />
<Compile Include="Game\Environment\TravelDirections.cs" /> <Compile Include="Game\Environment\TravelDirections.cs" />
<Compile Include="Game\World.cs" />
<Compile Include="Networking\ConnectionManager.cs" /> <Compile Include="Networking\ConnectionManager.cs" />
<Compile Include="Networking\Server.cs" /> <Compile Include="Networking\Server.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />