-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathuGameActions.pas
More file actions
130 lines (115 loc) · 2.79 KB
/
uGameActions.pas
File metadata and controls
130 lines (115 loc) · 2.79 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
unit uGameActions;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls, FMX.Objects;
type
TActions = class(TFrame)
Rectangle1: TRectangle;
imgPause: TImage;
imgRadar: TImage;
imgSafe: TImage;
imgAbort: TImage;
procedure S(Sender: TObject);
procedure imgAbortClick(Sender: TObject);
procedure imgSafeClick(Sender: TObject);
procedure imgRadarClick(Sender: TObject);
private
FHeight : Single;
public
Procedure ShowIn(aControl : TControl);
procedure HideActions;
end;
Var
Actions : TActions;
implementation
Uses
FMX.Ani,
uField,
uField.View,
uPause,
uMedia,
uGameScore,
uGameInterfaces;
{$R *.fmx}
{ TActions }
procedure TActions.ShowIn(aControl: TControl);
begin
Parent := aControl;
FHeight := aControl.Height;
Position.x := (aControl.Width-Width)/2;
Position.Y := aControl.Height+2;
TAnimator.AnimateFloat(Self, 'Position.Y', aControl.Height-height-20, 1, TAnimationType.Out, TInterpolationType.Back);
ImgRadar.Opacity := 1;
imgSafe .Opacity := 1;
end;
procedure TActions.HideActions;
begin
TAnimator.AnimateFloat(Self, 'Position.Y', Fheight+2, 1, TAnimationType.Out, TInterpolationType.Back);
TThread.CreateAnonymousThread(
Procedure
Begin
Sleep(1010);
TThread.Queue(Nil, Procedure Begin Parent := Nil; End);
End).Start;
end;
procedure TActions.S(Sender: TObject);
begin
Media.Click2;
Score.StopTime;
Pause.ShowIn(Owner,
Procedure
Begin
Score.ResumeTime;
End);
end;
procedure TActions.imgRadarClick(Sender: TObject);
begin
If imgRadar.Opacity <> 1 Then exit;
(Owner As IMinesweeper).StartTime;
Media.SonarPulse;
FieldView.RadarPulse;
Score .IncTime(20);
imgRadar.Opacity := 0.4;
TThread.CreateAnonymousThread(
procedure
Begin
Sleep(20000);
TThread.Queue(Nil,
Procedure
Begin
TAnimator.AnimateFloat(imgRadar, 'Opacity', 1, 0.3);
End);
End).Start;
end;
procedure TActions.imgSafeClick(Sender: TObject);
Var
LPos : TPoint;
begin
If imgSafe.Opacity <> 1 Then
exit;
Media.Click2;
LPos := Field.GetSafePoint;
If LPos.x <> -1 Then
Begin
(Owner As IMinesweeper).ClickField(TMouseButton.mbLeft, LPos.X, LPos.Y, 0);
Score .IncTime(10);
imgSafe.Opacity := 0.4;
TThread.CreateAnonymousThread(
procedure
Begin
Sleep(20000);
TThread.Queue(Nil,
Procedure
Begin
TAnimator.AnimateFloat(imgSafe, 'Opacity', 1, 0.3);
End);
End).Start;
End;
end;
procedure TActions.imgAbortClick(Sender: TObject);
begin
Media.Click2;
(Owner as IMinesweeper).Terminate;
end;
end.