public MapEditor(InputHandler Input, int levelWidth, int levelHeight, Modes mapMode, MapEditorGuiScreen parent, List <GEntity> tiles, List <GEntity> entities, List <GEntity> spawners) { _parent = parent; _mode = mapMode; LevelWidth = levelWidth; LevelHeight = levelHeight; this.Input = Input; Entities = new List <GEntity>(); Tiles = new List <GEntity>(); for (int i = 0; i < tiles.Count; i++) { Entities.Add(null); Tiles.Add(null); } int x, y; foreach (GEntity g in entities) { x = g.iX / GTile.WIDTH; y = g.iY / GTile.HEIGHT; Entities[y * LevelWidth + x] = g; } foreach (GEntity g in tiles) { x = g.iX / GTile.WIDTH; y = g.iY / GTile.HEIGHT; Tiles[y * LevelWidth + x] = g; } foreach (GEntity g in spawners) { x = g.iX / GTile.WIDTH; y = g.iY / GTile.HEIGHT; Entities[y * LevelWidth + x] = g; } _endConstruct(); }
public MapEditor(InputHandler Input, int levelWidth, int levelHeight, int fillTile, Modes mapMode, MapEditorGuiScreen parent) { _parent = parent; _mode = mapMode; LevelWidth = levelWidth; LevelHeight = levelHeight; this.Input = Input; Tiles = new List <GEntity>(); Entities = new List <GEntity>(); Spawners = new List <GEntity>(); GEntity e, t; int tx, ty; for (int i = 0; i < LevelHeight; i++) { ty = i * GTile.HEIGHT; for (int j = 0; j < levelWidth; j++) { e = t = null; tx = j * GTile.WIDTH; if (_isBorder(j, i)) { Entities.Add(new Metal(tx, ty)); Tiles.Add(new GTile(tx, ty, true)); continue; } switch (fillTile) { case TileType.WALL: e = new Wall(tx, ty); t = new Gravel(tx, ty); break; case TileType.METAL: e = new Metal(tx, ty); break; case TileType.SAND: t = new Sand(tx, ty); break; case TileType.WATER: t = new Water(tx, ty); break; case TileType.GRAVEL: t = new Gravel(tx, ty); break; case TileType.GRASS: t = new Grass(tx, ty); break; } if (t == null) { t = new GTile(tx, ty, true); } Tiles.Add(t); Entities.Add(e); } } _endConstruct(); }