public LevelBuilder(string name, int gridX = -1, int gridY = -1) { info = LevelInfo.Find(name); this.name = info.levelName; if (info.preset != null) { var ds1 = DS1.Load(info.preset.ds1Files[0]); this.gridX = ds1.width - 1; this.gridY = ds1.height - 1; gridWidth = 1; gridHeight = 1; grid = new DS1[1] { ds1 }; } else { if (info.maze != null) { this.gridX = info.maze.sizeX; this.gridY = info.maze.sizeY; } else { this.gridX = gridX; this.gridY = gridY; } gridWidth = info.sizeX / this.gridX; gridHeight = info.sizeY / this.gridY; grid = new DS1[gridWidth * gridHeight]; } InitTileSampler(); }
public void Place(LevelPreset preset, Vector2i pos, int minIndex = 0, int maxIndex = -1) { if (maxIndex == -1) { maxIndex = preset.ds1Files.Count; } var ds1Filename = preset.ds1Files[Random.Range(minIndex, maxIndex)]; var ds1 = DS1.Load(ds1Filename); Place(ds1, pos); }
static LevelBuilder CreateBloodMoor() { var bloodMoor = new LevelBuilder("Act 1 - Wilderness 1", 8, 8); var riverN = DS1.Load(@"data\global\tiles\act1\outdoors\UriverN.ds1"); var uRiver = DS1.Load(@"data\global\tiles\act1\outdoors\Uriver.ds1"); var lRiver = DS1.Load(@"data\global\tiles\act1\outdoors\Lriver.ds1"); var bord1 = LevelPreset.Find("Act 1 - Wild Border 1"); var bord2 = LevelPreset.Find("Act 1 - Wild Border 2"); var bord3 = LevelPreset.Find("Act 1 - Wild Border 3"); var bord5 = LevelPreset.Find("Act 1 - Wild Border 5"); var bord6 = LevelPreset.Find("Act 1 - Wild Border 6"); var bord9 = LevelPreset.Find("Act 1 - Wild Border 9"); var cottage = LevelPreset.Find("Act 1 - Cottages 1"); var denEntrance = LevelPreset.Find("Act 1 - DOE Entrance"); for (int i = 0; i < bloodMoor.gridHeight; ++i) { bloodMoor.Place(lRiver, new Vector2i(bloodMoor.gridWidth - 1, i)); } for (int i = 1; i < bloodMoor.gridHeight; ++i) { bloodMoor.Place(uRiver, new Vector2i(bloodMoor.gridWidth - 2, i)); } bloodMoor.Place(riverN, new Vector2i(bloodMoor.gridWidth - 2, 0)); for (int i = 1; i < bloodMoor.gridHeight - 1; ++i) { bloodMoor.Place(bord2, new Vector2i(0, i), 0, 3); } bloodMoor.Place(bord5, new Vector2i(0, bloodMoor.gridHeight - 1)); for (int i = 1; i < 3; ++i) { bloodMoor.Place(bord1, new Vector2i(i, bloodMoor.gridHeight - 1), 0, 3); } bloodMoor.Place(bord9, new Vector2i(3, bloodMoor.gridHeight - 1)); for (int i = 1; i < bloodMoor.gridWidth - 2; ++i) { bloodMoor.Place(bord3, new Vector2i(i, 0), 0, 3); } bloodMoor.Place(bord6, new Vector2i(0, 0)); for (int i = 1; i < 5; ++i) { bloodMoor.Place(cottage, new Vector2i(i, 4 + Random.Range(-1, 1))); } bloodMoor.Place(denEntrance, new Vector2i(5, 7)); return(bloodMoor); }
static public void LoadDS1() { var assetPath = AssetDatabase.GetAssetPath(Selection.activeObject); if (!Application.isPlaying) { DT1.ResetCache(); DS1.ResetCache(); } var ds1 = DS1.Load(assetPath, mpq: false); var level = new LevelBuilder(ds1); level.Instantiate(new Vector2i(0, 0)); }