protected static void RenderEntityDetails(int x, int y, ShopItemControl display, IEntity shopItem, ISystemContainer systemContainer, ISpriteManager spriteManager) { BLT.Font(""); SpriteAppearance appearance = shopItem.Has <SpriteAppearance>() ? shopItem.Get <SpriteAppearance>() : new SpriteAppearance { Bottom = "unknown" }; AnimationFrame frame = shopItem.Has <Animated>() ? systemContainer.AnimationSystem.GetFrame(shopItem) : AnimationFrame.Idle0; Price price = shopItem.Get <Price>(); var playerWealth = systemContainer.ItemSystem.CheckWealth(systemContainer.PlayerSystem.Player, price.Currency); var canAfford = playerWealth >= price.Amount; BLTLayers.Set(BLTLayers.UIElementPieces, display.ActivityIndex); string appearanceBottom = appearance.Bottom; RenderSpriteIfSpecified(x + 4 + BLTTilesIOSystem.TILE_SPACING * 2, y + 4, spriteManager, appearanceBottom, frame); BLTLayers.Set(BLTLayers.UIElementPieces + 1, display.ActivityIndex); string appearanceTop = appearance.Top; RenderSpriteIfSpecified(x + 4 + BLTTilesIOSystem.TILE_SPACING * 2, y + 4, spriteManager, appearanceTop, frame); BLTLayers.Set(BLTLayers.Text, display.ActivityIndex); BLT.Font("text"); BLT.Print(new Rectangle(x + 2, y + BLTTilesIOSystem.TILE_SPACING * 2 + 2, 6 * BLTTilesIOSystem.TILE_SPACING, 10), ContentAlignment.TopCenter, shopItem.GetBLTName()); BLT.Color(canAfford ? Color.Gold : Color.Gray); BLT.Print(new Rectangle(x + 2, y + BLTTilesIOSystem.TILE_SPACING * 2 + 12, 6 * BLTTilesIOSystem.TILE_SPACING, 10), ContentAlignment.TopCenter, $"{price.Amount} {price.Currency}"); BLT.Color(Color.White); }
protected override void DisplayInternal(ISpriteManager spriteManager, IDataRogueControl control, ISystemContainer systemContainer, List <MapCoordinate> playerFov) { var messageLog = control as MessageLogControl; var numberOfMessages = messageLog.NumberOfMessages; BLTLayers.Set(BLTLayers.Text, control.ActivityIndex); BLT.Font("text"); var messagesToRender = systemContainer.MessageSystem.RecentMessages(numberOfMessages); messagesToRender.Reverse(); var x = control.Position.Left; var y = control.Position.Bottom; foreach (var message in messagesToRender) { var size = BLT.Measure(message.Text); y -= size.Height + 1; BLT.Color(message.Color); BLT.Print(x, y, message.Text); } BLT.Color(""); BLT.Font(""); }
protected override void DisplayInternal(ISpriteManager spriteManager, IDataRogueControl control, ISystemContainer systemContainer, List <MapCoordinate> playerFov) { var display = control as MenuActionsControl; if (display.AvailableActions.Count > 1) { BLT.Font("text"); BLTLayers.Set(BLTLayers.Text, display.ActivityIndex); BLT.Color(display.Color); var x = control.Position.X; var y = control.Position.Y; BLT.Print(x, y, "[["); x += BLT.Measure("[[").Width; foreach (var action in display.AvailableActions) { if (action == display.SelectedAction) { BLT.Color(display.SelectedColor); } BLT.Print(x, y, action.ToString()); BLT.Color(""); x += BLT.Measure(action.ToString()).Width; BLT.Print(x, y, "|"); x += BLT.Measure("|").Width; } x -= BLT.Measure("|").Width; BLT.Print(x, y, "]]"); } }
private static void RenderHighlightedCells(IDataRogueControl control, ISpriteSheet topSprite, ISpriteSheet bottomSprite, IMap currentMap, int cameraX, int cameraY, int renderWidth, int renderHeight, int offsetX, int offsetY, List <MapCoordinate> highlightedCells) { var checks = new bool[renderWidth + 2, renderHeight + 2]; for (int y = 0; y < renderHeight; y++) { for (int x = 0; x < renderWidth; x++) { var lookupX = cameraX - offsetX + x; var lookupY = cameraY - offsetY + y; var currentCell = new MapCoordinate(currentMap.MapKey, lookupX, lookupY); checks[x + 1, y + 1] = highlightedCells.Contains(currentCell); } } BLT.Color(Color.FromArgb(128, 255, 255, 255)); if (bottomSprite != null) { RenderLayer(BLTLayers.MapShade, control, bottomSprite, renderWidth, renderHeight, checks); } if (topSprite != null) { RenderLayer(BLTLayers.MapShade + 1, control, topSprite, renderWidth, renderHeight, checks); } }
private void RenderMapShade(ISpriteManager spriteManager, bool[,] renderTracker, bool[,] fovTracker, int renderWidth, int renderHeight, BLTMapRendererOffset[,,] offsetTracker, IDataRogueControl mapConfiguration) { var shadeSprite = spriteManager.Get("shade"); BLTLayers.Set(BLTLayers.MapShade, mapConfiguration.ActivityIndex); BLT.Font(""); BLT.Color(Color.White); for (int x = 0; x < renderWidth; x++) { for (int y = 0; y < renderHeight; y++) { if (renderTracker[x + 1, y + 1]) { var offsetX = (int)Math.Floor(offsetTracker[x + 1, y + 1, 0].OffsetX * BLTTilesIOSystem.TILE_SPACING); var offsetY = (int)Math.Floor(offsetTracker[x + 1, y + 1, 0].OffsetY * BLTTilesIOSystem.TILE_SPACING); if (!fovTracker[x + 1, y + 1]) { var sprite = shadeSprite.Tile(TileDirections.None); BLT.Put(mapConfiguration.Position.Left + x * BLTTilesIOSystem.TILE_SPACING + offsetX, mapConfiguration.Position.Top + y * BLTTilesIOSystem.TILE_SPACING + offsetY, sprite); } else { var aboveConnect = (fovTracker[x + 1, y]); var belowConnect = (fovTracker[x + 1, y + 2]); var leftConnect = (fovTracker[x, y + 1]); var rightConnect = (fovTracker[x + 2, y + 1]); var directions = TileDirections.None; if (aboveConnect) { directions |= TileDirections.Up; } if (belowConnect) { directions |= TileDirections.Down; } if (leftConnect) { directions |= TileDirections.Left; } if (rightConnect) { directions |= TileDirections.Right; } var sprite = shadeSprite.Tile(directions); BLT.Put( mapConfiguration.Position.Left + x * BLTTilesIOSystem.TILE_SPACING + offsetX, mapConfiguration.Position.Top + y * BLTTilesIOSystem.TILE_SPACING + offsetY, sprite); } } } } }
private void RenderMapParticles(ISystemContainer systemContainer, bool[,] renderTracker, bool[,] fovTracker, List <IEntity>[,] particlesTracker, int renderWidth, int renderHeight, IDataRogueControl mapConfiguration) { BLTLayers.Set(BLTLayers.MapParticles, mapConfiguration.ActivityIndex); BLT.Font("text"); for (int x = 0; x < renderWidth; x++) { for (int y = 0; y < renderHeight; y++) { if (renderTracker[x + 1, y + 1] && fovTracker[x + 1, y + 1] && particlesTracker[x + 1, y + 1].Any()) { foreach (var particle in particlesTracker[x + 1, y + 1]) { var textParticle = particle.Get <TextParticle>(); BLT.Color(textParticle.Color); var moving = particle.TryGet <Moving>(); var offsetX = (int)Math.Floor((moving?.OffsetX ?? 0) * BLTTilesIOSystem.TILE_SPACING); var offsetY = (int)Math.Floor((moving?.OffsetY ?? 0) * BLTTilesIOSystem.TILE_SPACING); BLT.Print( (int)(mapConfiguration.Position.Left + x * BLTTilesIOSystem.TILE_SPACING + offsetX), (int)(mapConfiguration.Position.Top + y * BLTTilesIOSystem.TILE_SPACING + offsetY), textParticle.Text); } } } } }
private static void RenderBarFillMask(int x, int y, ISpriteManager spriteManager, int totalLength, decimal percentage, Color color, IDataRogueControl display) { BLTLayers.Set(BLTLayers.UIMasks, display.ActivityIndex); BLT.Color(color); var mask_main = spriteManager.Tile("bar_fill_mask"); RenderBarContent(x, y, totalLength, percentage, mask_main, mask_main, mask_main, mask_main); BLT.Color(""); }
protected static void RenderText(int x, int y, int activityIndex, out Size textSize, string text, Color color, bool updateY = true, string font = "text") { BLTLayers.Set(BLTLayers.Text, activityIndex); BLT.Font(font); BLT.Color(color); BLT.Print(x, y, text); textSize = BLT.Measure(text); textSize.Height += 1; BLT.Color(""); }
protected override void DisplayInternal(ISpriteManager spriteManager, IDataRogueControl control, ISystemContainer systemContainer, List <MapCoordinate> playerFov) { var display = control as IDataRogueInfoControl; var text = display.Parameters; BLT.Font("textLarge"); BLTLayers.Set(BLTLayers.Text, display.ActivityIndex); BLT.Color(display.Color); BLT.Print(display.Position.X, display.Position.Y, text); BLT.Color(""); }
private void RenderMapSprites( ISpriteManager spriteManager, IDataRogueControl mapConfiguration, bool[,] renderTracker, int renderWidth, int renderHeight, SpriteAppearance[,,] tilesTracker, AnimationFrame[,,] frameTracker, BLTMapRendererOffset[,,] offsetTracker, int z, bool top) { if (z == 0) { BLTLayers.Set(top ? BLTLayers.MapTileTop : BLTLayers.MapTileBottom, mapConfiguration.ActivityIndex); } else { BLTLayers.Set(top ? BLTLayers.MapEntityTop : BLTLayers.MapEntityBottom, mapConfiguration.ActivityIndex); } BLT.Font(""); BLT.Color(Color.White); for (int x = 0; x < renderWidth; x++) { for (int y = 0; y < renderHeight; y++) { if (renderTracker[x + 1, y + 1]) { var appearance = tilesTracker[x + 1, y + 1, z]; var frame = frameTracker[x + 1, y + 1, z]; if (appearance != null) { var spriteName = top ? appearance.Top : appearance.Bottom; if (spriteName != null) { TileDirections directions = BLTTileDirectionHelper.GetDirections(tilesTracker, x + 1, y + 1, z, top); var sprite = spriteManager.Tile(spriteName, directions, frame); var offsetX = (int)Math.Floor(offsetTracker[x + 1, y + 1, z].OffsetX * BLTTilesIOSystem.TILE_SPACING); var offsetY = (int)Math.Floor(offsetTracker[x + 1, y + 1, z].OffsetY * BLTTilesIOSystem.TILE_SPACING); BLT.Put( mapConfiguration.Position.Left + x * BLTTilesIOSystem.TILE_SPACING + offsetX, mapConfiguration.Position.Top + y * BLTTilesIOSystem.TILE_SPACING + offsetY, sprite); } } } } } }
protected override void DisplayInternal(ISpriteManager spriteManager, IDataRogueControl control, ISystemContainer systemContainer, List <MapCoordinate> playerFov) { BLTLayers.Set(BLTLayers.UIElements, control.ActivityIndex); BLT.Font(""); var sprite = spriteManager.Tile("minimap_tile"); var cameraPosition = systemContainer.RendererSystem.CameraPosition; var currentMap = systemContainer.MapSystem.MapCollection[cameraPosition.Key]; var cameraX = cameraPosition.X; var cameraY = cameraPosition.Y; var maxX = control.Position.Width; var maxY = control.Position.Height; int offsetX = maxX / 2; int offsetY = maxY / 2; for (int x = 0; x < maxX; x++) { for (int y = 0; y < maxY; y++) { var lookupX = cameraX - offsetX + x; var lookupY = cameraY - offsetY + y; Color color; if (x == 0 || y == 0 || x == maxX - 1 || y == maxY - 1) { color = Color.SaddleBrown; } else { MapCoordinate coordinate = new MapCoordinate(currentMap.MapKey, lookupX, lookupY); var isInFov = playerFov.Contains(coordinate); color = DetermineMapColor(systemContainer, coordinate, currentMap, isInFov); } if (color != Color.Transparent) { BLT.Color(color); BLT.Put(control.Position.Left + x * BLTTilesIOSystem.TILE_SPACING / 8, control.Position.Top + y * BLTTilesIOSystem.TILE_SPACING / 8, sprite); } } } }
protected override void DisplayInternal(ISpriteManager spriteManager, IDataRogueControl control, ISystemContainer systemContainer, List <MapCoordinate> playerFov) { var x = control.Position.X; var y = control.Position.Y; var display = control as IDataRogueInfoControl; List <IEntity> interactables = systemContainer.InteractableSystem.GetInteractablesNear(systemContainer.PlayerSystem.Player); if (interactables.Any()) { var possibleInteractions = interactables .SelectMany(e => e.Components.OfType <Interaction>() .Select(i => new { Entity = e, Interactable = i })); (IEntity, Interaction)currentInteraction = systemContainer.InteractableSystem.GetCurrentInteractionFor(systemContainer.PlayerSystem.Player); var interactEntity = currentInteraction.Item1; var interactable = currentInteraction.Item2; BLT.Font(""); SpriteAppearance appearance = interactEntity.Has <SpriteAppearance>() ? interactEntity.Get <SpriteAppearance>() : new SpriteAppearance { Bottom = "unknown" }; AnimationFrame frame = interactEntity.Has <Animated>() ? systemContainer.AnimationSystem.GetFrame(interactEntity) : AnimationFrame.Idle0; BLTLayers.Set(BLTLayers.UIElementPieces, display.ActivityIndex); string appearanceBottom = appearance.Bottom; RenderSpriteIfSpecified(x + 4, y + 4, spriteManager, appearanceBottom, frame); BLTLayers.Set(BLTLayers.UIElementPieces + 1, display.ActivityIndex); string appearanceTop = appearance.Top; RenderSpriteIfSpecified(x + 4, y + 4, spriteManager, appearanceTop, frame); BLTLayers.Set(BLTLayers.Text, display.ActivityIndex); BLT.Font("text"); BLT.Color(Color.LightBlue); BLT.Print(x + BLTTilesIOSystem.TILE_SPACING + 6, y + BLTTilesIOSystem.TILE_SPACING / 2, interactable.Verb); BLT.Color(Color.White); BLT.Print(x + BLTTilesIOSystem.TILE_SPACING + 6, y + 4 + BLTTilesIOSystem.TILE_SPACING / 2, interactEntity.DescriptionName); RenderBackgroundBox(x, y, display.ActivityIndex, control.Position.Size, spriteManager); } }
protected override void DisplayInternal(ISpriteManager spriteManager, IDataRogueControl control, ISystemContainer systemContainer, List <MapCoordinate> playerFov) { var display = control as MapEditorHighlightControl; var mapEditor = systemContainer.ActivitySystem.MapEditorActivity; var primary = mapEditor.PrimaryCell.Get <SpriteAppearance>(); var primaryTop = primary.Top != null?spriteManager.Get(primary.Top) : null; var primaryBottom = primary.Bottom != null?spriteManager.Get(primary.Bottom) : null; var secondary = mapEditor.SecondaryCell.Get <SpriteAppearance>(); var secondaryTop = secondary.Top != null?spriteManager.Get(secondary.Top) : null; var secondaryBottom = secondary.Bottom != null?spriteManager.Get(secondary.Bottom) : null; BLT.Font(""); var cameraPosition = systemContainer.RendererSystem.CameraPosition; var currentMap = systemContainer.MapSystem.MapCollection[cameraPosition.Key]; var cameraX = cameraPosition.X; var cameraY = cameraPosition.Y; var renderWidth = control.Position.Width / BLTTilesIOSystem.TILE_SPACING; var renderHeight = control.Position.Height / BLTTilesIOSystem.TILE_SPACING; int offsetX = renderWidth / 2; int offsetY = renderHeight / 2; var highlightedCells = mapEditor.GetHighlightedCells(); RenderHighlightedCells(control, primaryTop, primaryBottom, currentMap, cameraX, cameraY, renderWidth, renderHeight, offsetX, offsetY, highlightedCells); var secondaryCells = mapEditor.GetSecondaryCells(); RenderHighlightedCells(control, secondaryTop, secondaryBottom, currentMap, cameraX, cameraY, renderWidth, renderHeight, offsetX, offsetY, secondaryCells); BLT.Color(Color.White); }