Guest User

Untitled

a guest
Jul 18th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.19 KB | None | 0 0
  1.         public static Location getDistLoc( Creature C, int Range )
  2.         {
  3.             List<Location> possible = new List<Location>();
  4.  
  5.             possible = GetLocationsWithRange(C.Location, Range);
  6.  
  7.             possible.OrderBy( l => l.DistanceTo(new Location((int)Player.X,(int)Player.Y,(int)Player.Z)));
  8.  
  9.             return possible.FirstOrDefault();
  10.         }
  11.  
  12.         public static List<Location> GetLocationsWithRange(Location baselocation, int range)
  13.         {
  14.             List<Location> possibles = new List<Location>();
  15.  
  16.             for ( int x=1; x <= range; x++ )
  17.             {
  18.                 for ( int y=0; y <= range; y++ )
  19.                 {
  20.                     Location newloc = new Location();
  21.                     newloc.X = baselocation.X - range + x;
  22.                     newloc.Y = baselocation.Y - range + y;
  23.                     newloc.Z = baselocation.Z;
  24.                     if (IsTileWalkable(newloc.X,newloc.Y,newloc.Z))
  25.                     {
  26.                         possibles.Add(newloc);
  27.                     }                  
  28.                 }
  29.             }
  30.  
  31.             return possibles.Where(l => l.DistanceTo(baselocation) == range).ToList();
  32.         }
Add Comment
Please, Sign In to add comment