muddesigner/MudEngine/GameObjects/Characters/BaseCharacter.cs
Scionwest_cp 486efa4fed MudEngine:
- Re-worked the command system. All commands now only need 2 arguments rather than 4. The actual command string and the Player
 - All commands updated to work with the new command system
 - Look command now works in the example MudGame 
 - Realm now contains InitialZone for the starting Zone within that Realm.
 - Zone now contains InitialRoom for the starting Room within that Zone.
 - All Environment objects now contains a Initial property and Add() method for adding child objects.
 - BaseCharacter now contains a copy of Game
 - Revised Realm.GetZone()
 - Revised Zone.GetRoom()
 - Removed Zone.RebuildRoomCollection as content is currently no longer stored using physical files.
 - Added GameManagement.Log for logging errors and warnings to file. Use Log.Write().
2010-07-25 16:56:15 -07:00

69 lines
2.2 KiB
C#

//Microsoft .NET Framework
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//MUD Engine
using MudEngine.FileSystem;
using MudEngine.Commands;
using MudEngine.GameManagement;
using MudEngine.GameObjects;
using MudEngine.GameObjects.Environment;
using MudEngine.GameObjects.Items;
namespace MudEngine.GameObjects.Characters
{
public class BaseCharacter : BaseObject
{
/// <summary>
/// The current Room this Character is located at.
/// </summary>
public Room CurrentRoom { get; set; }
/// <summary>
/// Gets or Sets if this Character is controlled by the user. If not user controlled then it will be AI controlled.
/// </summary>
public Boolean IsControlled { get; set; }
/// <summary>
/// Gets or Sets if this user has Admin privileges or not.
/// </summary>
public Boolean IsAdmin { get; private set; }
/// <summary>
/// Gets a reference to the currently running game.
/// </summary>
public Game Game { get; private set; }
public BaseCharacter(Game game)
{
Game = game;
CurrentRoom = game.InitialRealm.InitialZone.InitialRoom;
}
public virtual void OnTravel(AvailableTravelDirections travelDirection)
{
if (CurrentRoom.DoorwayExist(travelDirection.ToString()))
{
string connectedRoom = CurrentRoom.GetDoor(travelDirection).ConnectedRoom;
CurrentRoom = (Room)CurrentRoom.Load(connectedRoom);
}
}
public CommandResults ExecuteCommand(string command)
{
//TODO: Character class can handle a lot of the command management here, checking various things prior to sending
//the command off to the command engine for execution.
return CommandEngine.ExecuteCommand(command, this);
}
public void Initialize(ref MudEngine.Networking.ClientSocket rcs)
{
CurrentRoom = Game.InitialRealm.InitialZone.InitialRoom;
sock = rcs;
}
public MudEngine.Networking.ClientSocket sock;
}
}