private static void RenderBarContent(int x, int y, int totalLength, decimal percentage, int bar_left, int bar_fill, int bar_full_right, int bar_right)
        {
            if (percentage > 0)
            {
                var lengthToCover = percentage * totalLength - 6;

                if (lengthToCover - 1 < 0)
                {
                    BLT.Put(x + 1, y + 2, bar_right);
                }
                else
                {
                    BLT.Put(x + 1, y + 2, bar_left);


                    for (int i = 3; i < lengthToCover - 1; i += 2)
                    {
                        BLT.Put(x + i, y + 2, bar_fill);
                    }

                    if (percentage == 1)
                    {
                        BLT.Put(x + totalLength - 7, y + 2, bar_full_right);
                    }
                    else
                    {
                        BLT.Put(x + (int)lengthToCover - 1, y + 2, bar_right);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        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);
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
 protected static void RenderSpriteIfSpecified(int x, int y, ISpriteManager spriteManager, string spriteName, AnimationFrame frame)
 {
     if (!string.IsNullOrEmpty(spriteName))
     {
         BLT.Put(x, y, spriteManager.Tile(spriteName, frame));
     }
 }
        private static void RenderBarContainer(int x, int y, ISpriteManager spriteManager, int totalLength, IDataRogueControl display)
        {
            BLTLayers.Set(BLTLayers.UIElements, display.ActivityIndex);
            BLT.Put(x, y, spriteManager.Tile("bar_container_left"));

            for (int i = 4; i < totalLength - 6; i += 2)
            {
                BLT.Put(x + i, y, spriteManager.Tile("bar_container_mid"));
            }

            BLT.Put(x + totalLength - 4 - 4, y, spriteManager.Tile("bar_container_right"));
        }
Ejemplo n.º 5
0
        protected static void RenderBackgroundBox(int x, int y, int activityIndex, Size size, ISpriteManager spriteManager, string spriteName = "textbox_blue")
        {
            BLTLayers.Set(BLTLayers.UIElements, activityIndex);
            BLT.Font("");
            var width  = size.Width / BLTTilesIOSystem.TILE_SPACING;
            var height = size.Height / BLTTilesIOSystem.TILE_SPACING;

            var spriteSheet = spriteManager.Get(spriteName);

            for (int xCoord = 0; xCoord < width; xCoord++)
            {
                for (int yCoord = 0; yCoord < height; yCoord++)
                {
                    BLT.Put(x + xCoord * BLTTilesIOSystem.TILE_SPACING, y + yCoord * BLTTilesIOSystem.TILE_SPACING, spriteSheet.Tile(BLTTileDirectionHelper.GetDirections(xCoord, width, yCoord, height)));
                }
            }
        }
Ejemplo n.º 6
0
        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);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
        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);
                    }
                }
            }
        }
