-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrangementModel.cs
More file actions
190 lines (161 loc) · 5.36 KB
/
ArrangementModel.cs
File metadata and controls
190 lines (161 loc) · 5.36 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
using ImGuiNET;
using Silk.NET.Maths;
using Silk.NET.SDL;
namespace hijacking
{
internal class ArrangementModel
{
private static float movementSpeed = 2.0f;
private static float planeSpeed = movementSpeed;
private static float TurningSpeed = 0.4f;
private static float PlaneTurningSpeed = 0.6f;
public Vector3D<float> airplaneTranslation;
public Vector3D<float>[] aircraftPosition;
public Vector3D<float> roadPosition;
private bool land = false;
private Random r;
private bool colidingWithRoad = false;
private int colidingWithFighterJets = -1;
public ArrangementModel()
{
airplaneTranslation = new Vector3D<float>(0, 0, 0);
r = new Random();
int r_x = r.Next(-3000, 3000);
roadPosition = new Vector3D<float>(r_x, -1000, -18000);
aircraftPosition = new Vector3D<float>[4];
aircraftPosition[0] = new Vector3D<float>(700, 0, 700);
aircraftPosition[1] = new Vector3D<float>(-700, 0, 700);
aircraftPosition[2] = new Vector3D<float>(-700, 0, -700);
aircraftPosition[3] = new Vector3D<float>(700, 0, -700);
}
public void AdvanceTime()
{
if (colidingWithFighterJets != -1)
{
airplaneTranslation.Y -= movementSpeed;
aircraftPosition[colidingWithFighterJets].Y -= movementSpeed;
for (int i = 0; i < aircraftPosition.Length; i++)
{
if (i != colidingWithFighterJets)
{
aircraftPosition[i].Z -= movementSpeed;
}
}
return;
}
if (colidingWithRoad)
{
moveFighterJets();
airplaneTranslation.Z -= planeSpeed;
planeSpeed *= 0.9981f;
return;
}
airplaneTranslation.Z -= planeSpeed;
moveFighterJets();
if (land)
{
airplaneTranslation.Y -= 0.5f;
}
}
public void TurnLeft()
{
if (colidingWithFighterJets != -1 || colidingWithRoad)
{
return;
}
airplaneTranslation.X -= PlaneTurningSpeed;
if (airplaneTranslation.X < -10000)
{
airplaneTranslation.X = 10000;
}
}
public void TurnRight()
{
if (colidingWithFighterJets != -1 || colidingWithRoad)
{
return;
}
airplaneTranslation.X += PlaneTurningSpeed;
if (airplaneTranslation.X > 10000)
{
airplaneTranslation.X = -10000;
}
}
public void setLand()
{
this.land = true;
}
public void setColidingWithFighterJet(int numberOfJet)
{
this.colidingWithFighterJets = numberOfJet;
}
public int getColifingWithFighterJet()
{
return this.colidingWithFighterJets;
}
public void setColidingWithRoad()
{
movementSpeed = 7f;
this.colidingWithRoad = true;
}
public bool getColidingWithRoad()
{
return this.colidingWithRoad;
}
private void moveFighterJets()
{
for (int i = 0; i < aircraftPosition.Length; i++)
{
aircraftPosition[i].Z -= movementSpeed;
}
if (aircraftPosition[0].X < roadPosition.X + 700)
{
aircraftPosition[0].X += TurningSpeed;
}
else if (aircraftPosition[0].X > roadPosition.X + 700)
{
aircraftPosition[0].X -= TurningSpeed;
}
if (aircraftPosition[1].X < roadPosition.X - 700)
{
aircraftPosition[1].X += TurningSpeed;
}
else if (aircraftPosition[1].X > roadPosition.X - 700)
{
aircraftPosition[1].X -= TurningSpeed;
}
if (aircraftPosition[2].X < roadPosition.X - 700)
{
aircraftPosition[2].X += TurningSpeed;
}
else if (aircraftPosition[2].X > roadPosition.X - 700)
{
aircraftPosition[2].X -= TurningSpeed;
}
if (aircraftPosition[3].X < roadPosition.X + 700)
{
aircraftPosition[3].X += TurningSpeed;
}
else if (aircraftPosition[3].X > roadPosition.X + 700)
{
aircraftPosition[3].X -= TurningSpeed;
}
}
public float getMovementSpeed()
{
return movementSpeed;
}
public void setMovementSpeed(float speed)
{
if (!colidingWithRoad)
{
movementSpeed = speed;
planeSpeed = speed;
}
}
public float getTurningSpeed()
{
return PlaneTurningSpeed;
}
}
}