MudEngine:

- Added Look and Walk Commands, however they are not fully implemented.
 - Corrected Networking classes having a public de-constructor. These must be private or the compiler fails.
 - Corrected Networking classes using an incorrect 'using' statement. You cannot reference classes in the statement, must only reference the namespace itself (i.e. using MUDEngine.Networking).
 - Removed using statement for Networking in the Networking classes as all classes created within that namespace automatically are within the same scope.
This commit is contained in:
Scionwest_cp 2010-07-18 21:25:12 -07:00
parent 9debc62ba4
commit 6987d8178f
8 changed files with 105 additions and 9 deletions

View file

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MudEngine.GameObjects.Characters;
using MudEngine.GameObjects.Characters.Controlled;
using MudEngine.FileSystem;
using MudEngine.Commands;
using MudEngine.GameManagement;
using MudEngine.GameObjects.Environment;
using MudEngine.GameObjects.Items;
namespace MudEngine.Commands
{
public class CommandLook : IGameCommand
{
public string Name { get; set; }
public bool Override { get; set; }
public CommandResults Execute(string command, BaseCharacter player, Game project, Room room)
{
StringBuilder desc = new StringBuilder();
if (room == null)
{
return new CommandResults("Not within a created Room.");
}
desc.AppendLine(room.Description);
foreach (Door door in room.Doorways)
{
if (door.TravelDirection != MudEngine.GameObjects.AvailableTravelDirections.Down && door.TravelDirection != MudEngine.GameObjects.AvailableTravelDirections.Up)
{
desc.AppendLine(door.Description);
}
}
return new CommandResults(desc.ToString());
}
}
}

View file

@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using MudEngine.GameObjects.Characters;
using MudEngine.GameManagement;
using MudEngine.GameObjects.Environment;
using MudEngine.GameObjects;
using MudEngine.FileSystem;
namespace MudEngine.Commands
{
public class CommandWalk : IGameCommand
{
public string Name { get; set; }
public bool Override { get; set; }
public CommandResults Execute(string command, BaseCharacter player, Game project, Room room)
{
string[] words = command.Split(' ');
List<string> directions = new List<string>();
if (words.Length == 1)
return new CommandResults("No direction supplied");
else
{
foreach (Door door in room.Doorways)
{
AvailableTravelDirections direction = TravelDirections.GetTravelDirectionValue(words[1]);
if (door.TravelDirection == direction)
{
room = (Room)room.Load(door.ConnectedRoom);
CommandResults cmd = CommandEngine.ExecuteCommand("Look", player, project, room);
string lookValue = "";
if (cmd.Result.Length != 0)
lookValue = cmd.Result[0].ToString();
return new CommandResults(new object[] { lookValue, room });
}
}
}
return new CommandResults("Unable to travel in that direction.");
}
}
}

View file

@ -11,5 +11,6 @@ namespace MudEngine.GameObjects.Characters.Controlled
{
public class PlayerBasic : BaseCharacter
{
}
}

View file

@ -50,6 +50,8 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Commands\CommandExit.cs" />
<Compile Include="Commands\CommandLook.cs" />
<Compile Include="Commands\CommandWalk.cs" />
<Compile Include="GameManagement\CommandEngine.cs" />
<Compile Include="GameManagement\CommandResults.cs" />
<Compile Include="GameManagement\ICommand.cs" />

View file

@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MudEngine.Networking.Socket;
// TODO: everything D:
@ -13,7 +12,8 @@ namespace MudEngine.Networking
public ClientSocket()
{
}
public ~ClientSocket()
~ClientSocket()
{
}

View file

@ -2,8 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MudEngine.Networking.ServerSocket;
using MudEngine.Networking.ClientSocket;
using MudEngine.Networking;
// TODO: everything D:
@ -14,7 +13,8 @@ namespace MudEngine.Networking
public Server()
{
}
public ~Server()
~Server()
{
}

View file

@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MudEngine.Networking.Socket;
// TODO: everything D:
@ -21,7 +20,8 @@ namespace MudEngine.Networking
stage = 0;
type = 0;
}
public ~ServerSocket()
~ServerSocket()
{
port = 0;
stage = 0;

View file

@ -12,7 +12,8 @@ namespace MudEngine.Networking
public Socket()
{
}
public ~Socket()
~Socket()
{
}