Ejemplo n.º 8
0
        protected override void DisplayInternal(ISpriteManager spriteManager, IDataRogueControl control, ISystemContainer systemContainer, List <MapCoordinate> playerFov)
        {
            var display     = control as ButtonControl;
            var x           = control.Position.X;
            var y           = control.Position.Y;
            var pressed     = control.IsPressed;
            var focused     = control.IsFocused;
            var spriteSheet = focused ? spriteManager.Get("button_pressed") : spriteManager.Get("button_unpressed");

            BLT.Font("text");

            var textSize   = BLT.Measure(display.Text).Width;
            var buttonSize = textSize + 4;

            if (buttonSize % 8 != 0)
            {
                buttonSize = (buttonSize / 8 + 1) * 8;
            }

            var numberOfTiles = buttonSize / 8;

            BLT.Font("");
            BLTLayers.Set((int)BLTLayers.UIElements, control.ActivityIndex);
            for (int i = 0; i < numberOfTiles; i++)
            {
                TileDirections direction = TileDirections.None;
                if (i != 0)
                {
                    direction |= TileDirections.Left;
                }

                if (i != numberOfTiles - 1)
                {
                    direction |= TileDirections.Right;
                }

                BLT.Put(x + 8 * i, y, spriteSheet.Tile(direction));
            }

            BLT.Font("text");
            BLTLayers.Set((int)BLTLayers.Text, control.ActivityIndex);
            BLT.Print(x + buttonSize / 2 - textSize / 2, y + (focused ? 3 : 2), display.Text);
        }
        protected override void DisplayInternal(ISpriteManager spriteManager, IDataRogueControl control, ISystemContainer systemContainer, List <MapCoordinate> playerFov)
        {
            var display = control as MultipleChoiceFormData;
            var x       = control.Position.X;
            var y       = control.Position.Y;

            BLT.Font("text");
            var text     = display.Value.ToString();
            var textSize = BLT.Measure(text);

            BLT.Print(x + 10, y, text);

            if (control.IsFocused)
            {
                BLTLayers.Set(BLTLayers.UIElements, control.ActivityIndex);
                BLT.Font("");
                BLT.Put(x, y - 2, spriteManager.Tile("ui_arrow", TileDirections.Left));
                BLT.Put(x + textSize.Width + 12, y - 2, spriteManager.Tile("ui_arrow", TileDirections.Right));
            }
        }
        private static void RenderLayer(int layer, IDataRogueControl control, ISpriteSheet sprite, int renderWidth, int renderHeight, bool[,] checks)
        {
            BLTLayers.Set(layer, control.ActivityIndex);

            for (int y = 0; y < renderHeight; y++)
            {
                for (int x = 0; x < renderWidth; x++)
                {
                    if (checks[x + 1, y + 1])
                    {
                        var renderX = control.Position.Left + x * BLTTilesIOSystem.TILE_SPACING;
                        var renderY = control.Position.Top + y * BLTTilesIOSystem.TILE_SPACING;

                        var aboveConnect = checks[x + 1, y + 1] == checks[x + 1, y];
                        var belowConnect = checks[x + 1, y + 1] == checks[x + 1, y + 2];
                        var leftConnect  = checks[x + 1, y + 1] == checks[x, y + 1];
                        var rightConnect = checks[x + 1, y + 1] == checks[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;
                        }

                        BLT.Put(renderX, renderY, sprite.Tile(directions));
                    }
                }
            }
        }
Ejemplo n.º 11
0
        protected override void DisplayInternal(ISpriteManager spriteManager, IDataRogueControl display, ISystemContainer systemContainer, List <MapCoordinate> playerFov)
        {
            var x            = display.Position.Left;
            var y            = display.Position.Top;
            var statsControl = (display as IDataRogueInfoControl);
            var entity       = statsControl.Entity;

            BLT.Font("");

            BLTLayers.Set(BLTLayers.MapTileBottom, statsControl.ActivityIndex);
            var boxSprite = spriteManager.Get("textbox_grey");

            BLT.Put(x, y, boxSprite.Tile(TileDirections.Down | TileDirections.Right));
            BLT.Put(x + BLTTilesIOSystem.TILE_SPACING, y, boxSprite.Tile(TileDirections.Down | TileDirections.Left));
            BLT.Put(x, y + BLTTilesIOSystem.TILE_SPACING, boxSprite.Tile(TileDirections.Up | TileDirections.Right));
            BLT.Put(x + BLTTilesIOSystem.TILE_SPACING, y + BLTTilesIOSystem.TILE_SPACING, boxSprite.Tile(TileDirections.Up | TileDirections.Left));

            var appearance = entity.Has <SpriteAppearance>() ? entity.Get <SpriteAppearance>() : new SpriteAppearance {
                Top = "unknown"
            };

            if (!string.IsNullOrEmpty(appearance.Bottom))
            {
                BLTLayers.Set(BLTLayers.MapEntityBottom, statsControl.ActivityIndex);
                BLT.Put(x + 4, y + 4, spriteManager.Tile(appearance.Bottom));
            }
            if (!string.IsNullOrEmpty(appearance.Top))
            {
                BLTLayers.Set(BLTLayers.MapEntityTop, statsControl.ActivityIndex);
                BLT.Put(x + 4, y + 4, spriteManager.Tile(appearance.Top));
            }

            BLTLayers.Set(BLTLayers.Text, statsControl.ActivityIndex);

            var text = $"{entity.GetBLTName()}";

            y += 5;
            RenderText(x + 18, y, statsControl.ActivityIndex, out _, text, statsControl.Color, false, font: "textLarge");
            y += 13;
        }
Ejemplo n.º 12
0
        protected override void DisplayInternal(ISpriteManager spriteManager, IDataRogueControl control, ISystemContainer systemContainer, List <MapCoordinate> playerFov)
        {
            var backgroundSpriteSheet = spriteManager.Get("textbox_blue");

            BLTLayers.Set(BLTLayers.Background, control.ActivityIndex);
            BLT.Font("");

            var width  = (int)Math.Ceiling(control.Position.Width / (double)BLTTilesIOSystem.TILE_SPACING);
            var height = (int)Math.Ceiling(control.Position.Height / (double)BLTTilesIOSystem.TILE_SPACING);

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    TileDirections directions = BLTTileDirectionHelper.GetDirections(x, width, y, height);

                    var sprite = backgroundSpriteSheet.Tile(directions);

                    BLT.Put(control.Position.Left + x * BLTTilesIOSystem.TILE_SPACING, control.Position.Top + y * BLTTilesIOSystem.TILE_SPACING, sprite);
                }
            }
        }
