-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAggro.cs
35 lines (32 loc) · 828 Bytes
/
Aggro.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
namespace room
{
class Aggro : AI
{
public void Think(World w, Mob m)
{
if (w.RandomGenerator.Next(0, 2) == 1)
{
int x = m.X;
int y = m.Y;
// Get Player direction and walk one step toward.
if (m.X > w.Player.X)
x--;
if (m.X < w.Player.X)
x++;
if (m.Y > w.Player.Y)
y--;
if (m.Y < w.Player.Y)
y++;
if (w.CanWalk(x, y))
{
m.X = x;
m.Y = y;
}
if (w.DistanceToPlayer(x, y) > 10)
{
m.LoseAggro();
}
}
}
}
}