public static Array <Point> setPropertyLocations(int x, int y, int width, int height, Array <Array <int> > map, int property, Array <Point> locations, Array <int> properties = null, int ignore = 0) { var list = new Array <Point>(); int h = map.length; int w = map[0].length; int toX = x + width; int toY = y + height; int r, c; for (r = y; r < toY; r++) { for (c = x; c < toX; c++) { //if(c >= 0 && r >= 0 && c < w && r < h && ((map[r][c] & property) == property) && !((map[r][c] & ignore) == ignore)) { if (c >= 0 && r >= 0 && c < w && r < h && ((map[r][c] & property) == property) && !((map[r][c] & ignore) > 0)) { locations.push(new Point(c, r)); if (properties != null) { properties.push(map[r][c]); } } } } return(list); }
/* Create indestructible walls around unreachable areas and fill insides with VOID */ public void fillVoid(Point entry) { Point p = entry; var voidMap = create2DArray(width, height, 0); int i; int x; int y; var points = new Array <Point> { p }; int property = 0; int length = points.Count; voidMap[(int)p.y][(int)p.x] = 1; while (length > 0) { while ((length--) > 0) { p = points.shift(); x = (int)p.x; y = (int)p.y; property = map[y][x]; if (((property & WALL) == WALL) && !((property & ENEMY) > 0)) { continue; } // cardinals if (y > 0 && voidMap[y - 1][x] == 0) { points.push(new Point(x, y - 1)); voidMap[y - 1][x] = 1; } if (x < width - 1 && voidMap[y][x + 1] == 0) { points.push(new Point(x + 1, y)); voidMap[y][x + 1] = 1; } if (y < height - 1 && voidMap[y + 1][x] == 0) { points.push(new Point(x, y + 1)); voidMap[y + 1][x] = 1; } if (x > 0 && voidMap[y][x - 1] == 0) { points.push(new Point(x - 1, y)); voidMap[y][x - 1] = 1; } } length = points.Count; } int r, c; for (r = 0; r < height; r++) { for (c = 0; c < width; c++) { if (voidMap[r][c] == 0 && !((map[r][c] & INDESTRUCTIBLE) > 0)) { map[r][c] = VOID; } if (voidMap[r][c] == 1 && ((property & WALL) == WALL) && !((property & ENEMY) > 0) && ( (r > 0 && voidMap[r - 1][c] == 0) || (c < width - 1 && voidMap[r][c + 1] == 0) || (r < height - 1 && voidMap[r + 1][c] == 0) || (c > 0 && voidMap[r][c - 1] == 0) ) ) { map[r][c] = WALL | INDESTRUCTIBLE; } } } }
public string[] Split(string[] e, StringSplitOptions o) { if (e.Length != 1) throw new NotImplementedException(""); var x = ((ActionScript.String)(object)this).split(e[0]); if (o == StringSplitOptions.None) return x; var a = new Array(); foreach (var v in x) { if (!string.IsNullOrEmpty(v)) a.push(v); } return (string[])(object)a; }