Exemplo n.º 1
0
 public override void DrawNewFrame(TCODConsole screen)
 {
     if (m_enabled)
     {
         foreach (Point p in m_playerFOV)
         {
             int screenPlacementX = m_mapUpCorner.X + p.X + 1;
             int screenPlacementY = m_mapUpCorner.Y + p.Y + 1;
             if (IsDrawableTile(screenPlacementX, screenPlacementY))
                 screen.setCharBackground(screenPlacementX, screenPlacementY, ColorPresets.DarkRed);
         }
         foreach (ICharacter c in m_monsterFOV.Keys)
         {
             foreach (Point p in m_monsterFOV[c])
             {
                 int screenPlacementX = m_mapUpCorner.X + p.X + 1;
                 int screenPlacementY = m_mapUpCorner.Y + p.Y + 1;
                 if (IsDrawableTile(screenPlacementX, screenPlacementY))
                 {
                     TCODColor currentColor = screen.getCharBackground(screenPlacementX, screenPlacementY);
                     screen.setCharBackground(screenPlacementX, screenPlacementY, TCODColor.Interpolate(currentColor, GetColorForMonster(c), .6f));
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Updates the consoles tiles to the default state of this window
        /// </summary>
        public virtual void InitializeConsole()
        {
            Vector2   screenCoords;
            TCODColor coordColor;
            Vector2   screenCenter = new Vector2(RogueGame.WindowWidth / 2, RogueGame.WindowHeight / 2);

            console.clear();

            for (int x = 0; x < console.getWidth(); x++)
            {
                for (int y = 0; y < console.getHeight(); y++)
                {
                    // Get the absolute screen coords
                    screenCoords = new Vector2(x + origin.x, y + origin.y);
                    coordColor   = Renderer.GetFadedColor(screenCoords, screenCenter, backgroundColor);

                    console.setCharBackground(x, y, coordColor);
                    DrawBorderAt(x, y, console.getWidth(), console.getHeight(), screenCoords, screenCenter);
                }
            }

            // draw the windows title
            if (title != null)
            {
                DrawText(2, 0, title, TCODColor.white);
            }
        }
Exemplo n.º 3
0
        // Display a line of text
        public void DisplayText(string textToDisplay, int x, int y, TCODColor foregroundColor, TCODColor backgroundColor, int Index)
        {
            // Handle mainmenu colour-swapping
            if (Index == (int)currentMenuOption)
            {
                foregroundColor   = TCODColor.black;
                colourInterpolate = colourInterpolate + colourInterpolateStep;
                if (colourInterpolate >= 0.91)
                {
                    colourInterpolateStep = -0.01;
                }
                else if (colourInterpolate <= 0.11)
                {
                    colourInterpolateStep = 0.01;
                }
                backgroundColor = TCODColor.Interpolate(TCODColor.yellow, TCODColor.red, (float)colourInterpolate);
            }

            rootConsole.setBackgroundColor(backgroundColor);
            rootConsole.setForegroundColor(foregroundColor);

            if (Index != -1)
            {
                System.Text.StringBuilder OffSetString = new System.Text.StringBuilder();
                OffSetString.Append(' ', (36 - textToDisplay.Length) / 2);
                textToDisplay = OffSetString + textToDisplay + OffSetString;
            }
            else
            {
                if (x == -1)
                {
                    x = (consoleWidth - textToDisplay.Length) / 2;
                }
            }

            int offset = 0;

            foreach (char value in textToDisplay)
            {
                if (value == '[')
                {
                    rootConsole.setForegroundColor(foregroundColor);
                }
                else if (value == ']')
                {
                    rootConsole.setForegroundColor(foregroundColor);
                }
                else if (offset == 1 && textToDisplay[0] == '[')
                {
                    rootConsole.setForegroundColor(foregroundColor);
                }
                else
                {
                    rootConsole.setForegroundColor(foregroundColor);
                }
                offset++;
                rootConsole.setCharBackground(x + offset, y, backgroundColor, TCODBackgroundFlag.Set);
                rootConsole.print(x + offset, y, value.ToString());
            }
        }
Exemplo n.º 4
0
        public new void Draw(TCODConsole console, Point offset)
        {
            switch (DrawMode)
            {
            case DrawModes.Normal:
                if (Area.SolidTerrainAt(Position))
                {
                    goto case DrawModes.OnlyForegroundColor;
                }
                base.Draw(console, offset);
                break;

            case DrawModes.OnlyForegroundColor:
                if (Position.X > offset.X && Position.X <= offset.X + 45 && Position.Y > offset.Y && Position.Y <= offset.Y + 45)
                {
                    console.setCharForeground(Position.X - offset.X, Position.Y - offset.Y, ForegroundColor);
                }
                break;

            case DrawModes.OnlyBackgroundColor:
                if (Position.X > offset.X && Position.X <= offset.X + 45 && Position.Y > offset.Y && Position.Y <= offset.Y + 45)
                {
                    console.setCharBackground(Position.X - offset.X, Position.Y - offset.Y, BackgroundColor);
                }
                break;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Draw a cricle, which optionally fades out towards the edges. Only sets cell backgrounds
        /// </summary>
        public static void DrawCircle(TCODConsole console, Vector2 center, float radius, TCODColor color, bool fade = true)
        {
            TCODColor currentCol;
            Vector2   pos;
            int       e = (int)(center.x + radius);
            int       w = (int)(center.x - radius);
            int       n = (int)(center.y - radius);
            int       s = (int)(center.y + radius);

            // small optimization so that the distance doesnt have to be calculated for each tile
            float radSqr = radius * radius;

            for (int x = w; x <= e; x++)
            {
                for (int y = n; y <= s; y++)
                {
                    pos.x = x;
                    pos.y = y;

                    float sqrDist = (center - pos).SqrMagnitude();
                    if (sqrDist > radSqr)
                    {
                        continue;
                    }

                    float mag = fade ? 1.0f - (sqrDist / radSqr) : 1.0f;

                    currentCol = console.getCharBackground(x, y);
                    console.setCharBackground(x, y, CrossFadeColor(color, currentCol, mag));
                }
            }
        }
Exemplo n.º 6
0
        public override void DrawNewFrame(TCODConsole screen)
        {
            if (m_enabled)
            {
                int lowX = m_cursorPosition.X - (MapDrawnWidth / 2);
                int lowY = m_cursorPosition.Y - (MapDrawnHeight / 2);
                for (int i = lowX; i < lowX + MapDrawnWidth; ++i)
                {
                    for (int j = lowY; j < lowY + MapDrawnHeight; ++j)
                    {
                        int screenPlacementX = m_mapCorner.X + i + 1;
                        int screenPlacementY = m_mapCorner.Y + j + 1;

                        if (IsDrawableTile(screenPlacementX, screenPlacementY))
                        {
                            if (m_map.IsPointOnMap(new Point(i, j)))
                            {
                                TileVisibility isVisible = m_tileVisibility[i, j];
                                if (isVisible == TileVisibility.Unvisited)
                                {
                                    // If it's unvisisted, nuke the square completed black
                                    screen.setCharBackground(screenPlacementX, screenPlacementY, ColorPresets.Black);
                                    screen.setCharForeground(screenPlacementX, screenPlacementY, ColorPresets.Black);
                                    screen.putChar(screenPlacementX, screenPlacementY, ' ');
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 7
0
        // Draw the tile cursor, and inspection window if there are entites under the tile
        private void DrawTileCursor(TCODConsole baseConsole, PlayerController.TileCursor tileCursor, Camera camera)
        {
            if (tileCursor.IsActive)
            {
                Vector2 start      = Renderer.WorldToScreenCoord(camera, player.position);
                Vector2 end        = tileCursor.position;
                Vector2 inspectPos = Renderer.ScreenToWorldCoord(camera, tileCursor.position);

                // never draw it if cursor is not on map
                if (!world.currentMap.InBounds(inspectPos))
                {
                    return;
                }

                // change color depending on if the player has los to the endpoint
                TCODColor lineColor = tileCursor.hasLOS ? Constants.COL_FRIENDLY : Constants.COL_ANGRY;

                Renderer.DrawLine(baseConsole, start, end, lineColor);
                baseConsole.setCharBackground(end.X, end.Y, cursorColor);

                // decide if there is anything to inspect on this tile
                Entity[] entities = world.currentMap.GetAllObjectsAt(inspectPos.X, inspectPos.Y);

                // if there is stuff to inspect, and the inspect window is not open or is initialized for a different tile
                if (entities.Length > 0 &&
                    (!inspectionWindow.isVisible || inspectionWindow.currentLocation != inspectPos))
                {
                    // open the window, but make sure its on the opposite side of the where the cursor is so it never overlaps
                    if (tileCursor.position.X < engine.consoleWidth / 2)
                    {
                        inspectionWindow.origin.x = (camera.screenX + camera.width) - inspectionWindow.console.getWidth();
                    }
                    else
                    {
                        inspectionWindow.origin.x = camera.screenX;
                    }

                    var tile = world.currentMap.GetTile(inspectPos.X, inspectPos.Y);

                    // only open the inspector if the target tile is in los
                    if (tile.cachedLOS)
                    {
                        inspectionWindow.OpenForTile(tile, inspectPos);
                    }
                }
                else if (entities.Length == 0 && inspectionWindow.isVisible)
                {
                    inspectionWindow.Close();
                }
            }
            else
            {
                // always close inspect window if tile cursor gets turned off
                if (inspectionWindow.isVisible)
                {
                    inspectionWindow.Close();
                }
            }
        }
Exemplo n.º 8
0
        public override void DrawNewFrame(TCODConsole screen)
        {
            if (m_enabled)
            {
                for (int i = 0; i < m_width; ++i)
                {
                    for (int j = 0; j < m_height; ++j)
                    {
                        int screenPlacementX = m_mapUpCorner.X + i + 1;
                        int screenPlacementY = m_mapUpCorner.Y + j + 1;

                        if (IsDrawableTile(screenPlacementX, screenPlacementY))
                        {
                            if (m_moveableGrid[i, j])
                                screen.setCharBackground(screenPlacementX, screenPlacementY, ColorPresets.DarkGreen);
                            else
                                screen.setCharBackground(screenPlacementX, screenPlacementY, ColorPresets.DarkRed);
                        }
                    }
                }
            }
        }
Exemplo n.º 9
0
        private void ColorSquare(TCODConsole screen, Point p, double strength, TCODColor color)
        {
            int screenPlacementX = m_mapUpCorner.X + p.X + 1;
            int screenPlacementY = m_mapUpCorner.Y + p.Y + 1;

            if (IsDrawableTile(screenPlacementX, screenPlacementY))
            {
                TCODColor attackColor = TCODColor.Interpolate(ColorPresets.Black, color, (float)strength);
                TCODColor currentColor = screen.getCharBackground(screenPlacementX, screenPlacementY);
                TCODColor newColor = TCODColor.Interpolate(currentColor, attackColor, .5f);
                screen.setCharBackground(screenPlacementX, screenPlacementY, newColor);
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Draws a simple rect
        /// </summary>
        public static void DrawRect(TCODConsole console, int x, int y, int width, TCODColor color)
        {
            TCODColor fadedCol;
            Vector2   pos;

            for (int i = 0; i < width; i++)
            {
                pos      = new Vector2(x + i, y);
                fadedCol = GetFadedColor(pos, color);
                console.setCharBackground(pos.X, pos.Y, fadedCol);
                console.setChar(pos.X, pos.Y, ' ');
            }
        }
Exemplo n.º 11
0
        public void Draw(TCODConsole console, IGameEngine engine, List<ISkill> selectedSkillList, List<ISkill> newlySelectedSkillList, Point cursorPosition)
        {
            SkillSquare cursorSkillSquare = null;
            ISkill cursorOverSkill = null;
            if (m_squareLookup.ContainsKey(cursorPosition))
            {
                cursorSkillSquare = m_squareLookup[cursorPosition];
                cursorOverSkill = cursorSkillSquare.GetSkill(engine);
            }
            int selectedSkillCost = newlySelectedSkillList.Sum(x => x.Cost);

            int upperLeftX = cursorPosition.X - ((SkillTreePainter.SkillTreeWidth - 1) / 2);
            int upperLeftY = cursorPosition.Y - ((SkillTreePainter.SkillTreeHeight - 1) / 2);

            int lowerRightX = cursorPosition.X - ((SkillTreePainter.SkillTreeWidth - 1) / 2);
            int lowerRightY = cursorPosition.Y - ((SkillTreePainter.SkillTreeHeight - 1) / 2);

            int arrayWidth = CharArray.GetLength(0);
            int arrayHeight = CharArray.GetLength(1);

            for (int i = SkillTreePainter.UpperLeft + 1; i < SkillTreePainter.SkillTreeWidth + SkillTreePainter.UpperLeft - 1; ++i)
            {
                for (int j = SkillTreePainter.UpperLeft + 1; j < SkillTreePainter.SkillTreeHeight + SkillTreePainter.UpperLeft -1; ++j)
                {
                    int gridX;
                    int gridY;
                    ConvertDrawToGridCoord(i, j, cursorPosition, out gridX, out gridY);
                    if (gridX >= 0 && gridY >= 0 && gridX < arrayWidth && gridY < arrayHeight)
                    {
                        //CalculateBackgroundColorForSkill
                        // We're painting something that shows up on our "grid"
                        TCODColor background = CalculateBackgroundColorForSkill(new Point(gridX, gridY), cursorPosition, selectedSkillList, newlySelectedSkillList, engine.Player.SkillPoints, selectedSkillCost, cursorOverSkill);
                        console.putCharEx(i, j, CharArray[gridX, gridY], UIHelper.ForegroundColor, background);
                    }
                    else
                    {
                        // We're not painting something on our grid, black it out
                        console.setCharBackground(i, j, m_black);
                    }
                }
            }

            if (cursorSkillSquare != null)
                DrawSkillPopup(console, selectedSkillList, engine.Player.SkillPoints - selectedSkillCost, cursorSkillSquare, cursorOverSkill, cursorPosition);
        }
Exemplo n.º 12
0
        public override void DrawNewFrame(TCODConsole screen)
        {
            if (m_isSelectionCursor)
            {
                screen.setCharBackground(ScreenCenter.X + 1, ScreenCenter.Y + 1, TCODColor.darkYellow);

                if (ToolTipsEnabled)
                {
                    if (TCODSystem.getElapsedMilli() - m_lastCursorMovedTime > TimeUntilToolTipPopup)
                    {
                        if (m_currentToolTips.Count > 0)
                        {
                            const int MaxNumberOfLinesToShow = 3;
                            int numberOfLinesToShow = System.Math.Min(m_currentToolTips.Count, MaxNumberOfLinesToShow);

                            int longestLine = 0;
                            for (int i = 0; i < numberOfLinesToShow; ++i)
                                longestLine = System.Math.Max(longestLine, m_currentToolTips[i].Length);

                            // If we're going to need to print "...more..." make sure we have the width
                            if (m_currentToolTips.Count > MaxNumberOfLinesToShow)
                                longestLine = System.Math.Max(longestLine, 10);

                            screen.setBackgroundColor(ColorPresets.DarkGray);

                            int frameHeight = m_currentToolTips.Count > MaxNumberOfLinesToShow ? 3 + numberOfLinesToShow : 2 + numberOfLinesToShow;
                            screen.printFrame(ScreenCenter.X + 2, ScreenCenter.Y - 2, longestLine + 2, frameHeight, false, TCODBackgroundFlag.Multiply);

                            for (int i = 0; i < numberOfLinesToShow; ++i)
                                screen.printEx(ScreenCenter.X + 3, ScreenCenter.Y - 1 + i, TCODBackgroundFlag.Multiply, TCODAlignment.LeftAlignment, m_currentToolTips[i]);

                            if (m_currentToolTips.Count > MaxNumberOfLinesToShow)
                                screen.printEx(ScreenCenter.X + 3, ScreenCenter.Y - 1 + MaxNumberOfLinesToShow, TCODBackgroundFlag.Multiply, TCODAlignment.LeftAlignment, "...more...");

                            screen.setBackgroundColor(ColorPresets.Black);
                        }
                    }
                }
            }
        }
Exemplo n.º 13
0
 public static void SetBackColorOfPos(IntVector2 pos, Color color)
 {
     displayConsole.setCharBackground(pos.X, pos.Y, new libtcod.TCODColor(color.R, color.G, color.B));
 }
Exemplo n.º 14
0
        public new void Draw(TCODConsole console, Point offset)
        {
            switch (DrawMode) {
                case DrawModes.Normal:
                    if (Area.SolidTerrainAt(Position)) goto case DrawModes.OnlyForegroundColor;
                    base.Draw(console, offset);
                    break;

                case DrawModes.OnlyForegroundColor:
                    if (Position.X > offset.X && Position.X <= offset.X + 45 && Position.Y > offset.Y && Position.Y <= offset.Y + 45) {
                        console.setCharForeground(Position.X - offset.X, Position.Y - offset.Y, ForegroundColor);
                    }
                    break;

                case DrawModes.OnlyBackgroundColor:
                    if (Position.X > offset.X && Position.X <= offset.X + 45 && Position.Y > offset.Y && Position.Y <= offset.Y + 45) {
                        console.setCharBackground(Position.X - offset.X, Position.Y - offset.Y, BackgroundColor);
                    }
                    break;
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Renders the current map as the background of the level
        /// </summary>
        private void RenderGameBackground(TCODConsole targetConsole, Camera camera, AreaMap currentMap,
                                          Vector2 screenCenter)
        {
            int left   = camera.GetBound(Camera.EBound.Left);
            int right  = camera.GetBound(Camera.EBound.Right);
            int top    = camera.GetBound(Camera.EBound.Top);
            int bottom = camera.GetBound(Camera.EBound.Bottom);

            if (left < 0)
            {
                left  = 0;
                right = camera.width;
            }

            if (top < 0)
            {
                top    = 0;
                bottom = camera.height;
            }

            if (right > currentMap.width)
            {
                left  = currentMap.width - camera.width;
                right = currentMap.width;
            }

            if (bottom > currentMap.height)
            {
                top    = currentMap.height - camera.height;
                bottom = currentMap.height;
            }

            TCODColor fg, bg;

            for (int y = top; y < bottom; y++)
            {
                for (int x = left; x < right; x++)
                {
                    // Translate the world coords into screen coords
                    int screenX = camera.screenX + x - left;
                    int screenY = camera.screenY + y - top;

                    var tile = currentMap.GetTile(x, y);
                    fg = tile.terrain.fg;
                    bg = tile.terrain.bg;
                    char ch = tile.terrain.Ch;

                    if (!tile.explored && showOnlyExplored)
                    {
                        bg = AreaMap.unexplored.bg;
                        fg = AreaMap.unexplored.fg;
                        ch = AreaMap.unexplored.Ch;
                    }

                    // If the tile is not in the current LOS, fade its color
                    if (!tile.cachedLOS && showOnlyLOS)
                    {
                        bg = FadeColor(bg, blockedBrightness);
                        fg = FadeColor(fg, blockedBrightness);
                    }

                    if (doCircularFade)
                    {
                        bg = GetFadedColor(new Vector2(screenX, screenY), screenCenter, bg);
                        fg = GetFadedColor(new Vector2(screenX, screenY), screenCenter, fg);
                    }

                    targetConsole.setCharBackground(screenX, screenY, bg);
                    targetConsole.setCharForeground(screenX, screenY, fg);
                    targetConsole.setChar(screenX, screenY, ch);
                }
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Draws a line on the console from start to end
        /// </summary>
        public static void DrawLine(TCODConsole console, Vector2 from, Vector2 to, TCODColor color, bool fade = true)
        {
            if (from == to)
            {
                return;
            }

            Vector2 delta     = from - to;
            int     absDeltax = Math.Abs(delta.X);
            int     absDeltay = Math.Abs(delta.Y);
            int     signx     = Math.Sign(delta.x);
            int     signy     = Math.Sign(delta.y);
            int     error     = 0;

            int       x = to.X;
            int       y = to.Y;
            Vector2   current;
            TCODColor currentBg;

            // Is the line x or y dominant
            if (absDeltax > absDeltay)
            {
                error = absDeltay * 2 - absDeltax;
                do
                {
                    if (error >= 0)
                    {
                        y     += signy;
                        error -= absDeltax * 2;
                    }

                    x     += signx;
                    error += absDeltay * 2;

                    if (x == from.x && y == from.y)
                    {
                        break;
                    }

                    current = new Vector2(x - to.x, y - to.y);
                    float mag = fade ? current.SqrMagnitude() / (to - from).SqrMagnitude() : 1.0f;
                    currentBg = console.getCharBackground(x, y);


                    console.setCharBackground(x, y, CrossFadeColor(color, currentBg, mag));
                } while(x != from.x || y != from.y);
            }
            else
            {
                error = absDeltax * 2 - absDeltay;
                do
                {
                    if (error >= 0)
                    {
                        x     += signx;
                        error -= absDeltay * 2;
                    }

                    y     += signy;
                    error += absDeltax * 2;

                    if (x == from.x && y == from.y)
                    {
                        break;
                    }

                    current = new Vector2(x - to.x, y - to.y);
                    float mag = fade ? current.SqrMagnitude() / (to - from).SqrMagnitude() : 1.0f;
                    currentBg = console.getCharBackground(x, y);

                    console.setCharBackground(x, y, CrossFadeColor(color, currentBg, mag));
                } while(x != from.x || y != from.y);
            }
        }
Exemplo n.º 17
0
Arquivo: Fov.cs Projeto: dritory/Janus
        public override void render(bool insight)
        {
            if (!insight && owner != null)
            {
                Map m  = map;
                int ox = owner.x - m.offsetX;
                int oy = owner.y - m.offsetY;
                if (ox >= -fovRadius && ox < m.renderWidth + fovRadius && oy >= -fovRadius && oy < m.renderHeight + fovRadius)
                {
                    if (owner.x >= 0 && owner.x < m.tiles.GetLength(0) && owner.y >= 0 && owner.y < m.tiles.GetLength(1))
                    {
                        lightmap.clear();
                        int OFX = m.renderX - ox + mapx <= 0 ? 0 : m.renderX - ox + mapx;
                        int OFY = m.renderY - oy + mapy <= 0 ? 0 : m.renderY - oy + mapy;
                        int OFW = ox + width - m.renderWidth <= 0 ? 0 : ox + width - m.renderWidth;
                        int OFH = oy + height - m.renderHeight <= 0 ? 0 : oy + height - m.renderHeight;
                        for (int x = -mapx + OFX; x < width - OFW; x++)
                        {
                            for (int y = -mapy + OFY; y < height - OFH; y++)
                            {
                                int    mx       = owner.x + x;
                                int    my       = owner.y + y;
                                double distance = Math.Sqrt(Math.Pow(owner.x - (mx), 2) + Math.Pow(owner.y - (my), 2));
                                if (distance <= fovRadius)
                                {
                                    if ((m.isExplored(mx, my) || m.showAllTiles))
                                    {
                                        try
                                        {
                                            byte rs = (byte)((strenght * color.Red) / 255);
                                            byte gs = (byte)((strenght * color.Green) / 255);
                                            byte bs = (byte)((strenght * color.Blue) / 255);

                                            byte r = (byte)(rs - (((float)rs / ((float)fovRadius)) * ((byte)distance)));
                                            byte g = (byte)(gs - (((float)gs / ((float)fovRadius)) * ((byte)distance)));
                                            byte b = (byte)(bs - (((float)bs / ((float)fovRadius)) * ((byte)distance)));

                                            TCODColor lcolor = level.lightMapConsole.getCharBackground(mx - m.offsetX, my - m.offsetY);
                                            if ((int)r + (int)lcolor.Red < 255)
                                            {
                                                r += lcolor.Red;
                                            }
                                            else
                                            {
                                                r = 255;
                                            }
                                            //r += (byte)(lcolor.Red - ((int)r + (int)lcolor.Red - 255));
                                            if ((int)g + (int)lcolor.Green < 255)
                                            {
                                                g += lcolor.Green;
                                            }
                                            else
                                            {
                                                g = 255;
                                            }
                                            //g += (byte)(lcolor.Green - ((int)g + (int)lcolor.Green - 255));
                                            if ((int)b + (int)lcolor.Blue < 255)
                                            {
                                                b += lcolor.Blue;
                                            }
                                            else
                                            {
                                                b = 255;
                                            }
                                            //b += (byte)(lcolor.Blue - ((int)b + (int)lcolor.Blue - 255));
                                            byte tile = calculatedMaps[x + mapx, y + mapy, 0];

                                            /*
                                             * if (tile == 2)
                                             * {
                                             *  if (r > (byte)(rs / 3))
                                             *      r -= (byte)(rs / 3);
                                             *  if (g > (byte)(gs / 3))
                                             *      g -= (byte)(gs / 3);
                                             *  if (b > (byte)(bs / 3))
                                             *      b -= (byte)(bs / 3);
                                             * }
                                             */
                                            TCODColor col = new TCODColor(r, g, b);
                                            if (tile != 0)
                                            {
                                                lightmap.setCharBackground(mx - m.offsetX, my - m.offsetY, col, TCODBackgroundFlag.Set);
                                            }
                                            else if (false)
                                            {
                                                tile = calculatedMaps[x + mapx, y + mapy, 1];
                                                if (tile != 0)
                                                {
                                                    if (r > (byte)(rs / 3))
                                                    {
                                                        r -= (byte)(rs / 3);
                                                    }
                                                    if (g > (byte)(gs / 3))
                                                    {
                                                        g -= (byte)(gs / 3);
                                                    }
                                                    if (b > (byte)(bs / 3))
                                                    {
                                                        b -= (byte)(bs / 3);
                                                    }
                                                    if (tile == 2)
                                                    {
                                                        if (r > (byte)(rs / 5))
                                                        {
                                                            r -= (byte)(rs / 5);
                                                        }
                                                        if (g > (byte)(gs / 5))
                                                        {
                                                            g -= (byte)(gs / 5);
                                                        }
                                                        if (b > (byte)(bs / 5))
                                                        {
                                                            b -= (byte)(bs / 5);
                                                        }
                                                    }
                                                    col = new TCODColor(r, g, b);
                                                    lightmap.setCharBackground(mx - m.offsetX, my - m.offsetY, col, TCODBackgroundFlag.Set);
                                                }
                                            }
                                        }

                                        catch (Exception e)
                                        {
                                            Console.WriteLine(e.Message);
                                            throw new Exception(e.Message);
                                        }
                                    }
                                }
                                else
                                {
                                    //if (lightmap.getCharBackground(mx - m.offsetX, my - m.offsetY)!= TCODColor.black)
                                    //lightmap.setCharBackground(mx - m.offsetX, my - m.offsetY, TCODColor.black, TCODBackgroundFlag.Set);
                                }
                            }
                        }
                        TCODConsole.blit(lightmap, 0, 0,
                                         lightmap.getWidth(), lightmap.getHeight(), level.lightMapConsole, 0, 0, (float)strenght / (255 * 2), (float)strenght / (255 * 2));
                    }
                }
            }
        }
Exemplo n.º 18
0
        private void DrawTabBar(TCODConsole screen)
        {
            const int HorizontalTabOffset = 2;
            screen.rect(UpperLeft + 1, UpperLeft + 1, SkillTreeWidth - 2, HorizontalTabOffset - 1, true);

            screen.putChar(UpperLeft, UpperLeft + HorizontalTabOffset, (int)TCODSpecialCharacter.TeeEast);
            screen.putChar(UpperLeft + SkillTreeWidth - 1, UpperLeft + HorizontalTabOffset, (int)TCODSpecialCharacter.TeeWest);
            screen.hline(UpperLeft + 1, UpperLeft + HorizontalTabOffset, SkillTreeWidth - 2);

            int x = UpperLeft + 2;
            int y = UpperLeft + HorizontalTabOffset - 1;
            foreach (string name in m_skillTreeTabs.Keys)
            {
                int xOffset = name == "Water" ? 1 : 0;
                screen.print(x + xOffset, y, name);
                x += name.Length + 1;

                if (name != "Water")
                {
                    screen.putChar(x, y, (int)TCODSpecialCharacter.VertLine);

                    // This is a bit of a hack. We don't want to overwrite the color'ed background title of the frame, so we check first
                    // This can break if libtcod changes that background title color
                    if (!screen.getCharBackground(x, y - 1).Equal(new TCODColor(211, 211, 211)))
                        screen.putChar(x, y - 1, (int)TCODSpecialCharacter.TeeSouth);

                    screen.putChar(x, y + 1, (int)TCODSpecialCharacter.TeeNorth);
                }
                x += 2;

                if (m_currentTabName == name)
                {
                    int lengthReductionToDueTee = name == "Water" ? 0 : 2;
                    for (int i = x - 4 - name.Length; i < x - lengthReductionToDueTee; i++)
                    {
                        screen.setCharBackground(i, y, TCODColor.grey);
                    }
                }
            }
        }
Exemplo n.º 19
0
        private static void DrawThing(Point mapUpCorner, Point position, TCODConsole screen, TCODColor c)
        {
            int screenPlacementX = mapUpCorner.X + position.X + 1;
            int screenPlacementY = mapUpCorner.Y + position.Y + 1;

            if (IsDrawableTile(screenPlacementX, screenPlacementY))
                screen.setCharBackground(screenPlacementX, screenPlacementY, c);
        }
Exemplo n.º 20
0
        public override void DrawNewFrame(TCODConsole screen)
        {
            screen.printFrame(StartingX, 0, InfoWidth, InfoHeight, true);
            screen.printEx(SectionCenter, 1, TCODBackgroundFlag.Set, TCODAlignment.CenterAlignment, m_name);

            // The 7 and 18 here are psydo-magical, since they place the text overlap just so it fits and doesn't go over for sane values
            screen.printEx(StartingX + 7, 2, TCODBackgroundFlag.None, TCODAlignment.CenterAlignment, m_healthString);
            screen.printEx(StartingX + 18, 2, TCODBackgroundFlag.None, TCODAlignment.CenterAlignment, m_staminaString);
            for (int j = 0; j < BarLength; ++j)
                screen.setCharBackground(StartingX + 2 + j, 2, PlayerHealthBarColorAtPosition(j));

            screen.printEx(StartingX + 13, 3, TCODBackgroundFlag.Set, TCODAlignment.CenterAlignment, m_manaString);
            for (int j = 0; j < BarLength; ++j)
                screen.setCharBackground(StartingX + 2 + j, 3, PlayerManaBarColor(j));

            int nextAvailablePosition = 6;

            string skillPointString = "Skill Points: " + m_skillPoints;
            screen.print(StartingX + 2, nextAvailablePosition, skillPointString);
            nextAvailablePosition += 2;

            int linesTaken = screen.printRect(StartingX + 2, nextAvailablePosition, UIHelper.ScreenWidth - StartingX - 3, 5, m_weaponString);
            nextAvailablePosition += linesTaken + 1;

            m_colorHelper.SaveColors(screen);
            if (m_statusEffects.Count() > 0)
            {
                screen.print(StartingX + 2, nextAvailablePosition, "Status Effects:");
                int currentX = StartingX + 2 + 1 + 15;
                foreach (IStatusEffect s in m_statusEffects)
                {
                    if (currentX + s.Name.Length >= UIHelper.ScreenWidth)
                    {
                        currentX = StartingX + 2;
                        nextAvailablePosition++;
                    }
                    screen.setForegroundColor(s.IsPositiveEffect ? ColorCache.Instance["DarkGreen"] : ColorCache.Instance["DarkRed"] );
                    screen.print(currentX, nextAvailablePosition, s.Name);
                    currentX += s.Name.Length + 1;
                }
                nextAvailablePosition += 2;
            }
            m_colorHelper.ResetColors(screen);

            m_colorHelper.SaveColors(screen);
            if (m_monstersNearby.Count > 0)
            {
                screen.print(StartingX + 2, nextAvailablePosition, m_nearbyEnemyString);
                
                // Show at most 8 monsters
                int numberOfMonstersToShow = m_monstersNearby.Count > 8 ? 8 : m_monstersNearby.Count;
                for (int i = 0; i < numberOfMonstersToShow; ++i)
                {
                    ICharacter currentMonster = m_monstersNearby[i];
                    if (MapCursorEnabled)
                    {
                        if (currentMonster.Position == CursorSpot)
                            screen.setForegroundColor(ColorCache.Instance["DarkYellow"]);
                        else
                            screen.setForegroundColor(UIHelper.ForegroundColor);
                    }

                    screen.printEx(StartingX + 12, nextAvailablePosition + 1 + i, TCODBackgroundFlag.Set, TCODAlignment.CenterAlignment, currentMonster.Name);
                    for (int j = 0; j < HealthBarLength(currentMonster, true); ++j)
                        screen.setCharBackground(StartingX + 2 + j, nextAvailablePosition + 1 + i, EnemyHealthBarColor(currentMonster));
                }
                nextAvailablePosition += 2;
            }
            m_colorHelper.ResetColors(screen);

            if (Preferences.Instance.DebuggingMode)
            {
                screen.print(54, 39, "Turn Count - " + m_turnCount.ToString());

                screen.print(54, 40, "Danger - " + m_inDanger.ToString());

                string level = (m_currentLevel + 1).ToString();
                screen.print(54, 41, "Level - " + level);

                string position = m_position.ToString();
                screen.print(54, 42, position);

                string fps = TCODSystem.getFps().ToString();
                screen.print(54, 43, fps);
            }
        }