/// <summary> /// Generate the floor. This creates and builds the rooms that comprise it. /// </summary> public void Generate(int floorID) { FloorID = floorID; // Seeds the random generator. Use the base seed for the level + the floor ID to // offset the seed by the floor. By doing so, we'll get a different generation // pattern for each successive floor in a way that is easily reproducible // in a save/load situation. Random.InitState((GameController.seed + floorID) % GameController.MaxSeed); generator = generators[Random.Range(0, generators.Length)]; generator.Generate(); // Ensure the player cannot spawn inside of walls by clearing any nearby walls. // TODO: We need to make sure there's no case where the player will get trapped from this. ClearAround(new Vec2i(5, 5)); GameObject.FindWithTag("Player").transform.position = new Vector3(5.0f, 5.0f); if (firstTime) { firstTime = false;//Don't } else { GameController.Instance.AddScore(10); } Pathfinder.Generate(); GameController.Instance.SaveGame(); }
private void Awake() { Instance = this; spritePool = GetComponent <SpritePool>(); colliderPool = GetComponent <ColliderPool>(); generator = new FloorGenerator(this); generator.Generate(RoomCount); }
/// <summary> /// Generate the floor. This creates and builds the rooms that comprise it. /// </summary> public void Generate() { foreach (Room room in rooms.Values) { room.Destroy(); } rooms.Clear(); generator.Generate(RoomCount); GameObject.FindWithTag("Player").transform.position = new Vector3(5.0f, 5.0f); }