Ejemplo n.º 13
0
        protected override void DisplayInternal(ISpriteManager spriteManager, IDataRogueControl control, ISystemContainer systemContainer, List <MapCoordinate> playerFov)
        {
            var display = control as StatsFormData;
            var x       = display.Position.X;
            var y       = display.Position.Y;

            var stats = display.Stats;

            var statTotal = $"[[{display.CurrentTotalStat.ToString().PadLeft(4)}/{display.MaxTotalStat.ToString().PadRight(4)}]]";

            BLT.Print(16 + x, y, statTotal);

            var longestStat = stats.Max(s => BLT.Measure(s.statName).Width);

            y += 4;

            foreach (var stat in stats)
            {
                var statSelected = display.SubSelection == stat.statName;

                BLT.Print(12, y, (stat.statName + ": ").PadRight(longestStat + 2));
                BLT.Print(12 + longestStat + 4, y, (statSelected ? "[color=red]" : "") + "-");
                BLT.Print(12 + longestStat + 8, y, stat.statValue.ToString().PadBoth(4));
                BLT.Print(12 + longestStat + 16, y, (statSelected ? "[color=green]" : "") + "+");

                if (statSelected)
                {
                    BLTLayers.Set(BLTLayers.UIElements, control.ActivityIndex);
                    BLT.Font("");
                    BLT.Put(6, y, spriteManager.Tile("selector_left", TileDirections.Left));
                    BLTLayers.Set(BLTLayers.Text, control.ActivityIndex);
                    BLT.Font("text");
                }

                y += 4;
            }
        }
Ejemplo n.º 14
0
        protected override void DisplayInternal(ISpriteManager spriteManager, IDataRogueControl control, ISystemContainer systemContainer, List <MapCoordinate> playerFov)
        {
            var display = control as TargetingOverlayControl;
            var targetingActivityData = display.TargetingActivity;
            var targetingSprites      = new Dictionary <TargetingStatus, ISpriteSheet>
            {
                { TargetingStatus.Targetable, spriteManager.Get("targetable") },
                { TargetingStatus.Targeted, spriteManager.Get("current_target") }
            };

            BLTLayers.Set(BLTLayers.MapShade, control.ActivityIndex);
            BLT.Font("");

            var cameraPosition = systemContainer.RendererSystem.CameraPosition;

            var currentMap = systemContainer.MapSystem.MapCollection[cameraPosition.Key];
            var cameraX    = cameraPosition.X;
            var cameraY    = cameraPosition.Y;

            MapCoordinate playerPosition = systemContainer.PositionSystem.CoordinateOf(systemContainer.PlayerSystem.Player);

            var targetableCells = systemContainer.TargetingSystem.TargetableCellsFrom(targetingActivityData.TargetingData, playerPosition);

            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 sprites = new TargetingStatus[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);
                    var targetingStatus = targetingActivityData.GetTargetingStatus(currentCell);

                    if (targetingStatus != TargetingStatus.NotTargeted)
                    {
                        sprites[x + 1, y + 1] = targetingStatus;
                    }
                }
            }

            for (int y = 0; y < renderHeight; y++)
            {
                for (int x = 0; x < renderWidth; x++)
                {
                    var targetingStatus = sprites[x + 1, y + 1];

                    if (targetingStatus != TargetingStatus.NotTargeted)
                    {
                        var renderX = control.Position.Left + x * BLTTilesIOSystem.TILE_SPACING;
                        var renderY = control.Position.Top + y * BLTTilesIOSystem.TILE_SPACING;

                        var aboveConnect = sprites[x + 1, y + 1] == sprites[x + 1, y];
                        var belowConnect = sprites[x + 1, y + 1] == sprites[x + 1, y + 2];
                        var leftConnect  = sprites[x + 1, y + 1] == sprites[x, y + 1];
                        var rightConnect = sprites[x + 1, y + 1] == sprites[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;
                        }

                        BLT.Put(renderX, renderY, targetingSprites[targetingStatus].Tile(directions));
                    }
                }
            }
        }