/
Ghost.cs
31 lines (29 loc) · 992 Bytes
/
Ghost.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
namespace theQuest
{
class Ghost : Enemy
{
public Ghost(Game game, Point location, Rectangle boundaries) : base(game, location, boundaries, 8) { }
public override void Move(Random random)
{
if (HitPoints > 0)
{
Point newLocation;
int movement = random.Next(0, 99);
if (movement < 67)
{
newLocation = base.Move((Direction)random.Next(1, 5), game.Boundaries);
if (newLocation == this.location) newLocation = base.Move((Direction)random.Next(1, 5), game.Boundaries);
location = newLocation;
if (NearPlayer()) game.HitPlayer(4, random);
}
else if (NearPlayer()) game.HitPlayer(4, random);
}
}
}
}