Esempio n. 1
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, ' ');
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 2
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;
            }
        }
Esempio n. 3
0
        public void Draw(TCODConsole cons)
        {
            cons.setForegroundColor(TCODColor.white);
            for (int i = 0; i < MAP_WIDTH; i++)
            {
                for (int j = 0; j < MAP_HEIGHT; j++)
                {
                    cons.putChar(i, j, this[i, j] ? '#' : '.');
                }
            }

            _stair.Draw(cons);
            cons.putChar(StartPosX, StartPosY, '<');

            foreach (Item item in _items)
            {
                item.Draw(cons);
            }

            foreach (Monster mons in _monsters)
            {
                mons.Draw(cons);
            }

            Player.Draw(cons);

            for (int i = 0; i < MAP_WIDTH; i++)
            {
                for (int j = 0; j < MAP_HEIGHT; j++)
                {
                    /*int intens;
                     * Light light = LightAt(i, j);
                     *
                     * if (light == null)
                     *  intens = 0;
                     * else
                     * {
                     *  intens = light.IntensityAt(i, j);
                     *  color = color.Multiply(light.Color);
                     * }
                     * float value = (float)intens / 20 + (Game.ShowWall ? 0.05f : 0f);
                     * color.setValue(System.Math.Min(value, 1f));//*/

                    TCODColor color  = cons.getCharForeground(i, j);
                    TCODColor newCol = ColorAt(i, j);

                    if (newCol.NotEqual(TCODColor.black))
                    {
                        _known[i, j] = true;
                    }
                    color = color.Multiply(newCol);

                    cons.setCharForeground(i, j, color);
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Custom string drawing method that vignets out the text using the renderer
        /// </summary>
        public static void DrawText(TCODConsole console, int x, int y, string text, TCODColor color)
        {
            TCODColor fadedCol;
            Vector2   pos;

            for (int i = 0; i < text.Length; i++)
            {
                pos      = new Vector2(x + i, y);
                fadedCol = GetFadedColor(pos, color);
                console.setCharForeground(pos.X, pos.Y, fadedCol);
                console.setChar(pos.X, pos.Y, text[i]);
            }
        }
Esempio n. 5
0
        public void DrawRectBorderAt(int x, int y, int left, int top, int right, int bottom, EBorderStyle style, TCODColor borderCol)
        {
            // border cases
            if (x == left && (style == EBorderStyle.WEST || style == EBorderStyle.ALL))
            {
                console.setCharForeground(x, y, borderCol);
                console.setChar(x, y, CharConstants.VERT_LINE);
            }

            if (x == right - 1 && (style == EBorderStyle.EAST || style == EBorderStyle.ALL))
            {
                console.setCharForeground(x, y, borderCol);
                console.setChar(x, y, CharConstants.VERT_LINE);
            }

            if (y == top && (style == EBorderStyle.NORTH || style == EBorderStyle.ALL))
            {
                console.setCharForeground(x, y, borderCol);
                console.setChar(x, y, CharConstants.HORZ_LINE);
            }

            if (y == bottom - 1 && (style == EBorderStyle.SOUTH || style == EBorderStyle.ALL))
            {
                console.setCharForeground(x, y, borderCol);
                console.setChar(x, y, CharConstants.HORZ_LINE);
            }

            // Corner cases: char color has been set by the prev two cases: only if its all sides
            if (style == EBorderStyle.ALL)
            {
                if (x == left && y == top)
                {
                    console.setChar(x, y, CharConstants.NW_LINE);
                }
                if (x == right - 1 && y == top)
                {
                    console.setChar(x, y, CharConstants.NE_LINE);
                }
                if (x == left && y == bottom - 1)
                {
                    console.setChar(x, y, CharConstants.SW_LINE);
                }
                if (x == right - 1 && y == bottom - 1)
                {
                    console.setChar(x, y, CharConstants.SE_LINE);
                }
            }
        }
Esempio n. 6
0
 public void Draw(TCODConsole cons)
 {
     cons.putChar(PosX, PosY, _tile);
     cons.setCharForeground(PosX, PosY, Color);
 }
Esempio n. 7
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;
            }
        }
Esempio n. 8
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);
                }
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Renders all game objects that have a draw component attached onto the target console, at their world positions
        /// Also obeys current visibility rules
        /// </summary>
        private void RenderEntities(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;
            }

            Vector2   pos;
            TCODColor col;

            for (int i = drawList.Count - 1; i >= 0; i--)
            {
                pos = drawList[i].owner.position;

                bool los       = currentMap.GetTile(pos.X, pos.Y).cachedLOS;
                bool explored  = currentMap.GetTile(pos.X, pos.Y).explored;
                bool isVisible = true;

                // Do not draw object if it is not in los and is not static, or if it is static, then only if it hasn't been explored yet
                if (!explored)
                {
                    continue;
                }
                else if (!los)
                {
                    // check if the entity wants to be rendered anyways
                    if (!drawList[i].owner.Has(typeof(StaticComponent)))
                    {
                        continue;
                    }

                    isVisible = false;
                }

                col = drawList[i].color;
                TCODColor fadedColor = new TCODColor(col.Red, col.Green, col.Blue);

                // Fade the color based on how far from the center it is
                if (doCircularFade)
                {
                    fadedColor = GetFadedColor(pos, screenCenter, col);
                }

                if (!isVisible)
                {
                    fadedColor = FadeColor(fadedColor, 0.5f);
                }

                int screenX = camera.screenX + pos.X - left;
                int screenY = camera.screenY + pos.Y - top;

                // Draw the char to the forground layer
                targetConsole.setCharForeground(screenX, screenY, fadedColor);
                targetConsole.setChar(screenX, screenY, drawList[i].ch);
            }
        }
