type TActionComponent = class(TObject) public procedure Execute;virtual; end; TStuckPig = class(TActionComponent) public procedure Execute;override; end; TRole = class(TObject) public Name:String[255]; ActionList:TList<TActionComponent>; end; TWorld = class(TObject) public ObjectList:TDictionary<string,TList<TRole>>; end; TForm2 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form2: TForm2; implementation {$R *.dfm} procedure TForm2.Button1Click(Sender: TObject); var World:TWorld; Roles:TList<TRole>; Role:TRole; ActionComponent:TActionComponent; begin World:=TWorld.Create; //角色:屠夫 Role:=TRole.Create; Role.Name:='屠夫'; //杀猪动作或者叫技能可能更准确 ActionComponent:=TStuckPig.Create; Role.ActionList.Add(ActionComponent); Roles:=TList<TRole>.Create; Roles.Add(Role); //角色:将军 Role:=TRole.Create; Role.Name:='骠骑大将军'; Roles.Add(Role); //角色:书法家 Role:=TRole.Create; Role.Name:='书法家'; Roles.Add(Role); //角色:酒鬼 Role:=TRole.Create; Role.Name:='酒鬼'; Roles.Add(Role); //赋与张飞各角色 World.ObjectList.Add('张飞',Roles); end;