Began initial work on the game world. World, Realm, Zone, Room and Doorway classes created but not implemented.
This commit is contained in:
parent
b708a63273
commit
a3eb1b5fad
18 changed files with 313 additions and 36 deletions
|
@ -4,7 +4,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Reflection;
|
||||
|
||||
using MudEngine.Core.Interface;
|
||||
using MudEngine.Core.Interfaces;
|
||||
using MudEngine.Game.Characters;
|
||||
|
||||
namespace MudEngine.Core
|
||||
|
|
|
@ -5,7 +5,7 @@ using System.Text;
|
|||
|
||||
using MudEngine.Game.Characters;
|
||||
|
||||
namespace MudEngine.Core.Interface
|
||||
namespace MudEngine.Core.Interfaces
|
||||
{
|
||||
public interface ICommand
|
||||
{
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace MudEngine.Game.Characters
|
|||
Admin,
|
||||
Immortal,
|
||||
GM,
|
||||
Builder,
|
||||
QuestGiver,
|
||||
Player,
|
||||
NPC
|
||||
|
|
|
@ -13,6 +13,7 @@ using MudEngine.GameScripts;
|
|||
using MudEngine.Core.Interfaces;
|
||||
using MudEngine.Networking;
|
||||
using MudEngine.Core;
|
||||
using MudEngine.Game.Environment;
|
||||
|
||||
namespace MudEngine.Game.Characters
|
||||
{
|
||||
|
@ -24,7 +25,6 @@ namespace MudEngine.Game.Characters
|
|||
/// <summary>
|
||||
/// Gets a reference to the currently active game.
|
||||
/// </summary>
|
||||
public StandardGame Game { get; private set; }
|
||||
|
||||
public string Filename
|
||||
{
|
||||
|
@ -87,11 +87,11 @@ namespace MudEngine.Game.Characters
|
|||
|
||||
protected CommandSystem Commands { get; private set; }
|
||||
|
||||
public Room CurrentRoom { get; private set; }
|
||||
|
||||
public StandardCharacter(StandardGame game, String name, String description)
|
||||
: base(game, name, description)
|
||||
{
|
||||
this.Game = game;
|
||||
|
||||
this.Role = CharacterRoles.Player;
|
||||
|
||||
//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.
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
public virtual void Initialize()
|
||||
{
|
||||
//throw new NotImplementedException();
|
||||
this.Enabled = true;
|
||||
|
@ -124,7 +124,7 @@ namespace MudEngine.Game.Characters
|
|||
/// Destroys any resources used by this character.
|
||||
/// Assumes that Save() has already been invoked.
|
||||
/// </summary>
|
||||
public void Destroy()
|
||||
public virtual void Destroy()
|
||||
{
|
||||
this.Commands = null;
|
||||
}
|
||||
|
@ -163,31 +163,12 @@ namespace MudEngine.Game.Characters
|
|||
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>
|
||||
/// Executes the specified command if it exists in the Command library.
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
public Boolean ExecuteCommand(string command)
|
||||
public virtual Boolean ExecuteCommand(string command)
|
||||
{
|
||||
if (this.Enabled && this.Connected)
|
||||
{
|
||||
|
@ -209,7 +190,7 @@ namespace MudEngine.Game.Characters
|
|||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
public Boolean ExecuteSilentCommand(string command)
|
||||
public virtual Boolean ExecuteSilentCommand(string command)
|
||||
{
|
||||
if (this.Enabled)
|
||||
{
|
||||
|
@ -245,12 +226,12 @@ namespace MudEngine.Game.Characters
|
|||
this.OnDisconnectEvent();
|
||||
}
|
||||
|
||||
public void SendMessage(String data)
|
||||
public virtual void SendMessage(String data)
|
||||
{
|
||||
this.SendMessage(data, true);
|
||||
}
|
||||
|
||||
public void SendMessage(String data, Boolean newLine)
|
||||
public virtual void SendMessage(String data, Boolean newLine)
|
||||
{
|
||||
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 StreamReader _Reader;
|
||||
private StreamWriter _Writer;
|
||||
|
|
29
MudEngine/WinPC_Engine/Game/Environment/Doorway.cs
Normal file
29
MudEngine/WinPC_Engine/Game/Environment/Doorway.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
70
MudEngine/WinPC_Engine/Game/Environment/Realm.cs
Normal file
70
MudEngine/WinPC_Engine/Game/Environment/Realm.cs
Normal 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;
|
||||
}
|
||||
}
|
33
MudEngine/WinPC_Engine/Game/Environment/Room.cs
Normal file
33
MudEngine/WinPC_Engine/Game/Environment/Room.cs
Normal 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;
|
||||
}
|
||||
}
|
55
MudEngine/WinPC_Engine/Game/Environment/Zone.cs
Normal file
55
MudEngine/WinPC_Engine/Game/Environment/Zone.cs
Normal 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;
|
||||
}
|
||||
}
|
|
@ -71,10 +71,15 @@ namespace MudEngine.Game
|
|||
public Boolean Debugging { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or reference to the currently running Server.
|
||||
/// Gets a reference to the currently running Server.
|
||||
/// </summary>
|
||||
public Server Server { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the current Game World
|
||||
/// </summary>
|
||||
public World World { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets the paths that content is saved to.
|
||||
/// </summary>
|
||||
|
@ -113,6 +118,8 @@ namespace MudEngine.Game
|
|||
this.SavePaths = paths;
|
||||
|
||||
SetupPaths();
|
||||
|
||||
this.World = new World(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -134,6 +141,7 @@ namespace MudEngine.Game
|
|||
CommandSystem.LoadCommands();
|
||||
|
||||
//Load World
|
||||
this.World.CreateRealm("Azeroth", "The realm of Azeroth is full of jungles and small villages");
|
||||
|
||||
//Start our server.
|
||||
this.Server.Start(maxPlayers, maxQueueSize);
|
||||
|
|
39
MudEngine/WinPC_Engine/Game/World.cs
Normal file
39
MudEngine/WinPC_Engine/Game/World.cs
Normal 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;
|
||||
}
|
||||
}
|
|
@ -23,10 +23,13 @@ namespace MudEngine.GameScripts
|
|||
|
||||
public XMLData SaveData { get; protected set; }
|
||||
|
||||
public StandardGame Game { get; private set; }
|
||||
|
||||
public BaseScript(StandardGame game, String name, String description)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Description = description;
|
||||
this.Game = game;
|
||||
|
||||
this.ID = Guid.NewGuid().ToString();
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ using System.Text.RegularExpressions;
|
|||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
|
||||
using MudEngine.Core.Interface;
|
||||
using MudEngine.Core.Interfaces;
|
||||
using MudEngine.Game;
|
||||
using MudEngine.Game.Characters;
|
||||
using MudEngine.Game.Environment;
|
||||
|
|
|
@ -5,7 +5,7 @@ using System.Text;
|
|||
using System.Text.RegularExpressions;
|
||||
using System.IO;
|
||||
|
||||
using MudEngine.Core.Interface;
|
||||
using MudEngine.Core.Interfaces;
|
||||
using MudEngine.Game;
|
||||
using MudEngine.Game.Characters;
|
||||
using MudEngine.Game.Environment;
|
||||
|
|
33
MudEngine/WinPC_Engine/GameScripts/Commands/CommandLook.cs
Normal file
33
MudEngine/WinPC_Engine/GameScripts/Commands/CommandLook.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using MudEngine.Core.Interface;
|
||||
using MudEngine.Core.Interfaces;
|
||||
using MudEngine.Game;
|
||||
using MudEngine.Game.Characters;
|
||||
using MudEngine.Networking;
|
||||
|
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
using MudEngine.Core.Interface;
|
||||
using MudEngine.Core.Interfaces;
|
||||
using MudEngine.Game;
|
||||
using MudEngine.Game.Characters;
|
||||
using MudEngine.Networking;
|
||||
|
|
|
@ -4,7 +4,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
using MudEngine.Core.Interface;
|
||||
using MudEngine.Core.Interfaces;
|
||||
using MudEngine.Game;
|
||||
using MudEngine.Game.Characters;
|
||||
using MudEngine.Networking;
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
<Compile Include="Core\ObjectCollection.cs" />
|
||||
<Compile Include="DAL\DataPaths.cs" />
|
||||
<Compile Include="DAL\XMLData.cs" />
|
||||
<Compile Include="GameScripts\Commands\CommandLook.cs" />
|
||||
<Compile Include="GameScripts\Commands\CommandLogin.cs" />
|
||||
<Compile Include="GameScripts\Commands\CommandSay.cs" />
|
||||
<Compile Include="GameScripts\Commands\CommandStop.cs" />
|
||||
|
@ -65,8 +66,13 @@
|
|||
<Compile Include="Game\Characters\MyCharacter.cs" />
|
||||
<Compile Include="Game\Characters\StandardCharacter.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\Environment\TravelDirections.cs" />
|
||||
<Compile Include="Game\World.cs" />
|
||||
<Compile Include="Networking\ConnectionManager.cs" />
|
||||
<Compile Include="Networking\Server.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue