void Update() { if (Input.GetButtonDown("Jump")) { ClearMap(); var bsp = new BSPGenerator(40, 40, 15, 9, 1, true, tilemapFloor, tilemapWall, floor, wall); bsp.NewMap(); } }
void Start() { if (tilemapFloor == null || tilemapWall == null) { Debug.Log("No tilemaps!!!"); } else { var bsp = new BSPGenerator(40, 40, 15, 9, 1, false, tilemapFloor, tilemapWall, floor, wall); //Generate new BSP map. It's just for demo, you can set any map you want bsp.NewMap(); } }
public void GenerateNewMap(string mapType) { switch (mapType) { case "Tunneling": var tunn = new Tunneling(width, height, maxTunnels, maxTunnelLength, minTunnelLength, tunnelWidth, maxRRoomSize, minRRoomSize, maxCRoomRadius, minCRoomRadius, buildRectRoom, buildCircleRoom, randomTunnelWidth, floor, wall, floorTile, wallTile); tunn.NewMap(); if (decorations.Count > 0) { PlaceDecorations(); } break; case "CellularAutomata": var cellular = new Cellurar(width, height, deathLimit, birthLimit, numberOfSteps, chanceToStartAlive, floor, wall, floorTile, wallTile); cellular.NewMap(); if (decorations.Count > 0) { PlaceDecorations(); } break; case "BSP": var bsp = new BSPGenerator(width, height, maxLeafSize, minLeafSize, hallsWidth, randomHallWidth, floor, wall, floorTile, wallTile); bsp.NewMap(); if (decorations.Count > 0) { PlaceDecorations(); } break; case "Maze": var maze = new MazeGenerator(width, height, chanceOfEmptySpace, floor, wall, floorTile, wallTile); maze.NewMap(); if (decorations.Count > 0) { PlaceDecorations(); } break; } }
public static Dungeon GenerateDungeon() { var bspGen = new BSPGenerator(); var genOpts = new GenOptions() { DUN_WIDTH = 50 + level * 10, DUN_HEIGHT = 50 + level * 10, MAX_LEAF_AREA = 650, MIN_LEAF_SIDE = 10, MIN_ROOM_SIDE = 6 }; Dungeon dungeon = bspGen.GenDungeon(genOpts); SpawnMonsters(dungeon); return(dungeon); }
void DebugStart() { var lvlGen = new BSPGenerator(); var genOpts = new GenOptions() { DUN_WIDTH = 50, DUN_HEIGHT = 50, MAX_LEAF_AREA = 650, MIN_LEAF_SIDE = 10, MIN_ROOM_SIDE = 6 }; Dungeon dungeon = lvlGen.GenDungeon(genOpts); this.LeveMng.LoadLevel(dungeon); SetupPlayer(dungeon.PlayerStartPos, this.PlayerTestBuild); // Room room = dungeon.Rooms[0]; // Point dogStartPos = dungeon.PlayerStartPos; // dogStartPos.Y++;dogStartPos.Y++;dogStartPos.Y++; //// while(true) //// { //// dogStartPos = room.GetRandomPointInsideRoom(1); //// if (dogStartPos != dungeon.PlayerStartPos) //// { //// break; //// } //// } for (int i = 0; i < dungeon.Rooms.Count; i++) { var room = dungeon.Rooms[i]; var dogGo = (GameObject)Instantiate(this.DogPrefab); var dog = dogGo.GetComponent <Monster>(); this.LeveMng.AddCharacterOnPos(dog as Character, room.GetRandomPointInsideRoom(2)); } LevelMng.Instance.ActivateRoom(dungeon.Rooms[0]); }