private GameObject LoadNextLevel() { currentLevelIndex++; GameObject nextLvl = levelBuilder.Build(currentLevelIndex); nextLvl.transform.parent = gameObject.transform; nextLvl.transform.position = CalculateNextLevelPosition(ref nextLvl); return(nextLvl); }
void Start() { gameManagerMap = GameObject.Find("GameManagerMap").GetComponent <MapManager>(); gameManagerMap.player.SetActive(false); canvas = GameObject.Find("Canvas"); LevelNumber = GameObject.Find("Levels").GetComponent <Levels>().m_Levels.Count; currentLevel = GameObject.Find("Levels").GetComponent <Levels>().m_Levels[(int)Random.Range(0, LevelNumber)]; m_LevelBuilder.Build(currentLevel); m_Player = FindObjectOfType <Player>(); }
public void NextLevel() { m_LevelBuilder.NextLevel(); m_LevelBuilder.Build(); GetComponent <AudioSource>().clip = mainbackgroundsound; audioSource_background.Play(); StartCoroutine(ResetSceneASync()); Level = m_LevelBuilder.m_CurrentLevel + 1; levelText.text = "Stage" + Level; time = timeAmt; }
public void AttachingAMonstor_WillReduceItsHitPoints() { var state = MeleeWeapon.FormatState("Wooden Club", "Me1", 1, 12, -1, 1, 7.5, 0, 50); var testNum = 1; var fakeRandomNumbers = GetGenerator(testNum); var registry = new DispatchRegistry(); var dispatcher = new Dispatcher(registry); var fakeLogger = new FakeLogger(_output); var mazeDescriptor = FakeMazeDescriptorBuilder.Build(1, 1, 4, 2); var builder = new LevelBuilder(fakeRandomNumbers, mazeDescriptor, fakeLogger, dispatcher, registry); builder.Build(testNum); var me = ActorBuilder.Build <Me>(Coordinate.NotSet, registry, Me.FormatState(10, 10)); dispatcher.EnqueueTeleport(me); var monster = ActorBuilder.Build <Monster>(Coordinate.NotSet, registry, Monster.FormatState(10, 10)); dispatcher.EnqueueTeleport(monster); dispatcher.Dispatch(); var weapon = new MeleeWeapon(fakeRandomNumbers, registry, dispatcher, state); dispatcher.EnqueueUse(weapon, Compass8Points.East); dispatcher.Dispatch(); monster = (Monster)registry.GetDispatchee(monster.UniqueId); var expected = "HitPoints [7], ArmourClass [10]"; var actual = $"HitPoints [{monster.HitPoints}], ArmourClass [{monster.ArmourClass}]"; Assert.Equal(expected, actual); }
public void WhenBuiltDispatcher_ShouldHaveMeInMaze(int testNum, int blocksPerTile) { var registry = new DispatchRegistry(); var dispatcher = new Dispatcher(registry); var fakeRandomNumbers = GetGenerator(testNum); var fakeLogger = new FakeLogger(_output); var mazeDescriptor = FakeMazeDescriptorBuilder.Build(1, 1, 4, blocksPerTile); var builder = new LevelBuilder(fakeRandomNumbers, mazeDescriptor, fakeLogger, dispatcher, registry); builder.Build(testNum); var me = new Me(Coordinate.NotSet, registry, Me.FormatState(10, 10)); dispatcher.EnqueueTeleport(me); dispatcher.Dispatch(); var maze = registry.GetDispatchee("Maze1"); var actual = maze.ToString(); var expected = GetExpectation(testNum); _output.WriteLine(expected); _output.WriteLine('='.ToPaddedString(10)); _output.WriteLine(actual); Assert.Equal(expected, actual); }
public void Move_Me_CanMoveIntoEmptySpace() { var testNum = 1; var registry = new DispatchRegistry(); var dispatcher = new Dispatcher(registry); var fakeRandomNumbers = GetGenerator(testNum); var fakeLogger = new FakeLogger(_output); var mazeDescriptor = FakeMazeDescriptorBuilder.Build(1, 1, 4, 2); var builder = new LevelBuilder(fakeRandomNumbers, mazeDescriptor, fakeLogger, dispatcher, registry); builder.Build(GetLevel(testNum)); var me = ActorBuilder.Build <Me>(Coordinate.NotSet, registry, Me.FormatState(10, 10)); dispatcher.EnqueueTeleport(me); dispatcher.Dispatch(); // t+1 dispatcher.EnqueueMove(me, Compass8Points.South); dispatcher.Dispatch(); var expected = GetExpectation(testNum); var actual = registry.GetDispatchee("Maze1").ToString(); _output.WriteLine(expected); _output.WriteLine('='.ToPaddedString(10)); _output.WriteLine(actual); Assert.Equal(expected, actual); }
public void SetupLevel() { if (m_levelBuilder) { m_levelBuilder.Build(); } }
IEnumerator ResetSceneASync() { if (SceneManager.sceneCount > 1) { AsyncOperation asyncUnload = SceneManager.UnloadSceneAsync("LevelScene"); while (!asyncUnload.isDone) { yield return(null); Debug.Log("Unloading..."); } Debug.Log("Unload Done"); Resources.UnloadUnusedAssets(); } AsyncOperation asyncLoad = SceneManager.LoadSceneAsync("LevelScene", LoadSceneMode.Additive); while (!asyncLoad.isDone) { yield return(null); Debug.Log("Loading..."); } SceneManager.SetActiveScene(SceneManager.GetSceneByName("LevelScene")); m_LevelBuilder.Build(); m_Player = FindObjectsOfType <Player>(); Debug.Log("Level loaded"); }
public void LoadCurrentLevel() { levelBuilder = GameObject.Find("LevelBuilder").GetComponent <LevelBuilder>(); currentLevel = levelBuilder.Build(currentLevelIndex); currentLevel.transform.parent = gameObject.transform; currentLevelScript = currentLevel.GetComponent <Level>(); currentLevelScript.SetIsCurrentLevel(true); cameraMovement.SetCameraPos(currentLevelScript.GetCameraFocus()); if (currentLevelIndex < 25) { nextLevel = LoadNextLevel(); } }
public void Regenerate() { if (currentRoom.Value == null) { return; } if (previousRoom != null) { GameObject.Destroy(previousRoom); } previousRoom = LevelBuilder.Build(currentRoom.Value).Root; }
public void TestBuilder() { LevelBuilder levelBuilder = new LevelBuilder(); //Setup brick int x = 4; int y = 4; BrickStatus state = BrickStatus.destructible; int durability = 1; //Setup variable of level string levelName = "level1"; PersonalSounds music = new PersonalSounds("musicPath", "musicTheme"); BackgroundTexture background = new BackgroundTexture("backgroundPath", "backgroundTheme"); BallTexture ball = new BallTexture("ballPath", "ballTheme"); PaddleTexture paddle = new PaddleTexture("paddlePath", "paddleTheme"); //Create level with levelBuilder levelBuilder.brickSelected(x, y, state, durability); levelBuilder.setLevelName(levelName); levelBuilder.SetMusic(music.GetMusicPath(), music.GetMusicTheme()); levelBuilder.SetBackGround(background.GetBackgroundPath(), background.GetBackgroundTheme()); levelBuilder.SetBall(ball.GetBallPath(), ball.GetBallTheme()); levelBuilder.setPaddle(paddle.GetPaddlePath(), paddle.GetPaddleTheme()); Level level = levelBuilder.Build(); //Create level with classic constructor int height = 1, width = 1; ISet <BrickBasic> brick = new HashSet <BrickBasic>(); brick.Add(new BrickBasic(new Position(x - 1, y - 1), height, width, state, durability, BrickBasic.GetDefaultBrickTexturePath())); Level levelTest = new Level(levelName, brick, music, background, ball, paddle); //Check if all parameters are the same Assert.AreEqual(levelTest.GetLevelName(), level.GetLevelName()); Assert.AreEqual(levelTest.GetBackground().GetBackgroundPath(), level.GetBackground().GetBackgroundPath()); Assert.AreEqual(levelTest.GetBackground().GetBackgroundTheme(), level.GetBackground().GetBackgroundTheme()); Assert.AreEqual(levelTest.GetMusic().GetMusicPath(), level.GetMusic().GetMusicPath()); Assert.AreEqual(levelTest.GetMusic().GetMusicTheme(), level.GetMusic().GetMusicTheme()); Assert.AreEqual(levelTest.GetBallTexture().GetBallPath(), level.GetBallTexture().GetBallPath()); Assert.AreEqual(levelTest.GetBallTexture().GetBallTheme(), level.GetBallTexture().GetBallTheme()); Assert.AreEqual(levelTest.GetPaddleTexture().GetPaddlePath(), level.GetPaddleTexture().GetPaddlePath()); Assert.AreEqual(levelTest.GetPaddleTexture().GetPaddleTheme(), level.GetPaddleTexture().GetPaddleTheme()); //Check if levels are equals Assert.IsTrue(levelTest.EqualLevel(level)); }
private void Start() { if (shouldUseSeed.Value) { Debug.Log($"Initializing game with seed {seedValue.Value}"); Random.InitState(seedValue.Value.GetHashCode()); } LevelBuildData data = LevelDataGenerator.CreateNewLevel(allThemes[0]); Level.Current = LevelBuilder.Build(data); player.transform.position = data.SpawnPosition; shouldUseSeed.Value = false; }
public void PlaceTwoRooms_WherePlacingTheSecondRoomCausesMazeToGrow() { var fakeRandomNumbers = new FakeRandomNumberGenerator(); void SetupTwoRooms() { fakeRandomNumbers .PopulateRandomForRoomCount(2) .PopulateRandomForTestRoom(StandardTestRoom.Second) .PopulateRandomForTestRoom(StandardTestRoom.Second) ; } void SetupDoorForFirstRoom() { fakeRandomNumbers .AddCoordinates(0, 0) // Door placement, should be empty tile to walk from, but it is a wall, top left corner .AddCoordinates(3, 3) // Door placement, empty tile to start walk from .AddDirection(Compass8Points.South) // direction to walk to find a wall and place a door ; } void SetupDoorForSecondRoom() { fakeRandomNumbers .AddCoordinates(5, 9) // Door placement, should be empty tile to walk from, but it is a wall, bottom right corner .AddCoordinates(4, 8) // Door placement, empty tile to start walk from .AddDirection(Compass8Points.North) // direction to walk to find a wall and place a door ; } void SetupCoordinatesForPlacingFirstRoom() { fakeRandomNumbers .AddCoordinates(3, 3) // should succeed ; } void SetupCoordinatesForPlacingSecondRoom() { fakeRandomNumbers .AddCoordinates(17, 15) // placing room outside of maze .AddCoordinates(17, 15) // placing room outside of maze .AddCoordinates(17, 15) // placing room outside of maze, show grow after third attempt .AddCoordinates(17, 15) // placing room outside of old maze, now inside new maze so succeeds ; } var registry = new DispatchRegistry(); var dispatcher = new Dispatcher(registry); SetupTwoRooms(); SetupDoorForFirstRoom(); SetupDoorForSecondRoom(); SetupCoordinatesForPlacingFirstRoom(); SetupCoordinatesForPlacingSecondRoom(); var fakeLogger = new FakeLogger(_output); var mazeDescriptor = FakeMazeDescriptorBuilder.MazeRoomsWithTwoBlocks(); var builder = new LevelBuilder(fakeRandomNumbers, mazeDescriptor, fakeLogger, dispatcher, registry); builder.Build(1, connectTunnels: false); var expected = GetExpectation(2); var actual = (Maze)registry.GetDispatchee("Maze1"); var actualString = actual.ToString(); _output.WriteLine('='.ToPaddedString(10)); _output.WriteLine(expected); _output.WriteLine('='.ToPaddedString(10)); _output.WriteLine(actualString); _output.WriteLine('='.ToPaddedString(10)); Assert.Equal(expected, actualString); }
private void Awake() { Level.Current = LevelBuilder.Build(roomData); }
public void PlaceTwoRooms_WhereFirstAndSecondDoNotOverlap() { var fakeRandomNumbers = new FakeRandomNumberGenerator(); void SetupTwoRooms() { fakeRandomNumbers .PopulateRandomForRoomCount(2) .PopulateRandomForTestRoom(StandardTestRoom.First) .PopulateRandomForTestRoom(StandardTestRoom.First) ; } void SetupDoors() { fakeRandomNumbers .AddCoordinates(2, 2) // Door placement, empty tile to start walk from .AddDirection(Compass8Points.West) // direction to walk to find a wall and place a door .AddCoordinates(3, 3) // Door placement, empty tile to start walk from .AddDirection(Compass8Points.East) // direction to walk to find a wall and place a door ; } void SetupCoordinatesForPlacingFirstRoom() { fakeRandomNumbers .AddCoordinates(1, 1) // too close to edge of maze, should fail .AddCoordinates(2, 2) // too close to edge of maze, should fail .AddCoordinates(3, 3) // should succeed ; } void SetupCoordinatesForPlacingSecondRoom() { fakeRandomNumbers .AddCoordinates(4, 4) // overlaps first so should fail .AddCoordinates(6, 6) // too near first so should fail .AddCoordinates(17, 10) // does not overlap and not close so should succeed ; } var registry = new DispatchRegistry(); var dispatcher = new Dispatcher(registry); SetupTwoRooms(); SetupDoors(); SetupCoordinatesForPlacingFirstRoom(); SetupCoordinatesForPlacingSecondRoom(); var fakeLogger = new FakeLogger(_output); var mazeDescriptor = FakeMazeDescriptorBuilder.MazeRoomsWithTwoBlocks(); var builder = new LevelBuilder(fakeRandomNumbers, mazeDescriptor, fakeLogger, dispatcher, registry); builder.Build(1, connectTunnels: false); var expected = GetExpectation(1); var actual = (Maze)registry.GetDispatchee("Maze1"); var actualString = actual.ToString(); _output.WriteLine('='.ToPaddedString(10)); _output.WriteLine(expected); _output.WriteLine('='.ToPaddedString(10)); _output.WriteLine(actualString); _output.WriteLine('='.ToPaddedString(10)); Assert.Equal(expected, actualString); }
private void selectedLevelToolStripMenuItem_Click(object sender, EventArgs e) { LevelBuilder lb = new LevelBuilder(); lb.Build(levelPanel1.SelectedLevel); }