Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static Location getDistLoc( Creature C, int Range )
- {
- List<Location> possible = new List<Location>();
- possible = GetLocationsWithRange(C.Location, Range);
- possible.OrderBy( l => l.DistanceTo(new Location((int)Player.X,(int)Player.Y,(int)Player.Z)));
- return possible.FirstOrDefault();
- }
- public static List<Location> GetLocationsWithRange(Location baselocation, int range)
- {
- List<Location> possibles = new List<Location>();
- for ( int x=1; x <= range; x++ )
- {
- for ( int y=0; y <= range; y++ )
- {
- Location newloc = new Location();
- newloc.X = baselocation.X - range + x;
- newloc.Y = baselocation.Y - range + y;
- newloc.Z = baselocation.Z;
- if (IsTileWalkable(newloc.X,newloc.Y,newloc.Z))
- {
- possibles.Add(newloc);
- }
- }
- }
- return possibles.Where(l => l.DistanceTo(baselocation) == range).ToList();
- }
Add Comment
Please, Sign In to add comment