Guest User

Untitled

a guest
Jan 23rd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. private Cell[,] mapCells = new Cell[10, 10];
  2.  
  3. bool cellExists = index.x >= 0 && // check left
  4. index.y >= 0 && // check bottom
  5. index.x < mapCells.GetLength(0) && // check right
  6. index.y < mapCells.GetLength(1); // check top
  7.  
  8. Vector2 dir = new Vector2(/* this can be
  9. (0,1) // up
  10. (0,-1) // down
  11. (-1,0) // left
  12. (1,0) // right
  13. */);
  14.  
  15. public static class Extensions
  16. {
  17. public static bool IsExist(this Cell[,] mapCells, Cell index)
  18. {
  19. bool cellExists = index.x >= 0 &&
  20. index.y >= 0 &&
  21. index.x < mapCells.GetLength(0) &&
  22. index.y < mapCells.GetLength(1);
  23.  
  24. return cellExists;
  25. }
  26. }
  27.  
  28. mapCells.IsExist(index);
Add Comment
Please, Sign In to add comment