public abstract class Road
{
}
public abstract class House
{
}
public abstract class Role
{
}
public class ClassicRoad : Road
{
}
public class ClassicHouse : House
{
}
public class ClassicRole : Role
{
}
public class ModernRoad : Road
{
}
public class ModernHouse : House
{
}
public class ModernRole : Role
{
}
public abstract class SceneFactory
{
public abstract Road CreateRoad();
public abstract House CreateHouse();
public abstract Role CreateRole();
}
public class ClassicSceneFactory
{
public Road CreateRoad()
{
return new ClassicRoad();
}
public House CreateHouse()
{
return new ClassicHouse();
}
public Role CreateRole()
{
return new ClassicRole();
}
}
public class ModernSceneFactory
{
public Road CreateRoad()
{
return new ModernRoad();
}
public House CreateHouse()
{
return new ModernHouse();
}
public Role CreateRole()
{
return new ModernRole();
}
}
class GameManager
{
private SceneFactory _factory = null;
private Road _road = null;
private House _house = null;
private Role _role = null;
public GameManager(SceneFactory factory)
{
this._factory = factory;
}
public void CreateScene()
{
_road = _factory.CreateRoad();
_house = _factory.CreateHouse();
_role = _factory.CreateRole();
}
public void Run()
{
_role.WalkAlone(_road);
_role.Enter(_house);
...
}