SORAKH2756

Untitled

Jan 25th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. public bool checkDirections(Location currentlyOn, Location l)
  2. {
  3.     bool valid = true;
  4.     int lineDirection = CheckForLines(currentlyOn, l);
  5.  
  6.     if ((currentlyOn.row == l.row && l.column == currentlyOn.column + 1 &&  direction != (int)Direction.LEFT ) || lineDirection == 1)
  7.     {
  8.         direction = (int)Direction.RIGHT;
  9.     }
  10.     else if ((currentlyOn.row == l.row && l.column == currentlyOn.column - 1 && direction != (int)Direction.RIGHT) || lineDirection == 2)
  11.     {
  12.         direction = (int)Direction.LEFT;
  13.     }
  14.     else if ((currentlyOn.column == l.column && l.row == currentlyOn.row - 1 && direction != (int)Direction.DOWN) || lineDirection == 3)
  15.     {
  16.         direction = (int)Direction.UP;
  17.     }
  18.     else if ((currentlyOn.column == l.column && l.row == currentlyOn.row + 1 && direction != (int)Direction.UP) || lineDirection == 4)
  19.     {
  20.         direction = (int)Direction.DOWN;
  21.     }
  22.     else {
  23.         valid = false;
  24.     }
  25.  
  26.     return valid;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment