muddesigner/MudEngine/Commands/CommandWalk.cs
Scionwest_cp 6987d8178f 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.
2010-07-18 21:25:12 -07:00

50 lines
1.6 KiB
C#

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.");
}
}
}