/// <summary> /// Initializes a new instance of the <see cref="PatternBrush{TPixel}"/> class. /// </summary> /// <param name="brush">The brush.</param> internal PatternBrush(PatternBrush <TPixel> brush) { this.pattern = brush.pattern; this.patternVector = brush.patternVector; }
/// <summary> /// Applies the process to the specified portion of the specified <see cref="ImageBase{TColor}"/> at the specified location /// and with the specified size. /// </summary> /// <param name="targetPixels">The target pixels to apply the process to.</param> /// <param name="sourcePixels">The source pixels. Cannot be null.</param> /// <param name="sourceRectangle"> /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to draw. /// </param> /// <param name="kernel">The kernel operator.</param> private void ApplyConvolution(PixelAccessor <TColor> targetPixels, PixelAccessor <TColor> sourcePixels, Rectangle sourceRectangle, Fast2DArray <float> kernel) { int kernelHeight = kernel.Height; int kernelWidth = kernel.Width; int radiusY = kernelHeight >> 1; int radiusX = kernelWidth >> 1; int startY = sourceRectangle.Y; int endY = sourceRectangle.Bottom; int startX = sourceRectangle.X; int endX = sourceRectangle.Right; int maxY = endY - 1; int maxX = endX - 1; Parallel.For( startY, endY, this.ParallelOptions, y => { for (int x = startX; x < endX; x++) { Vector4 destination = default(Vector4); // Apply each matrix multiplier to the color components for each pixel. for (int fy = 0; fy < kernelHeight; fy++) { int fyr = fy - radiusY; int offsetY = y + fyr; offsetY = offsetY.Clamp(0, maxY); for (int fx = 0; fx < kernelWidth; fx++) { int fxr = fx - radiusX; int offsetX = x + fxr; offsetX = offsetX.Clamp(0, maxX); Vector4 currentColor = sourcePixels[offsetX, offsetY].ToVector4(); destination += kernel[fy, fx] * currentColor; } } TColor packed = default(TColor); packed.PackFromVector4(destination); targetPixels[x, y] = packed; } }); }
/// <summary> /// Initializes a new instance of the <see cref="PatternBrushApplicator" /> class. /// </summary> /// <param name="sourcePixels">The sourcePixels.</param> /// <param name="pattern">The pattern.</param> /// <param name="patternVector">The patternVector.</param> /// <param name="options">The options</param> public PatternBrushApplicator(PixelAccessor <TPixel> sourcePixels, Fast2DArray <TPixel> pattern, Fast2DArray <Vector4> patternVector, GraphicsOptions options) : base(sourcePixels, options) { this.pattern = pattern; this.patternVector = patternVector; }
/// <summary> /// Initializes a new instance of the <see cref="PatternBrushApplicator" /> class. /// </summary> /// <param name="sourcePixels">The sourcePixels.</param> /// <param name="pattern">The pattern.</param> /// <param name="patternVector">The patternVector.</param> public PatternBrushApplicator(PixelAccessor <TColor> sourcePixels, Fast2DArray <TColor> pattern, Fast2DArray <Vector4> patternVector) : base(sourcePixels) { this.pattern = pattern; this.patternVector = patternVector; }
/// <summary> /// Initializes a new instance of the <see cref="PatternBrush{TColor}"/> class. /// </summary> /// <param name="brush">The brush.</param> internal PatternBrush(PatternBrush <TColor> brush) { this.pattern = brush.pattern; this.patternVector = brush.patternVector; }
/// <summary> /// Initializes a new instance of the <see cref="Convolution2DProcessor{TPixel}"/> class. /// </summary> /// <param name="kernelX">The horizontal gradient operator.</param> /// <param name="kernelY">The vertical gradient operator.</param> public Convolution2DProcessor(Fast2DArray <float> kernelX, Fast2DArray <float> kernelY) { this.KernelX = kernelX; this.KernelY = kernelY; }
/// <summary> /// Creates a new room at the given position (bottom left corner) with the given layout. /// </summary> /// <param name="posX">The x-Position of the room.</param> /// <param name="posY">The y-Position of the room.</param> /// <param name="layout">The layout of the room.</param> public Room(int posX, int posY, Fast2DArray <TileType> layout, List <TiledImporter.PrefabLocations> gameObjects, RoomType roomType) { this.Position = new Vector2Int(posX, posY); this.Type = roomType; this.Layout = layout; this.GameObjects = gameObjects; this.ExitDirections = new Dictionary <Vector2Int, Direction>(); this.TileCount = 0; List <Vector2Int> checkedPositions = new List <Vector2Int>(); for (int x = 0; x < this.Layout.XSize; x++) { for (int y = 0; y < this.Layout.YSize; y++) { if (this.Layout[x, y] == TileType.Floor) { TileCount++; } if (this.Layout[x, y] == TileType.CorridorAccess && !checkedPositions.Contains(new Vector2Int(x, y))) { checkedPositions.Add(new Vector2Int(x, y)); if (this.Layout[x + 1, y] == TileType.CorridorAccess) { if (this.Layout[x, y + 1] == TileType.Floor) { ExitDirections.Add(new Vector2Int(x, y), Direction.Down); int delta = 1; while (this.Layout[x + delta, y] == TileType.CorridorAccess && this.Layout[x + delta + 1, y] == TileType.CorridorAccess) { checkedPositions.Add(new Vector2Int(x + delta, y)); ExitDirections.Add(new Vector2Int(x + delta, y), Direction.Down); delta++; } } else if (this.Layout[x, y - 1] == TileType.Floor) { ExitDirections.Add(new Vector2Int(x, y), Direction.Up); int delta = 1; while (this.Layout[x + delta, y] == TileType.CorridorAccess && this.Layout[x + delta + 1, y] == TileType.CorridorAccess) { checkedPositions.Add(new Vector2Int(x + delta, y)); ExitDirections.Add(new Vector2Int(x + delta, y), Direction.Up); delta++; } } } else if (this.Layout[x, y + 1] == TileType.CorridorAccess) { if (this.Layout[x + 1, y] == TileType.Floor) { ExitDirections.Add(new Vector2Int(x, y), Direction.Left); int delta = 1; while (this.Layout[x, y + delta] == TileType.CorridorAccess && this.Layout[x, y + delta + 1] == TileType.CorridorAccess && this.Layout[x, y + delta + 2] == TileType.CorridorAccess) { checkedPositions.Add(new Vector2Int(x, y + delta)); ExitDirections.Add(new Vector2Int(x, y + delta), Direction.Left); delta++; } checkedPositions.Add(new Vector2Int(x, y + delta)); } else if (this.Layout[x - 1, y] == TileType.Floor) { ExitDirections.Add(new Vector2Int(x, y), Direction.Right); int delta = 1; while (this.Layout[x, y + delta] == TileType.CorridorAccess && this.Layout[x, y + delta + 1] == TileType.CorridorAccess && this.Layout[x, y + delta + 2] == TileType.CorridorAccess) { checkedPositions.Add(new Vector2Int(x, y + delta)); ExitDirections.Add(new Vector2Int(x, y + delta), Direction.Right); delta++; } checkedPositions.Add(new Vector2Int(x, y + delta)); } } } } } }
/// <summary> /// Applies the process to the specified portion of the specified <see cref="ImageBase{TPixel}"/> at the specified location /// and with the specified size. /// </summary> /// <param name="targetPixels">The target pixels to apply the process to.</param> /// <param name="sourcePixels">The source pixels. Cannot be null.</param> /// <param name="sourceRectangle"> /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to draw. /// </param> /// <param name="kernel">The kernel operator.</param> private void ApplyConvolution(PixelAccessor <TPixel> targetPixels, PixelAccessor <TPixel> sourcePixels, Rectangle sourceRectangle, Fast2DArray <float> kernel) { int kernelHeight = kernel.Height; int kernelWidth = kernel.Width; int radiusY = kernelHeight >> 1; int radiusX = kernelWidth >> 1; int startY = sourceRectangle.Y; int endY = sourceRectangle.Bottom; int startX = sourceRectangle.X; int endX = sourceRectangle.Right; int maxY = endY - 1; int maxX = endX - 1; Parallel.For( startY, endY, this.ParallelOptions, y => { Span <TPixel> targetRow = targetPixels.GetRowSpan(y); for (int x = startX; x < endX; x++) { var destination = default(Vector4); // Apply each matrix multiplier to the color components for each pixel. for (int fy = 0; fy < kernelHeight; fy++) { int fyr = fy - radiusY; int offsetY = y + fyr; offsetY = offsetY.Clamp(0, maxY); Span <TPixel> row = sourcePixels.GetRowSpan(offsetY); for (int fx = 0; fx < kernelWidth; fx++) { int fxr = fx - radiusX; int offsetX = x + fxr; offsetX = offsetX.Clamp(0, maxX); var currentColor = row[offsetX].ToVector4(); destination += kernel[fy, fx] * currentColor; } } ref TPixel pixel = ref targetRow[x]; pixel.PackFromVector4(destination); } }); }
/// <summary> /// Initializes a new instance of the <see cref="EdgeDetectorProcessor{TPixel}"/> class. /// </summary> /// <param name="kernelXY">The 2d gradient operator.</param> protected EdgeDetectorProcessor(Fast2DArray <float> kernelXY) { this.KernelXY = kernelXY; }
/// <summary> /// Generates the water planes on top of every waterSpot. /// </summary> private List <Transform> GenerateWaterPlanes(List <List <Vector2Int> > waterSpots, Fast2DArray <Vector3> verts) { Transform waterParent = new GameObject("Water Planes").transform; waterParent.parent = map.transform; List <Transform> waterPlanes = new List <Transform>(); List <Vector3> waterVerts = new List <Vector3> { verts.Get(0, 0), verts.Get(verts.XSize - 1, 0), verts.Get(0, verts.YSize - 1), verts.Get(verts.XSize - 1, verts.YSize - 1) }; // change y for (int i = 0; i < waterVerts.Count; i++) { Vector3 temp = waterVerts[i]; temp.y = maxWaterLevel * amplitude; waterVerts[i] = temp; } List <int> tris = new List <int> { 0, 2, 1, 2, 3, 1 }; GameObject plane = new GameObject("Water Plane"); plane.transform.parent = waterParent; Mesh mesh = GenerateMesh(plane, waterVerts, tris, waterMaterial); plane.AddComponent <MeshCollider>().sharedMesh = mesh; waterPlanes.Add(plane.transform); /* * foreach (List<Vector2Int> waterSpot in waterSpots) * { * int minX = int.MaxValue; * int minY = int.MaxValue; * int maxX = int.MinValue; * int maxY = int.MinValue; * * foreach (Vector2Int point in waterSpot) * { * if (point.x < minX) * minX = point.x; * if (point.x > maxX) * maxX = point.x; * if (point.y < minY) * minY = point.y; * if (point.y > maxY) * maxY = point.y; * } * * // Set all y values to the water level and add/ subtract one stepsize from their position * float newY = maxWaterLevel * amplitude; * float stepSize = this.stepSize * 2; * * Vector3 zero = verts.Get(minX, minY); * zero.Set(zero.x - stepSize, newY, zero.z - stepSize); * * Vector3 one = verts.Get(minX, maxY); * one.Set(one.x - stepSize, newY, one.z + stepSize); * * Vector3 two = verts.Get(maxX, maxY); * two.Set(two.x + stepSize, newY, two.z + stepSize); * * Vector3 three = verts.Get(maxX, minY); * three.Set(three.x + stepSize, newY, three.z - stepSize); * * List<Vector3> waterVerts = new List<Vector3>(4) * { * zero, one, two, three * }; * * List<int> tris = new List<int>(6) * { * 0,1,3, * 1,2,3 * }; * * GameObject plane = new GameObject("Water Plane"); * plane.transform.parent = waterParent; * GenerateMesh(plane, waterVerts, tris, waterMaterial); * plane.AddComponent<BoxCollider>(); * waterPlanes.Add(plane.transform); * } */ return(waterPlanes); }
/// <summary> /// Initializes a new instance of the <see cref="PatternBrushApplicator" /> class. /// </summary> /// <param name="source">The source image.</param> /// <param name="pattern">The pattern.</param> /// <param name="patternVector">The patternVector.</param> /// <param name="options">The options</param> public PatternBrushApplicator(ImageFrame <TPixel> source, Fast2DArray <TPixel> pattern, Fast2DArray <Vector4> patternVector, GraphicsOptions options) : base(source, options) { this.pattern = pattern; this.patternVector = patternVector; }
/// <summary> /// Creates a List of all neighbours for a given point based on a min and max float value. /// </summary> /// <param name="noiseArray">Array containing all points of the generated noise</param> /// <param name="startingPoint">The starting vert</param> /// <param name="min">The lowest the noise can be</param> /// <param name="max">The highest the noise can be</param> /// <param name="alreadyChecked">A 2D array which marks which positions have already been checked for</param> /// <returns>A list of all verts of all neighbours</returns> private List <Vector2Int> AllNeighbours(Fast2DArray <float> noiseArray, Vector2Int startingPoint, float min, float max, Fast2DArray <bool> alreadyChecked = null) { List <Vector2Int> neighbours = new List <Vector2Int>(); Queue <Vector2Int> toConsider = new Queue <Vector2Int>(); if (alreadyChecked == null) { alreadyChecked = new Fast2DArray <bool>(noiseArray.XSize, noiseArray.YSize); } toConsider.Enqueue(startingPoint); alreadyChecked.Set(true, startingPoint.x, startingPoint.y); while (toConsider.Count > 0) { Vector2Int toInspect = toConsider.Dequeue(); float noiseVal = noiseArray.Get(toInspect.x, toInspect.y); // If the noise value is inside the range that we are trying to find if (MathUtil.InRangeInclusive(min, max, noiseVal) == false) { continue; } neighbours.Add(toInspect); for (int x = -1; x < 2; x++) { for (int y = -1; y < 2; y++) { if (x != 0 || y != 0) { Vector2Int newValue = new Vector2Int(toInspect.x + x, toInspect.y + y); // is the value inside the array bounds and has not been already checked // then add it to the toConsider Queue if (noiseArray.InBounds(newValue.x, newValue.y) && alreadyChecked.Get(newValue.x, newValue.y) == false) { // Set the current tile to already checked alreadyChecked.Set(true, newValue.x, newValue.y); toConsider.Enqueue(newValue); } } } } } // end while return(neighbours); }
internal void WriteMatrix2D_Fast2DArray(byte[] expected, int xCount, int yCount, bool isSingle, Fast2DArray <float> data) { IccDataWriter writer = CreateWriter(); writer.WriteMatrix(data, isSingle); byte[] output = writer.GetData(); Assert.Equal(expected, output); }
public void Generate() { int seed = useSeed ? this.seed : Random.Range(int.MinValue, int.MaxValue); Random.InitState(seed); scaleVector = new Vector3(scaleOfObjects, scaleOfObjects, scaleOfObjects); MapValuesDict mapValuesDict = MapValuesDict.Instance; mapValuesDict.ObjectScaleVector = scaleVector; mapValuesDict.WorldMapSize = WorldMapSize; // is there already a world? if (map != null || (map = GameObject.Find("World")) != null) { Destroy(map); } map = new GameObject("World") { layer = 8 }; MapValuesDict.Instance.Map = map; objects = new GameObject("Objects").transform; objects.parent = map.transform; // First we generate the base noise Array. // This is done by using simplex noise Fast2DArray <float> noiseArray = GenerateBaseNoise(out float minNoiseValue, out float maxNoiseValue); // We then go through the noise Array and look for every y value which is lower then the maxWaterLevel. // Each of these points are then combined to form a lake. This method gets us the waterSpots and also // which verts we already used for these water spots. GenerateWaterSpots(out List <List <Vector2Int> > waterSpots, out Fast2DArray <bool> alreadyPlacedSomething, noiseArray, minNoiseValue); // Generate the base verticies for the map. This is based on the noiseArray. To make it look // low poly, we also move the verticies slightly arround. Fast2DArray <Vector3> verticies = GenerateBaseVerts(noiseArray, waterSpots, out float minHeight, out float maxHeight); // Generate the planes for the water spots. This is a simply a plane with the waterMaterial attached to it List <Transform> waterPlanes = GenerateWaterPlanes(waterSpots, verticies); // Generate the baseMesh based on the verticies and the min and max height and attach a collider onto it GenerateBaseMesh(verticies, minHeight, maxHeight); map.AddComponent <MeshCollider>(); // Generate the Starting Toori for the player town in the middle of the map PlacePlayerStartingToori(verticies, alreadyPlacedSomething, minHeight, maxHeight); // Generate some objects and resources on top of the map GenerateWaterDecor(verticies, waterSpots, waterPlanes, minHeight, maxHeight); GenerateRessourceFields(verticies, alreadyPlacedSomething, minHeight, maxHeight); GenerateLandDecor(verticies, alreadyPlacedSomething, minHeight, maxHeight); // Generate the nav mesh GenerateNavMesh(waterPlanes); // move the map to the offset position map.transform.position = transform.position + mapOffset; }
private void PlacePlayerStartingToori(Fast2DArray <Vector3> verticies, Fast2DArray <bool> alreadyPlacedSomething, float minHeight, float maxHeight) { Town playerTown = TownDict.Instance.Towns[0]; // Might need to rethink this if there are multiple towns spawning Vector2Int startingPos = new Vector2Int(alreadyPlacedSomething.XSize / 2, alreadyPlacedSomething.YSize / 2); int incrementer = -1; while (true) { incrementer++; if (incrementer > alreadyPlacedSomething.XSize / 2 && incrementer > alreadyPlacedSomething.YSize / 2) { break; } for (int x = -incrementer; x < incrementer + 1; x++) { for (int y = -incrementer; y < incrementer + 1; y++) { // if it is not the most outer values continue if (x != -incrementer && x != incrementer && y != -incrementer && y != incrementer) { continue; } Vector2Int newPos = startingPos + new Vector2Int(x, y); // If there is already something placed or it is out of bounds continue if (!alreadyPlacedSomething.InBounds(newPos) || alreadyPlacedSomething.Get(newPos) != false) { continue; } RaycastHit[] hits = GetHitsFromPoint(verticies.Get(newPos), minHeight, maxHeight); for (int i = 0; i < hits.Length; i++) { // Collider is on the map, so we can place the toori there if (hits[i].collider.gameObject == map) { // Set the vicinity to already placed something for (int x2 = newPos.x - 1; x2 < newPos.x + 2; x2++) { for (int y2 = newPos.y - 1; y2 < newPos.y + 2; y2++) { alreadyPlacedSomething.Set(true, x2, y2); } } playerTown.PlaceToori(hits[i].point); return; } } // Could not find the map Debug.LogError("Tried to place Toori on the map but the rayscast could not hit the map."); return; } // end iteration over map y } // end iteration over map x } // end while(true) // Somehow iterated over the entire map and no suitable place was found. Debug.LogError("Could not place Toori. Could not find a place to put it to."); }
/// <summary> /// Initializes a new instance of the <see cref="EdgeDetector2DProcessor{TPixel}"/> class. /// </summary> /// <param name="kernelX">The horizontal gradient operator.</param> /// <param name="kernelY">The vertical gradient operator.</param> protected EdgeDetector2DProcessor(Fast2DArray <float> kernelX, Fast2DArray <float> kernelY) { this.KernelX = kernelX; this.KernelY = kernelY; }
/// <summary> /// Initializes a new instance of the <see cref="OrderedDitherBase"/> class. /// </summary> /// <param name="matrix">The thresholding matrix. </param> internal OrderedDitherBase(Fast2DArray <byte> matrix) { this.matrix = matrix; }
/// <summary> /// Create a 1 dimensional Gaussian kernel using the Gaussian G(x) function /// </summary> /// <param name="horizontal">Whether to calculate a horizontal kernel.</param> /// <returns>The <see cref="Fast2DArray{T}"/></returns> private Fast2DArray <float> CreateGaussianKernel(bool horizontal) { int size = this.kernelSize; float weight = this.sigma; Fast2DArray <float> kernel = horizontal ? new Fast2DArray <float>(size, 1) : new Fast2DArray <float>(1, size); float sum = 0; float midpoint = (size - 1) / 2f; for (int i = 0; i < size; i++) { float x = i - midpoint; float gx = ImageMaths.Gaussian(x, weight); sum += gx; if (horizontal) { kernel[0, i] = gx; } else { kernel[i, 0] = gx; } } // Invert the kernel for sharpening. int midpointRounded = (int)midpoint; if (horizontal) { for (int i = 0; i < size; i++) { if (i == midpointRounded) { // Calculate central value kernel[0, i] = (2F * sum) - kernel[0, i]; } else { // invert value kernel[0, i] = -kernel[0, i]; } } } else { for (int i = 0; i < size; i++) { if (i == midpointRounded) { // Calculate central value kernel[i, 0] = (2 * sum) - kernel[i, 0]; } else { // invert value kernel[i, 0] = -kernel[i, 0]; } } } // Normalise kernel so that the sum of all weights equals 1 if (horizontal) { for (int i = 0; i < size; i++) { kernel[0, i] = kernel[0, i] / sum; } } else { for (int i = 0; i < size; i++) { kernel[i, 0] = kernel[i, 0] / sum; } } return(kernel); }
/// <summary> /// Initializes a new instance of the <see cref="ConvolutionProcessor{TColor}"/> class. /// </summary> /// <param name="kernelXY">The 2d gradient operator.</param> public ConvolutionProcessor(Fast2DArray <float> kernelXY) { this.KernelXY = kernelXY; }
private IEnumerator Start() { yield return(new WaitForSeconds(0.1f)); UIManager.Instance.ShowLevelLoadScreen(); DungeonDict.Instance.ClearRooms(); RegionSceneLoader loader = RegionSceneLoader.Instance; yield return(loader.LoadScene(Region.EnemyTestRoom)); Vector2Int weaponSize = new Vector2Int(30, 30); Vector2Int corridorSize = new Vector2Int(10, 2); Vector2Int enemySize = new Vector2Int(20, 20); Vector2Int startSize = new Vector2Int(10, 10); Vector2Int weaponPos = new Vector2Int(1, 3); Vector2Int startPos = new Vector2Int(weaponPos.x + weaponSize.x + corridorSize.x - 2, 3); Vector2Int corridor1Pos = startPos + new Vector2Int(0, 2);// - new Vector2Int(corridorSize.x, -2); Vector2Int corridor2Pos = startPos + new Vector2Int(startSize.x - 1, 2); Vector2Int enemyPos = startPos + new Vector2Int(startSize.x - 1, 0) + new Vector2Int(corridorSize.x - 1, 0); Fast2DArray <TileType> layout = new Fast2DArray <TileType>(startSize.x, startSize.y); FillRoomWithBounds(layout); layout.Set(TileType.CorridorAccess, layout.XSize - 1, 2); layout.Set(TileType.CorridorAccess, layout.XSize - 1, 3); List <TiledImporter.PrefabLocations> gameObjects = new List <TiledImporter.PrefabLocations>(); Room startRoom = new Room(startPos.x, startPos.y, layout, gameObjects, RoomType.Start); layout = new Fast2DArray <TileType>(weaponSize.x, weaponSize.y); FillRoomWithBounds(layout); layout.Set(TileType.CorridorAccess, layout.XSize - 1, 2); layout.Set(TileType.CorridorAccess, layout.XSize - 1, 3); Room weaponRoom = new Room(weaponPos.x, weaponPos.y, layout, gameObjects, RoomType.Empty); Corridor corridor1 = new Corridor(corridor1Pos.x, corridor1Pos.y, corridorSize.x, Direction.Left); Corridor corridor2 = new Corridor(corridor2Pos.x, corridor2Pos.y, corridorSize.x, Direction.Right); layout = new Fast2DArray <TileType>(enemySize.x, enemySize.y); FillRoomWithBounds(layout); for (int x = 3; x < enemySize.x - 2; x++) { for (int y = 5; y < enemySize.y - 2; y += 5) { layout.Set(TileType.Wall, x, y); } } layout.Set(TileType.CorridorAccess, 0, 2); layout.Set(TileType.CorridorAccess, 0, 3); Room enemyRoom = new Room(enemyPos.x, enemyPos.y, layout, gameObjects, RoomType.Combat); Room[] rooms = { startRoom, enemyRoom, weaponRoom }; Corridor[] corridors = { corridor1, corridor2 }; if (Player.LocalPlayer.isServer) { GlobalsDict.Instance.GameStateManagerObject.AddComponent <GameManager>(); } Dungeon dungeon = new Dungeon(rooms, corridors, enemyPos + new Vector2Int(layout.XSize, layout.YSize)); DungeonConfig config = DungeonConfig.StandardConfig; yield return(DungeonCreator.Instance.CreateDungeon(-1, 1, config, RegionDict.Instance.Tileset, dungeon)); CombatRoom combatRoom = DungeonDict.Instance.Rooms.First(x => x.RoomType == RoomType.Combat) as CombatRoom; combatRoom.enemiesToSpawn = enemiesToSpawn; Destroy(gameObject); }