public MapLayer(int[] map, int width, int height, int layer) { Layer = layer; Map = new int[width, height]; Bouncers = new List <Node> [width, height]; Walls = new List <Rail> [width, height]; Water = new List <Rectangle> [width, height]; Teleports = new List <KeyValuePair <Rectangle, List <Rectangle> > > [width, height]; Elevations = new Elevation[width, height]; var i = 0; for (int r = 0; r < height; r++) { for (var c = 0; c < width; c++) { Map[c, r] = map[i]; Bouncers[c, r] = WorldHelpers.AddBouncerNodes(WorldHelpers.GetBouncers(map[i]), layer); Walls[c, r] = WorldHelpers.AddWallRails(WorldHelpers.GetLineSegments(map[i]), layer); Water[c, r] = WorldHelpers.GetWater(map[i]); Teleports[c, r] = WorldHelpers.GetTeleports(map[i]); Elevations[c, r] = WorldHelpers.GetElevation(map[i]); if (Layer == 2 && Elevations[c, r] != Elevation.Flat) { throw new Exception("Yeah nah we can only have elevations on layer 1"); } i++; } } Width = width; Height = height; }
private void UpdateTileDefs() { Rails = WorldHelpers.AddWallRails(WorldHelpers.GetLineSegments(CurrentTile), 1); SpecialRails = WorldHelpers.AddWallRails(WorldHelpers.GetLineSpecialSegments(CurrentTile, new Point(-1, -1)), 1); Bouncers = WorldHelpers.AddBouncerNodes(WorldHelpers.GetBouncers(CurrentTile), 1); Water = WorldHelpers.GetWater(CurrentTile); Teleporters = WorldHelpers.GetTeleporters(CurrentTile); Elevation = WorldHelpers.GetElevation(CurrentTile); Connections = WorldHelpers.GetSideConnections(CurrentTile); }