Hi,
Das ganze kommt mir seltsam vor... Also das ganze sieht so aus:
Delphi-Quellcode:
TPlantation =
class(TBuilding)
//...
end;
TPlantations =
Array of TPlantation;
TBuild =
class
private
FOwner: TPlayer;
procedure AddPlantation(AName:
String);
public
constructor Create(AOwner: TPlayer);
property Owner: TPlayer
read FOwner;
procedure Plantation(AName:
String);
destructor Destroy;
override;
end;
TPlayer =
class
private
FBuild: TBuild;
FPlantations: TPlantations;
//..
public
constructor Create;
property Build: TBuild
read FBuild;
property Plantations[
Index: Integer]: TPlantation
read GetPlantation
write SetPlantation;
//...
end;
constructor TPlayer.Create;
begin
inherited Create;
FBuild := TBuild.Create(Self);
end;
procedure TBuild.Plantation(AName:
String);
begin
if FOwner.Money >= UNIT_COSTS[UD_PLANTATION]
then
begin
AddPlantation(AName);
dec(FOwner.FMoney,UNIT_COSTS[UD_PLANTATION]);
end
else MessageDlg('
Sie haben nicht genug Geld!',mtInformation,[mbOK],0);
end;
procedure TBuild.AddPlantation(AName:
String);
begin
SetLength(FOwner.FPlantations,Length(FOwner.FPlantations)+1);
// Es knallt
with FOwner.FPlantations[High(FOwner.FPlantations)].Create(FOwner)
do
Name := AName;
end;
Aufgerufen wirds im Hauptprogramm so:
Delphi-Quellcode:
Player := TPlayer.Create;
Player.Build.Plantation('Test');
//..
Ich versteh das Problem nicht so ganz
Da dürfte doch eigentlich nix schief gehn oder?...
Gruß
Neutral General
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."