private Point GetRandomDirection(IWorld readonlyWorld) { var directions = new[] { new Point(1, 0), new Point(-1, 0), new Point(0, 1), new Point(0, -1) } .Where(d => !readonlyWorld.GetObjectsAt(Location.Add(d)).Any()) .Concat(new[] { new Point(0, 0), }) .ToList(); return(directions[random.Next(directions.Count)]); }
public void MoveLocation(Location loc, Direction dir) { loc.Add(PathFinding.Directions[(int)dir]); }
public override void Act(IWorld world) { var destination = GetDirection(world); Destination = Location.Add(destination); }