public static void Save() { if (cur == string.Empty || cur == "HAS_BEEN_CLOSED") { return; } Tilemapper.SaveMapsToCurrentScene(); Engine.SaveEngineState(); form.SetStatus("'" + cur + "' has been saved.", Main.StatusType.Message); }
public void Resize(int width, int height) { Tile[,] newArray = new Tile[width, height]; for (int i = 0; i < map.GetLength(0); i++) { for (int j = 0; j < map.GetLength(1); j++) { newArray[i, j] = map[i, j]; } } map = newArray; Tilemapper.SetCurrentTile(); }
public void RemoveTile(int x, int y, int w, int h, bool converts) { x -= this.x; y -= this.y; try { if (x < 0 || y < 0) { return; } if (w == tilesize && h == tilesize) { if (map[x, y] != null && !map[x, y].build) { return; } map[x, y] = new Tile(); } else { for (int yy = 0; yy < h / tilesize; yy++) { for (int xx = 0; xx < w / tilesize; xx++) { RemoveTile(x + xx, y + yy, tilesize, tilesize, false); } } } if (converts) { Tilemapper.ConvertAndSetMap(this); } } catch (Exception exc) { Engine.ExecuteScript("lx.StopMouse(2);"); Feed.GiveException("Tile Remove", exc); } }
public void CopyFolder(int prevScene, HierarchyFolder f) { HierarchyFolder cf = new HierarchyFolder(folders.Count, f.name); foreach (HierarchyItem i in f.content) { EngineObject temp = Engine.scenes[prevScene].objects[i.engineId].Clone(); if (temp.parent != -1) { continue; } EngineObject tempChild = null; if (temp.child != -1) { tempChild = Engine.scenes[prevScene].objects[temp.child].Clone(); } string copies = ""; int amount = 0; while (Engine.GetEngineObjectWithVarName(temp.Variable() + copies) != null) { amount++; copies = "_" + amount; } if (copies != "") { temp.Rename(temp.Variable() + copies); if (tempChild != null) { tempChild.Rename(tempChild.Variable() + copies); } } int result = 0; if (temp.child == -1) { result = Engine.AddExistingEngineObject(temp); Engine.scenes[Engine.eSettings.currentScene].objects[result].id = result; } else { Point r = Engine.AddExistingEngineObjectWithChild(temp, tempChild); Engine.scenes[Engine.eSettings.currentScene].objects[r.X].child = r.Y; Engine.scenes[Engine.eSettings.currentScene].objects[r.Y].parent = r.X; Engine.scenes[Engine.eSettings.currentScene].objects[r.X].id = r.X; Engine.scenes[Engine.eSettings.currentScene].objects[r.Y].id = r.Y; result = r.X; } if (temp.type == EngineObjectType.Tilemap) { temp.tileMap = Tilemapper.AddMap(Engine.scenes[prevScene].tilemaps[temp.tileMap]); } cf.AddItem(new HierarchyItem(result)); } folders.Add(cf); }
public void SetTile(int x, int y, Tile t, bool converts) { x -= this.x; y -= this.y; try { if (x < 0 || y < 0) { return; } if (x >= map.GetLength(0)) { Resize(x + 1, map.GetLength(1)); } if (y >= map.GetLength(1)) { Resize(map.GetLength(0), y + 1); } if (map[x, y] != null && map[x, y].build && map[x, y].cX == Tilemapper.selected.cX && map[x, y].cY == Tilemapper.selected.cY && map[x, y].r == Tilemapper.selected.r) { return; } if (t.cW == tilesize && t.cH == tilesize) { t.build = true; map[x, y] = t; } else { for (int yy = 0; yy < t.cH / tilesize; yy++) { for (int xx = 0; xx < t.cW / tilesize; xx++) { Tile tt = new Tile() { sprite = t.sprite, cX = t.cX + xx * tilesize, cY = t.cY + yy * tilesize, cW = tilesize, cH = tilesize, build = true }; SetTile(x + this.x + xx, y + this.y + yy, tt, false); } } } if (converts) { Tilemapper.ConvertAndSetMap(this); } } catch (Exception exc) { Engine.ExecuteScript("lx.StopMouse(0);"); Feed.GiveException("Tile Set", exc); } }