-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLivingUnitControl.pas
86 lines (68 loc) · 2.06 KB
/
LivingUnitControl.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
unit LivingUnitControl;
interface
uses
Math, TypeControl, CircularUnitControl, FactionControl, StatusControl;
type
TLivingUnit = class (TCircularUnit)
private
FLife: LongInt;
FMaxLife: LongInt;
FStatuses: TStatusArray;
protected
constructor Create(const id: Int64; const x: Double; const y: Double; const speedX: Double; const speedY: Double;
const angle: Double; const faction: TFaction; const radius: Double; const life: LongInt; const maxLife: LongInt;
const statuses: TStatusArray);
public
function GetLife: LongInt;
property Life: LongInt read GetLife;
function GetMaxLife: LongInt;
property MaxLife: LongInt read GetMaxLife;
function GetStatuses: TStatusArray;
property Statuses: TStatusArray read GetStatuses;
destructor Destroy; override;
end;
TLivingUnitArray = array of TLivingUnit;
implementation
constructor TLivingUnit.Create(const id: Int64; const x: Double; const y: Double; const speedX: Double;
const speedY: Double; const angle: Double; const faction: TFaction; const radius: Double; const life: LongInt;
const maxLife: LongInt; const statuses: TStatusArray);
begin
inherited Create(id, x, y, speedX, speedY, angle, faction, radius);
FLife := life;
FMaxLife := maxLife;
if Assigned(statuses) then begin
FStatuses := Copy(statuses, 0, Length(statuses));
end else begin
FStatuses := nil;
end;
end;
function TLivingUnit.GetLife: LongInt;
begin
result := FLife;
end;
function TLivingUnit.GetMaxLife: LongInt;
begin
result := FMaxLife;
end;
function TLivingUnit.GetStatuses: TStatusArray;
begin
if Assigned(FStatuses) then begin
result := Copy(FStatuses, 0, Length(FStatuses));
end else begin
result := nil;
end;
end;
destructor TLivingUnit.Destroy;
var
i: LongInt;
begin
if Assigned(FStatuses) then begin
for i := High(FStatuses) downto 0 do begin
if Assigned(FStatuses[i]) then begin
FStatuses[i].Free;
end;
end;
end;
inherited;
end;
end.