-
Notifications
You must be signed in to change notification settings - Fork 0
/
Level.cs
39 lines (33 loc) · 893 Bytes
/
Level.cs
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
using System;
using System.Drawing;
namespace func_rocket
{
public class Level
{
public Level(string name, Rocket rocket, Vector target, Gravity gravity, Physics physics)
{
Name = name;
Rocket = rocket;
InitialRocket = rocket;
Target = target;
this.physics = physics;
Gravity = gravity;
}
public readonly string Name;
public readonly Rocket InitialRocket;
private readonly Physics physics;
public Rocket Rocket;
public Vector Target;
public Gravity Gravity { get; private set; }
public bool IsCompleted => (Rocket.Location - Target).Length < 20;
public void Move(Size spaceSize, Turn turn)
{
var force = ForcesTask.Sum(ForcesTask.GetThrustForce(1.0), ForcesTask.ConvertGravityToForce(Gravity, spaceSize));
Rocket = physics.MoveRocket(Rocket, force, turn, spaceSize, 0.3);
}
public void Reset()
{
Rocket = InitialRocket;
}
}
}