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:
parent
9debc62ba4
commit
6987d8178f
8 changed files with 105 additions and 9 deletions
42
MudEngine/Commands/CommandLook.cs
Normal file
42
MudEngine/Commands/CommandLook.cs
Normal 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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
50
MudEngine/Commands/CommandWalk.cs
Normal file
50
MudEngine/Commands/CommandWalk.cs
Normal 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.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,5 +11,6 @@ namespace MudEngine.GameObjects.Characters.Controlled
|
||||||
{
|
{
|
||||||
public class PlayerBasic : BaseCharacter
|
public class PlayerBasic : BaseCharacter
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,8 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Commands\CommandExit.cs" />
|
<Compile Include="Commands\CommandExit.cs" />
|
||||||
|
<Compile Include="Commands\CommandLook.cs" />
|
||||||
|
<Compile Include="Commands\CommandWalk.cs" />
|
||||||
<Compile Include="GameManagement\CommandEngine.cs" />
|
<Compile Include="GameManagement\CommandEngine.cs" />
|
||||||
<Compile Include="GameManagement\CommandResults.cs" />
|
<Compile Include="GameManagement\CommandResults.cs" />
|
||||||
<Compile Include="GameManagement\ICommand.cs" />
|
<Compile Include="GameManagement\ICommand.cs" />
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using MudEngine.Networking.Socket;
|
|
||||||
|
|
||||||
// TODO: everything D:
|
// TODO: everything D:
|
||||||
|
|
||||||
|
@ -13,7 +12,8 @@ namespace MudEngine.Networking
|
||||||
public ClientSocket()
|
public ClientSocket()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
public ~ClientSocket()
|
|
||||||
|
~ClientSocket()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using MudEngine.Networking.ServerSocket;
|
using MudEngine.Networking;
|
||||||
using MudEngine.Networking.ClientSocket;
|
|
||||||
|
|
||||||
// TODO: everything D:
|
// TODO: everything D:
|
||||||
|
|
||||||
|
@ -14,7 +13,8 @@ namespace MudEngine.Networking
|
||||||
public Server()
|
public Server()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
public ~Server()
|
|
||||||
|
~Server()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using MudEngine.Networking.Socket;
|
|
||||||
|
|
||||||
// TODO: everything D:
|
// TODO: everything D:
|
||||||
|
|
||||||
|
@ -21,7 +20,8 @@ namespace MudEngine.Networking
|
||||||
stage = 0;
|
stage = 0;
|
||||||
type = 0;
|
type = 0;
|
||||||
}
|
}
|
||||||
public ~ServerSocket()
|
|
||||||
|
~ServerSocket()
|
||||||
{
|
{
|
||||||
port = 0;
|
port = 0;
|
||||||
stage = 0;
|
stage = 0;
|
||||||
|
|
|
@ -12,7 +12,8 @@ namespace MudEngine.Networking
|
||||||
public Socket()
|
public Socket()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
public ~Socket()
|
|
||||||
|
~Socket()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue