/// <summary> /// Generate background above our walkable layer and add them to our LevelScreen /// </summary> private void GenerateBackgroundAboveWalkableLayer() { int backgroundHeight = 4; int minY = walkingLayerPoints[0].Key.Y; string background = "Level\\Tiles\\BGTile (3)"; while (walkingLayerPoints.Exists(x => x.Key.Y < minY)) { minY = walkingLayerPoints.Find(x => x.Key.Y < minY).Key.Y; } for (int index = 0; index < walkingLayerPoints.Count; index++) { KeyValuePair <Point, Type> info = walkingLayerPoints[index]; // Want to create a background image behind our hazard so need to increment the currentPoint y by 1 so we start underneath our hazard Point currentPoint = info.Key; if (info.Value == Type.kHazard) { currentPoint.Y++; } for (int y = currentPoint.Y - 1; y > minY - 1 - backgroundHeight; y--) { Image addedObject = LevelScreen.AddEnvironmentObject(new Image(new Vector2(currentPoint.X, y) * TileDimensions, background)); addedObject.UsesCollider = false; } if (index % 3 == 0) { LevelScreen.AddLight(new PointLight(new Vector2(750, 750), new Vector2(currentPoint.X * TileDimensions.X, (minY - 1) * TileDimensions.Y), Color.White)); } } }
/// <summary> /// Adds the hazards and walkable layers to our LevelScreen Environment manager - this should happen after we add our background objects so the draw order is correct /// </summary> private void AddObjectsInFrontOfBackground() { for (int y = 0; y < GenerationData.Height; y++) { for (int x = 0; x < GenerationData.Width; x++) { if (LevelObjects[y, x] != null) { // Do we want to add environment objects for these guys? // Or should it be game objects? LevelScreen.AddEnvironmentObject(LevelObjects[y, x]); } } } }
/// <summary> /// Generate background below our walkable layer and add them to our LevelScreen /// </summary> private void GenerateBackgroundBelowWalkableLayer() { Dictionary <Position, string> belowWalkableLayer = new Dictionary <Position, string>() { //{ Position.kLeft, "Level\\Tiles\\Tile (4)" }, { Position.kLeft, GenerationData.AboveWalkableLayerTextureAsset }, { Position.kMiddle, GenerationData.AboveWalkableLayerTextureAsset }, { Position.kRight, GenerationData.AboveWalkableLayerTextureAsset }, //{ Position.kRight, "Level\\Tiles\\Tile (6)" }, }; for (int index = 0; index < walkingLayerPoints.Count; index++) { Point point = walkingLayerPoints[index].Key; Position positionType = (Position)LevelObjects[point.Y, point.X].StoredObject; for (int y = point.Y + 1; y < GenerationData.Height; y++) { Image addedObject = LevelScreen.AddEnvironmentObject(new Image(new Vector2(point.X * TileDimensions.X, y * TileDimensions.Y), belowWalkableLayer[positionType])); addedObject.UsesCollider = false; } } }