私は現在、Adventure Game Creator Framework を作成しており、これまでのところ次のクラスがあります。
// Base class that represents a single episode from a complete game.
public abstract class Episode : IEpisode
{
public RoomList Rooms {get; }
public ArtefactList Artefacts {get; }
public Episode()
{
Rooms = new RoomList();
Artefacts = new ArtefactList();
}
}
// This is a list of all objects in the episode.
public ArtefactList : List<IArtefact>
{
public IArtefact Create( UInt32 id, String text )
{
IArtefact art = new Artefact( id, text );
base.Add( art );
return art;
}
}
// This is a list of all rooms in the episode.
public RoomList : List<IRoom>
{
public IRoom Create( UInt32 id, String text )
{
IRoom rm = new Room( id, text );
base.Add( rm );
return rm;
}
}
public class Room : IRoom
{
public UInt32 Id { get; set; }
public String Text { get; set; }
public IList<IArtefact> Artefacts
{
get
{
return ???what??? // How do I access the Artefacts property from
// the base class:
// (Room --> RoomList --> Episode)
}
}
}
public class Artefact : IArtefact
{
public UInt32 Id { get; set; }
public String Text { get; set; }
public IRoom CurrentRoom { get; set; }
}
public interface IArtefact
{
UInt32 Id { get; set; }
String Text { get; set; }
IRoom CurrentRoom { get; set; }
}
public interface IRoom
{
UInt32 Id { get; set; }
String Text { get; set; }
IList<IArtefact> Artefacts {get; }
}
私が知りたいのは、クラスが、オブジェクト グラフ全体への参照を渡すことなく、クラスRoom
のカプセル化されArtefacts
たプロパティにアクセスする方法、つまり--> -->です。Episode
Episode
Episode
RoomsList
Room