public StatusWriter(List <IMyTextPanel> lcds)
            {
                this.lcds = lcds;

                buffer        = new StringBuilder();
                currentStatus = TargetingStatus.Idle;
                update        = true;
            }
            public void UpdateStatus(TargetingStatus targetingStatus)
            {
                if (currentStatus == targetingStatus)
                {
                    return;
                }

                currentStatus = targetingStatus;
                update        = true;
            }
        private static RLColor ApplyTargetingColor(TargetingStatus cellTargeting, RLColor backColor, bool isInFov)
        {
            if (isInFov)
            {
                if (cellTargeting.HasFlag(TargetingStatus.Targeted))
                {
                    return(RLColor.Red);
                }

                if (cellTargeting.HasFlag(TargetingStatus.Targetable))
                {
                    return(RLColor.LightRed);
                }
            }

            return(backColor);
        }
        private void PickSpot()
        {
            columnNumber = rowNumber = -1;
            bool done = false;
            // For now result not actually used
            bool            result = false;
            TargetingStatus status = TargetingStatus.Continue;

            while (!done)
            {
                Console.Clear();
                DisplayInstructions();
                DisplayCurrentStatus();
                if (status == TargetingStatus.Continue)
                {
                    Console.WriteLine("");
                }
                else if (status == TargetingStatus.InvalidTarget)
                {
                    Console.ForegroundColor = ERROR_COLOR;
                    Console.WriteLine("Invalid location, please call out another location");
                    Console.ResetColor();
                }
                else
                {
                    // Should not reach here
                    Console.WriteLine("Time to debug why the game did not break out of loop");
                }

                DisplayGameState.DisplayBothBoards(opponentGameState, playerGameState, rowNumber, columnNumber);
                status = HandleInput(ReadUserInput());
                if (status == TargetingStatus.LegalTarget)
                {
                    result = opponentGameState.MakeMove(rowNumber, columnNumber);
                    done   = true;
                }
            }
            Console.Clear();
            opponentGameState.DisplayAction(rowNumber, columnNumber, "Player" + playerNum);
            // Display board state one last time before clearing screen
            DisplayGameState.DisplayBothBoards(opponentGameState, playerGameState, rowNumber, columnNumber);
        }
Example #5
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));
                    }
                }
            }
        }
        public static void DrawCell(RLConsole mapConsole, int x, int y, IPositionSystem positionSystem, IMap currentMap, int lookupX, int lookupY, List <MapCoordinate> playerFov, TargetingStatus cellTargeting = TargetingStatus.NotTargeted)
        {
            MapCoordinate coordinate = new MapCoordinate(currentMap.MapKey, lookupX, lookupY);
            var           backColor  = RLColor.Black;

            var isInFov = playerFov.Contains(coordinate);

            Appearance appearance = GetAppearanceAt(positionSystem, currentMap, coordinate, ref backColor, isInFov);

            var foreColor = isInFov ? appearance.Color.ToRLColor() : RLColor.Gray;

            backColor = ApplyTargetingColor(cellTargeting, backColor, isInFov);

            mapConsole.Set(x, y, foreColor, backColor, appearance.Glyph);
        }