Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private Cell[,] mapCells = new Cell[10, 10];
- bool cellExists = index.x >= 0 && // check left
- index.y >= 0 && // check bottom
- index.x < mapCells.GetLength(0) && // check right
- index.y < mapCells.GetLength(1); // check top
- Vector2 dir = new Vector2(/* this can be
- (0,1) // up
- (0,-1) // down
- (-1,0) // left
- (1,0) // right
- */);
- public static class Extensions
- {
- public static bool IsExist(this Cell[,] mapCells, Cell index)
- {
- bool cellExists = index.x >= 0 &&
- index.y >= 0 &&
- index.x < mapCells.GetLength(0) &&
- index.y < mapCells.GetLength(1);
- return cellExists;
- }
- }
- mapCells.IsExist(index);
Add Comment
Please, Sign In to add comment