Guest User

Untitled

a guest
Jan 20th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. public enum MovementDirections
  2. {
  3. Up, // (0,1)
  4. Down, // (0,-1)
  5. Left, // (-1,0)
  6. Right // (1,0)
  7. }
  8.  
  9. public int PosX { get; set; }
  10.  
  11. public int PosY { get; set; }
  12.  
  13. public List<Cell> GetCellsOnPath(MovementDirections movementDirection) // The direction Vector
  14. {
  15. List<Cell> cellsOnPath = new List<Cell>();
  16.  
  17. switch (movementDirection)
  18. {
  19. case MovementDirections.Up:
  20. for (int i = 0; i < mapCells.Count; i++)
  21. {
  22. Cell currentCell = mapCells[i];
  23.  
  24. if (currentCell.PosY > playerInfo.CurrentCell.PosY)
  25. {
  26. cellsOnPath.Add(currentCell);
  27. }
  28. }
  29. break;
  30.  
  31. case MovementDirections.Down:
  32. for (int i = 0; i < mapCells.Count; i++)
  33. {
  34. Cell currentCell = mapCells[i];
  35.  
  36. if (currentCell.PosY < playerInfo.CurrentCell.PosY)
  37. {
  38. cellsOnPath.Add(currentCell);
  39. }
  40. }
  41. break;
  42.  
  43. case MovementDirections.Left:
  44. for (int i = 0; i < mapCells.Count; i++)
  45. {
  46. Cell currentCell = mapCells[i];
  47.  
  48. if (currentCell.PosX < playerInfo.CurrentCell.PosX)
  49. {
  50. cellsOnPath.Add(currentCell);
  51. }
  52. }
  53. break;
  54.  
  55. case MovementDirections.Right:
  56. for (int i = 0; i < mapCells.Count; i++)
  57. {
  58. Cell currentCell = mapCells[i];
  59.  
  60. if (currentCell.PosX > playerInfo.CurrentCell.PosX)
  61. {
  62. cellsOnPath.Add(currentCell);
  63. }
  64. }
  65. break;
  66. }
  67.  
  68. return cellsOnPath;
  69. }
Add Comment
Please, Sign In to add comment