public void getRandomXGetsRandomX() { GameObject spawnable = new GameObject(); SpawnerPositionContainer container = spawnable.AddComponent <SpawnerPositionContainer>(); container.xPositions = new int[] { 0, 1, 2 }; int[] array = new int[20]; bool isAnElement = true; for (int i = 0; i < 20; i++) { int x = container.getRandomXForSpawning(); isAnElement = isAnElement && (x < 3 && x >= 0); } Assert.IsTrue(isAnElement); }
public void spawnSpawnsObstacle() { GameObject[] spawnableObstacles = new GameObject[5]; for (int i = 0; i < 5; i++) { GameObject spawnableObj = new GameObject(); spawnableObj.AddComponent <ModuleWeightContainer>().weight = i; SpawnerPositionContainer container = spawnableObj.AddComponent <SpawnerPositionContainer>(); container.xPositions = new int[] { 0 }; container.yPositions = new int[] { 0 }; spawnableObstacles[i] = spawnableObj; } GameObject spawnControllerHolder = new GameObject(); ObstacleSpawner spawnController = spawnControllerHolder.AddComponent <ObstacleSpawner>(); spawnController.spawnableObstacles = spawnableObstacles; spawnController.totalSumOfWeights = 10; spawnController.continuousSumOfWeights = new int[] { 0, 1, 3, 6, 10 }; GameObject gridObject = new GameObject(); Camera gridCamera = spawnControllerHolder.AddComponent <Camera>(); Grid grid = spawnControllerHolder.AddComponent <Grid>(); grid.gridObject = gridObject; grid.gridCamera = gridCamera; grid.Start(); spawnController.spawnerGrid = grid; GameObject newObstacle = spawnController.spawn(spawnControllerHolder.transform.rotation); Assert.IsNotNull(newObstacle); }