public bool SideCaseIsNotWall(DIRECTION dir, AnimateObject obj) { switch(dir) { case DIRECTION.DOWN: if (obj.GetCaseYSup(map.Tile_size) != -1) { if (map.Grid[obj.GetCaseYSup(map.Tile_size)][obj.GetAcutalCaseX(map.Tile_size)].Content == CELL_CONTENT.WALL) { return false; } } break; case DIRECTION.UP: if (obj.GetCaseYInf(map.Tile_size) != -1) { if (map.Grid[obj.GetCaseYInf(map.Tile_size) - 1][obj.GetAcutalCaseX(map.Tile_size)].Content == CELL_CONTENT.WALL) { return false; } } break; case DIRECTION.LEFT: if (obj.GetCaseXInf(map.Tile_size) != -1) { if (map.Grid[obj.GetAcutalCaseY(map.Tile_size)][obj.GetCaseXInf(map.Tile_size) - 1].Content == CELL_CONTENT.WALL) { return false; } } break; case DIRECTION.RIGHT: if (obj.GetCaseXSup(map.Tile_size) != -1) { if (map.Grid[obj.GetAcutalCaseY(map.Tile_size)][obj.GetCaseXSup(map.Tile_size)].Content == CELL_CONTENT.WALL) { return false; } } break; } return true; }
public List<DIRECTION> GetPossibleDirection(AnimateObject obj) { List<DIRECTION> ret = new List<DIRECTION>(); if (this.SideCaseIsNotWall(DIRECTION.DOWN, obj)) { ret.Add(DIRECTION.DOWN); } if (this.SideCaseIsNotWall(DIRECTION.UP, obj)) { ret.Add(DIRECTION.UP); } if (this.SideCaseIsNotWall(DIRECTION.RIGHT, obj)) { ret.Add(DIRECTION.RIGHT); } if (this.SideCaseIsNotWall(DIRECTION.LEFT, obj)) { ret.Add(DIRECTION.LEFT); } return ret; }