mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2026-01-08 19:33:31 -08:00
Add C# implementaion of 86 Target
This commit is contained in:
22
86 Target/csharp/Target/Explosion.cs
Normal file
22
86 Target/csharp/Target/Explosion.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
namespace Target
|
||||
{
|
||||
internal class Explosion
|
||||
{
|
||||
private readonly Point _position;
|
||||
|
||||
public Explosion(Point position, Offset targetOffset)
|
||||
{
|
||||
_position = position;
|
||||
FromTarget = targetOffset;
|
||||
DistanceToTarget = targetOffset.Distance;
|
||||
}
|
||||
|
||||
public Point Position => _position;
|
||||
public Offset FromTarget { get; }
|
||||
public float DistanceToTarget { get; }
|
||||
public string GetBearing() => _position.GetBearing();
|
||||
|
||||
public bool IsHit => DistanceToTarget <= 20;
|
||||
public bool IsTooClose => _position.Distance < 20;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user