-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCircle.cs
57 lines (46 loc) · 1.28 KB
/
Circle.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using ElfKingdom;
namespace SkillZ
{
public class Circle
{
private Location center;
private float radius;
public Circle(Location center, float radius)
{
this.center = center;
this.radius = radius;
}
public Circle(MapObject center, float radius)
{
this.center = center.GetLocation();
this.radius = radius;
}
public Location GetCenter()
{
return center;
}
public float GetRadius()
{
return radius;
}
public bool IsLocationInside(MapObject source)
{
return source.DistanceF(center) <= radius;
}
public override string ToString()
{
return $"({center.Row}, {center.Col}) - radius = {radius}";
}
public override bool Equals(object obj)
{
if (this == obj) return true;
if (obj == null || !GetType().Equals(obj.GetType())) return false;
Circle other = (Circle)obj;
return center.Col == other.center.Col && center.Row == other.center.Row && radius == other.radius;
}
public override int GetHashCode()
{
return center.Col;
}
}
}