Esempio n. 10
0
 private void DrawPoint(TCODConsole screen, Point p, char c)
 {
     Point screenPosition = new Point(m_mapUpCorner.X + p.X + 1, m_mapUpCorner.Y + p.Y + 1);
     screen.putChar(screenPosition.X, screenPosition.Y, c, TCODBackgroundFlag.None);
     screen.setCharForeground(screenPosition.X, screenPosition.Y, m_color);
 }
Esempio n. 11
0
        public void Draw(TCODConsole cons)
        {
            cons.setForegroundColor(TCODColor.white);
            for (int i = 0; i < MAP_WIDTH; i++)
                for (int j = 0; j < MAP_HEIGHT; j++)
                {
                    cons.putChar(i, j, this[i, j] ? '#' : '.');
                }

            _stair.Draw(cons);
            cons.putChar(StartPosX, StartPosY, '<');

            foreach (Item item in _items)
            {
                item.Draw(cons);
            }

            foreach (Monster mons in _monsters)
            {
                mons.Draw(cons);
            }

            Player.Draw(cons);

            for (int i = 0; i < MAP_WIDTH; i++)
                for (int j = 0; j < MAP_HEIGHT; j++)
                {
                    /*int intens;
                    Light light = LightAt(i, j);

                    if (light == null)
                        intens = 0;
                    else
                    {
                        intens = light.IntensityAt(i, j);
                        color = color.Multiply(light.Color);
                    }
                    float value = (float)intens / 20 + (Game.ShowWall ? 0.05f : 0f);
                    color.setValue(System.Math.Min(value, 1f));//*/

                    TCODColor color = cons.getCharForeground(i, j);
                    TCODColor newCol = ColorAt(i, j);

                    if (newCol.NotEqual(TCODColor.black))
                        _known[i, j] = true;
                    color = color.Multiply(newCol);

                    cons.setCharForeground(i, j, color);
                }
        }
Esempio n. 12
0
 public void Draw(TCODConsole cons)
 {
     cons.putChar(PosX, PosY, _tile);
     cons.setCharForeground(PosX, PosY, _color);
 }