Exemple #1
0
        public Monster(AIType ai, int x, int y, String name, int level, TCODColor color, char c, bool miniboss, bool finalboss, int toHit, int damage, int health, int AC, int dodge, int speed)
        {
            this.x     = x;
            this.y     = y;
            this.origX = x;
            this.origY = y;

            this.name  = name;
            this.level = level;
            this.ai    = ai;

            this.color = color;
            this.c     = c;

            this.toHit  = toHit;
            this.damage = damage;
            this.health = health;
            this.AC     = AC;
            this.dodge  = dodge;

            this.miniboss  = miniboss;
            this.finalboss = finalboss;

            this.speed   = speed;
            this.walk    = true;
            this.counter = 4;
        }
Exemple #2
0
        public void message(TCODColor color, string maintxt, params string[] messages)
        {
            Message aMsg = new Message();
            aMsg.color = color;

            if (maintxt.Length > 75)
            {
                message(color, maintxt.Substring(75, maintxt.Length - 75).Insert(0, "-"));
                maintxt = maintxt.Substring(0, 75);
            }
            if (messages.Length > 1)
            {
                aMsg.text = String.Format(maintxt, messages);
            }
            else if (messages.Length == 1)
            {
                aMsg.text = String.Format(maintxt, messages[0]);
            }
            else
            {
                aMsg.text = maintxt;
            }
            if (log.Count() >= Globals.MSGHEIGHT)
            {
                int last = log.Count();
                Message remove = log[last-1];
                log.Remove(remove);
            }
            log.Insert(0, aMsg);
        }
Exemple #3
0
 public static void drawHorizontalBackground(int y, int start, int end, TCODColor color)
 {
     for (int x = start; x < end; x++)
     {
         TCODConsole.root.setCharBackground(x, y, color);
     }
 }
Exemple #4
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());
            }
        }
Exemple #5
0
        public void Render(TCODColor backgroundColor)
        {
            var color = TCODColor.Interpolate(TCODColor.white, backgroundColor, Brightness);

            TCODConsole.root.setForegroundColor(color);
            TCODConsole.root.putChar(X, Y, '*');
        }
Exemple #6
0
        public Monster(AIType ai, int x, int y, String name, int level, TCODColor color, char c, bool miniboss, bool finalboss, int toHit, int damage, int health, int AC, int dodge, int speed)
        {
            this.x = x;
            this.y = y;
            this.origX = x;
            this.origY = y;

            this.name = name;
            this.level = level;
            this.ai = ai;

            this.color = color;
            this.c = c;

            this.toHit = toHit;
            this.damage = damage;
            this.health = health;
            this.AC = AC;
            this.dodge = dodge;

            this.miniboss = miniboss;
            this.finalboss = finalboss;

            this.speed = speed;
            this.walk = true;
            this.counter = 4;
        }
Exemple #7
0
 public static void drawVerticalBackground(int x, int start, int end, TCODColor color)
 {
     for (int y = start; y < end; y++)
     {
         TCODConsole.root.setCharBackground(x, y, color);
     }
 }
Exemple #8
0
        /// <summary>
        /// Wrapper around TCODColor.Interpolate
        /// </summary>
        /// <param name="sourceColor"></param>
        /// <param name="destinationColor"></param>
        /// <param name="coefficient"></param>
        /// <returns></returns>
        public static Color Lerp(Color sourceColor, Color destinationColor, float coefficient)
        {
            TCODColor color = TCODColor.Interpolate(sourceColor.TCODColor,
                                                    destinationColor.TCODColor, coefficient);

            return(new Color(color));
        }
        private static TCODColor GetRarityColour(RCell cell, TCODColor defaultColour)
        {
            if (cell.Is(RCell.Uncommon))
            {
                return(TCODColor.lightGreen);
            }

            if (cell.Is(RCell.Rare))
            {
                return(TCODColor.lighterBlue);
            }

            if (cell.Is(RCell.Epic))
            {
                return(TCODColor.lightMagenta);
            }

            if (cell.Is(RCell.Legendary))
            {
                return(TCODColor.lightYellow);
            }

            if (cell.Is(RCell.Artifact))
            {
                return(TCODColor.lightRed);
            }

            return(defaultColour);
        }
Exemple #10
0
 public static void WriteLineC(TCODColor color, string s, params object[] args)
 {
     if (s != null && color != null)
     {
         WriteLineC(color, (string.Format(s, args)));
     }
 }
Exemple #11
0
 public virtual void render(bool inSight)
 {
     if (inSight)
     {
         if (x - Program.engine.map.offsetX > Program.engine.map.renderX && y - Program.engine.map.offsetY > Program.engine.map.renderY)
         {
             if (x - Program.engine.map.offsetX < Program.engine.map.renderWidth && y - Program.engine.map.offsetY < Program.engine.map.renderHeight)
             {
                 TCODConsole.root.setChar(x - Program.engine.map.offsetX, y - Program.engine.map.offsetY, ch);
                 if (color != null)
                 {
                     TCODConsole.root.setCharForeground(x - Program.engine.map.offsetX, y - Program.engine.map.offsetY, color);
                 }
                 else
                 {
                     Console.WriteLine("Color of " + this.name + " was null, setting color to white");
                     color = TCODColor.white;
                 }
                 foreach (Component c in components)
                 {
                     c.render(true);
                 }
             }
         }
     }
     else
     {
         foreach (Component c in components)
         {
             c.render(false);
         }
     }
 }
Exemple #12
0
 public void Init(TCODColor color, int var)
 {
     this.color = color;
     this.particles = new List<Particle>();
     this.color_variation = var;
     initialized = true;
 }
Exemple #13
0
 public Thing(int x, int y, int symbol, TCODColor color)
 {
     this.x = x;
     this.y = y;
     this.symbol = symbol;
     this.color = color;
 }
Exemple #14
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();
                }
            }
        }
Exemple #15
0
 public MainMenuScene(Game game) : base(game)
 {
     background           = RexPaintImageLoader.LoadImage("Assets/MainMenu/Background.xp");
     backgroundColor      = new TCODColor(0, 32, 64);
     creditsDoneRendering = false;
     GenerateStarfield();
     GenerateClouds();
 }
Exemple #16
0
        /// <summary>
        /// Constructs a Color from the provided reg, green and blue values (0-255 for each)
        /// </summary>
        /// <param name="red"></param>
        /// <param name="green"></param>
        /// <param name="blue"></param>
        public Color(byte red, byte green, byte blue)
        {
            this._red   = red;
            this._green = green;
            this._blue  = blue;

            _color = new TCODColor(red, green, blue);
        }
Exemple #17
0
        /// <summary>
        /// Fade from color a to bolor b by the normalized ratio dx
        /// </summary>
        public static TCODColor CrossFadeColor(TCODColor colora, TCODColor colorb, float dx)
        {
            float redVal   = colora.Red * dx + colorb.Red * (1.0f - dx);
            float greenVal = colora.Green * dx + colorb.Green * (1.0f - dx);
            float blueVal  = colora.Blue * dx + colorb.Blue * (1.0f - dx);

            return(new TCODColor((byte)redVal, (byte)greenVal, (byte)blueVal));
        }
Exemple #18
0
 public Terrain(string name, EMobilityLevel mobility, TCODColor bg, TCODColor fg, char ch)
 {
     this.name     = name;
     this.mobility = mobility;
     this.bg       = bg;
     this.fg       = fg;
     this.ch       = ch;
 }
Exemple #19
0
 public Monster(char c, TCODColor color, Map map, int health)
     : base(c, color)
 {
     Health = health;
     map.AddCreature(this);
     _ai = new MonsterAI(this);
     _ai.SetMap(map);
 }
Exemple #20
0
 public Monster(char c, TCODColor color, Map map, int health)
     : base(c, color)
 {
     Health = health;
     map.AddCreature(this);
     _ai = new MonsterAI(this);
     _ai.SetMap(map);
 }
Exemple #21
0
 public static void drawHorizontalLine(int y, int start, int end, char c, TCODColor color)
 {
     for (int x = start; x < end; x++)
     {
         TCODConsole.root.setChar(x, y, c);
         TCODConsole.root.setCharForeground(x, y, color);
     }
 }
Exemple #22
0
        // /////////////////////////////////////////////////////////////////////////////////

        // /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Constructs a Color from the provided reg, green and blue values (0-255 for each)
        /// </summary>
        /// <param name="red"></param>
        /// <param name="green"></param>
        /// <param name="blue"></param>
        public Color(byte red, byte green, byte blue)
        {
            this.red   = red;
            this.green = green;
            this.blue  = blue;

            color = new TCODColor(red, green, blue);
        }
Exemple #23
0
 public static void drawText(int x, int y, string text, TCODColor color)
 {
     for (int i = 0; i < text.Length; i++)
     {
         TCODConsole.root.setChar(x + i, y, text[i]);
         TCODConsole.root.setCharForeground(x + i, y, color);
     }
 }
Exemple #24
0
 public static void drawVerticalLine(int x, int start, int end, char c, TCODColor color)
 {
     for (int y = start; y < end; y++)
     {
         TCODConsole.root.setChar(x, y, c);
         TCODConsole.root.setCharForeground(x, y, color);
     }
 }
Exemple #25
0
        public static TCODConsole LoadImage(string fileName)
        {
            var         transparentColor = new TCODColor(255, 0, 255);
            TCODConsole image            = null;

            try {
                using (var file = File.Open(fileName, FileMode.Open)) {
                    var decrompressedStream = new GZipStream(file, CompressionMode.Decompress);
                    var reader      = new BinaryReader(decrompressedStream);
                    var fileVersion = reader.ReadInt32();
                    var layerCount  = reader.ReadInt32();

                    // Reserving space for these in advance, so I'm not doing memory
                    // allocations repeatedly in the loop.
                    int       layerWidth = 0;
                    int       layerHeight = 0;
                    int       x, y;
                    int       characterCode = 0;
                    TCODColor foreground    = new TCODColor();
                    TCODColor background    = new TCODColor();

                    for (int layerIndex = 0; layerIndex < layerCount; ++layerIndex)
                    {
                        layerWidth  = reader.ReadInt32();
                        layerHeight = reader.ReadInt32();
                        if (image == null)
                        {
                            image = new TCODConsole(layerWidth, layerHeight);
                            image.setBackgroundColor(transparentColor);
                            image.clear();
                            image.setKeyColor(transparentColor);
                        }

                        for (var charIndex = 0; charIndex < layerWidth * layerHeight; ++charIndex)
                        {
                            x                = charIndex / layerHeight;
                            y                = charIndex % layerHeight;
                            characterCode    = reader.ReadInt32();
                            foreground.Red   = reader.ReadByte();
                            foreground.Green = reader.ReadByte();
                            foreground.Blue  = reader.ReadByte();
                            background.Red   = reader.ReadByte();
                            background.Green = reader.ReadByte();
                            background.Blue  = reader.ReadByte();

                            // Check if the current cell is transparent.
                            if (background.NotEqual(transparentColor))
                            {
                                image.putCharEx(x, y, characterCode, foreground, background);
                            }
                        }
                    }
                }
            } catch (Exception e) {
                Logger.Error($"Error loading file '{fileName}': {e.Message}");
            }
            return(image);
        }
Exemple #26
0
 public Actor(int id, int x, int y, int ch, TCODColor col)
 {
     this.color = col;
     this.id    = id;
     this.name  = string.Empty;
     this.x     = x;
     this.y     = y;
     this.ch    = ch;
 }
Exemple #27
0
 public Actor(int id, int x, int y, int ch, string name, TCODColor col)
 {
     this.color = col;
     this.name  = name;
     this.x     = x;
     this.y     = y;
     this.ch    = ch;
     this.id    = id;
 }
Exemple #28
0
 public virtual void nullify()
 {
     this.color       = null;
     this.description = string.Empty;
     this.name        = string.Empty;
     this.x           = 0;
     this.y           = 0;
     this.ch          = 0;
 }
Exemple #29
0
 public LightSource()
 {
     position  = new Point(0, 0);
     radius    = 0;
     colour    = new TCODColor(0, 0, 0);
     intensity = 0;
     lightMap  = new TCODMap(300, 200);
     lightMap.clear(false, false);
 }
 public MainMenuScene(Game game)
     : base(game)
 {
     background = RexPaintImageLoader.LoadImage("Assets/MainMenu/Background.xp");
     backgroundColor = new TCODColor(0, 32, 64);
     creditsDoneRendering = false;
     GenerateStarfield();
     GenerateClouds();
 }
Exemple #31
0
        public void render()
        {
            if (i > 10000)
            {
                i = 0;
            }
            if (time > 10)
            {
                i++;
                time = 0;
            }
            time++;

            for (int x = renderX; x < renderWidth; x++)
            {
                for (int y = renderY; y < renderHeight; y++)
                {
                    if (x + offsetX >= 0 && x + offsetX < tiles.GetLength(0) && y + offsetY >= 0 && y + offsetY < tiles.GetLength(1))
                    {
                        if (isExplored(x + offsetX, y + offsetY) || showAllTiles)
                        {
                            bool      explored = tiles[x + offsetX, y + offsetY].explored;
                            TCODColor src;

                            if (isWall(x + offsetX, y + offsetY))
                            {
                                src = new TCODColor(darkWall.Red, darkWall.Green, darkWall.Blue);
                                if (explored)
                                {
                                    float v = (float)(((float)((float)darkWall.getValue())));
                                    float s = (float)(((float)((float)darkWall.getSaturation())));
                                    src.setSaturation(s);
                                    src.setValue(v);
                                }
                                TCODConsole.root.setCharBackground(x, y, src);
                            }
                            else
                            {
                                src = new TCODColor(darkGround.Red, darkGround.Green, darkGround.Blue);
                                if (explored)
                                {
                                    float v = (float)(((float)((float)darkGround.getValue())));
                                    float s = (float)(((float)((float)darkGround.getSaturation())));
                                    src.setSaturation(s);
                                    src.setValue(v);
                                }
                                TCODConsole.root.setCharBackground(x, y, src);
                            }
                        }
                    }
                }
            }

            updateFov    = false;
            updateDynFov = false;
        }
Exemple #32
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);
                }
            }
        }
Exemple #33
0
        public List <ColoredChar> stringToLine(string text, TCODColor color)
        {
            List <ColoredChar> line = new List <ColoredChar>();

            for (int i = 0; i < text.Length; i++)
            {
                line.Add(new ColoredChar(text[i], color));
            }
            return(line);
        }
Exemple #34
0
        private static void RenderPlayConsole(Game gameInstance, TCODConsole console, TCODColor fogOfWarColour, Rectangle bounds)
        {
            console.clear();
            console.setForegroundColor(ColorPresets.White);
            console.printFrame(0, 0, bounds.Width, bounds.Height, true);


            for (int y = 0; y < gameInstance.Terrain.Height; y++)
            {
                for (int x = 0; x < gameInstance.Terrain.Width; x++)
                {
                    if (gameInstance.Player.VisibilityMap[x, y].WasSeen)
                    {
                        TCODColor lightColour = new TCODColor(gameInstance.LightMap[x, y].Colour.R,
                                                              gameInstance.LightMap[x, y].Colour.G,
                                                              gameInstance.LightMap[x, y].Colour.B);

                        if (lightColour.getValue() < fogOfWarColour.getValue())
                        {
                            lightColour = fogOfWarColour;
                        }

                        console.setForegroundColor(gameInstance.Player.VisibilityMap[x, y].IsVisible
                                                      ? lightColour
                                                      : fogOfWarColour);
                        console.putChar(x + 1, y + 1, gameInstance.Terrain[x, y].Symbol);
                    }
                }
            }

            console.setForegroundColor(
                new TCODColor(gameInstance.LightMap[gameInstance.Player.Location.Coordinate].Colour.R,
                              gameInstance.LightMap[gameInstance.Player.Location.Coordinate].Colour.G,
                              gameInstance.LightMap[gameInstance.Player.Location.Coordinate].Colour.B));
            console.putChar(gameInstance.Player.Location.Coordinate.X + 1, gameInstance.Player.Location.Coordinate.Y + 1,
                            '@');

            foreach (IActor actor in gameInstance.Actors.Where(x => x != gameInstance.Player))
            {
                if (gameInstance.Player.VisibilityMap[actor.Location.Coordinate].IsVisible)
                {
                    TCODColor lightColour = new TCODColor(gameInstance.LightMap[actor.Location.Coordinate].Colour.R,
                                                          gameInstance.LightMap[actor.Location.Coordinate].Colour.G,
                                                          gameInstance.LightMap[actor.Location.Coordinate].Colour.B);

                    if (lightColour.getValue() < fogOfWarColour.getValue())
                    {
                        lightColour = fogOfWarColour;
                    }

                    console.setForegroundColor(lightColour);
                    console.putChar(actor.Location.Coordinate.X + 1, actor.Location.Coordinate.Y + 1, actor.Race.Symbol);
                }
            }
        }
Exemple #35
0
        public Light(int intensity, int radius, int capacity, TCODColor color)
        {
            _color     = color;
            _intensity = intensity;
            _radius    = radius;
            _capacity  = capacity;
            _coef      = (float)(-intensity) / radius;

            _elapsed      = 0;
            _distanceFunc = Math.Distance_Euclide;
        }
Exemple #36
0
        public Light(int intensity, int radius, int capacity, TCODColor color)
        {
            _color = color;
            _intensity = intensity;
            _radius = radius;
            _capacity = capacity;
            _coef = (float)(-intensity) / radius;

            _elapsed = 0;
            _distanceFunc = Math.Distance_Euclide;
        }
Exemple #37
0
        public bool Event_OnDeath(ComponentEvent e)
        {
            // swap the char and color to the dead version, and cache the normal ones so they can be re-used later
            normalChar  = ch;
            normalColor = color;

            ch    = goreCh;
            color = goreColor;

            return(true);
        }
Exemple #38
0
 public Button(string s, int x, int y, int w, int h, TCODColor fcol, TCODColor bcol, bool center, Action a)
 {
     this.Text = s;
     if (center)
         r = new Rect(x - w / 2, y, w, h);
     else
         r = new Rect(x, y, w, h);
     this.fcol = fcol;
     this.bcol = bcol;
     this.A = a;
 }
Exemple #39
0
        public Transision(int px, int py)
        {
            rand = new Random();

            name = firstNames[rand.Next(0, firstNames.Length)] + " of " + lastNames[rand.Next(0, lastNames.Length)];

            x = px;
            y = py;

            c = '*';
            color = TCODColor.lightViolet;
        }
Exemple #40
0
        public Particle(int abs_x, int abs_y, float veloc_x, float veloc_y, float intensity, TCODColor color)
        {
            this.abs_x = (float)abs_x;
            this.abs_y = (float)abs_y;

            this.veloc_x = veloc_x;
            this.veloc_y = veloc_y;

            this.intensity = intensity;
            this.color = color;

            this.lifetime = 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);
            }
        }
Exemple #42
0
            public void Draw()
            {
                //Color based on mouse hover
                if (hover)
                {
                    TCODColor finv = new TCODColor(-((short)fcol.Red - 255), -((short)fcol.Green - 255), -((short)fcol.Blue - 255));
                    TCODColor binv = new TCODColor(-((short)bcol.Red - 255), -((short)bcol.Green - 255), -((short)bcol.Blue - 255));
                    GameLoop.Console.setForegroundColor(finv);
                    GameLoop.Console.setBackgroundColor(binv);
                }
                else
                {
                    GameLoop.Console.setForegroundColor(fcol);
                    GameLoop.Console.setBackgroundColor(bcol);
                }

                //Draw
                GameLoop.Console.printEx((int)r.X, (int)r.Y, TCODBackgroundFlag.Set, TCODAlignment.LeftAlignment, Text);
            }
Exemple #43
0
        public Player(Item weapon, Item armor, Classes pcClass)
        {
            this.name = "Tim";
            this.pcClass = pcClass;

            this.playerX = 1;
            this.playerY = 1;

            this.playerColor = TCODColor.magenta;
            this.playerChar = '@';

            this.weapon = weapon;
            this.armor = armor;
            this.gold = 0;

            this.maxHP = healthSet();
            this.nowHP = maxHP;

            this.level = 1;
            this.xp = 0;
            this.toHit = toHitSet();
            this.dodge = dodgeSet();
        }
Exemple #44
0
 public Actor(int x, int y, int ch, string name, TCODColor col)
 {
     this.x = x;
     this.y = y;
     this.ch = ch;
     this.col = col;
     this.name = name;
     this.blocks = true;
     this.attacker = null;
     this.destruct = null;
     this.ai = null;
     this.pick = null;
     this.contain = null;
     this.portal = null;
     if (name == "player")
     {
         this.gun = new Gun(10, 10);
     }
     else
     {
         this.gun = null;
     }
 }
Exemple #45
0
 public ShowStream(List<Point> path, TCODColor color, Dictionary<Point, bool> locationsOccupied)
 {
     m_path = path;
     m_color = color;
     m_locationsOccupied = locationsOccupied;
 }
Exemple #46
0
 public MessageColor(TCODColor fore, TCODColor back)
 {
     ForeColor = fore;
     BackColor = back;
 }
Exemple #47
0
 public Message(String text, MessageColor color)
 {
     MessageText = text;
     ForeColor = color.ForeColor;
     BackColor = color.BackColor;
 }
Exemple #48
0
 public ConsoleLine(string str)
 {
     Str = str;
     Color = TCODColor.grey;
 }
Exemple #49
0
 public void Init(TCODColor color, MessageHandler msg, Faction fac, Action firstAction, AI ai, Map m)
 {
     base.Init(color, msg, fac, firstAction);
     _ai = ai;
     _ai.Init(this, m);
 }
Exemple #50
0
        // /////////////////////////////////////////////////////////////////////////////////
        // /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Replaces saturation with given saturation (0.0 --> 1.0)
        /// Returns new instance - original instance is unchanged
        /// </summary>
        /// <param name="saturation"></param>
        /// <returns></returns>
        public Color ReplaceSaturation(float saturation)
        {
            TCODColor ret = new TCODColor();

            float h, s, v;
            color.getHSV(out h, out s, out v);

            ret.setHSV(h, saturation, v);

            return new Color(ret);
        }
Exemple #51
0
        public void UpdateTintMap(int width, int height)
        {
            List<LightSource> sources = new List<LightSource>();    //The sources list

            int z = Player.Z;

            #region "Viewport setup"

            int top; //Y
            int left; //X
            int right;
            int bottom;

            top = Player.Y - (height / 2);
            bottom = top + height;

            left = Player.X - (width / 2);
            right = left + width;

            if (top >= bottom || left >= right)
                return;

            if (top < 0)
            {
                bottom -= top; //Bottom - Top (which is negative): ex.: new Bottom (10-(-5) = 15)
                top = 0;
            }

            if (bottom > wm.GLOBAL_HEIGHT)
            {
                top -= (bottom - wm.GLOBAL_HEIGHT); //ex.: bottom = 15, Globalheight = 10, Top = 5; => Top = 5 - (15-10) = 0
                bottom = wm.GLOBAL_HEIGHT;
            }

            if (left < 0)
            {
                right -= left;
                left = 0;
            }

            if (right > wm.GLOBAL_WIDTH)
            {
                left -= (right - wm.GLOBAL_WIDTH);
                right = wm.GLOBAL_WIDTH;
            }

            #endregion

            int rel_x, rel_y;
            int curr_rel_x, curr_rel_y;

            byte[,] red = new byte[vp_width, vp_height];
            byte[,] green = new byte[vp_width, vp_height];
            byte[,] blue = new byte[vp_width, vp_height];

            TCODColor faded_col;
            TCODColor inter_col;

            //Fetch them viable lightsources!
            foreach (Item i in ItemList.GetValues())
            {
                if (i.GetType() == typeof(LightSource))
                {
                    LightSource s = (LightSource)i;
                    if (s.Z == z)
                        sources.Add(s);
                }
            }
            foreach (Creature c in CreatureList.GetValues())
            {

                if (c.Equip.SlotFilled((int)EquipmentSlot.Light))
                {
                    LightSource ls = (LightSource)c.Equip[(int)EquipmentSlot.Light];
                    if (ls != null)
                    {
                            sources.Add(ls);
                    }
                }
            }

            //Do the actual calculations
            foreach (LightSource ls in sources)
            {
                rel_x = ls.X - left;
                rel_y = ls.Y - top;

                tcod_map.computeFov(ls.X - cells[0, 0, 0].X, ls.Y - cells[0, 0, 0].Y, ls.LightRadius, true, TCODFOVTypes.RestrictiveFov);

                for (int x = -ls.LightRadius; x < ls.LightRadius; x++)
                {
                    for (int y = -ls.LightRadius; y < ls.LightRadius; y++)
                    {
                        curr_rel_x = rel_x + x;
                        curr_rel_y = rel_y + y;
                        if (curr_rel_x > 0 && curr_rel_x < vp_width
                            && curr_rel_y > 0 && curr_rel_y < vp_height
                            && tcod_map.isInFov(ls.X + x - cells[0, 0, 0].X, ls.Y + y - cells[0, 0, 0].Y) &&
                            ls.Lightmap[x + ls.LightRadius, y + ls.LightRadius] > 0)
                        {

                            //inter_col = new TCODColor(red[curr_rel_x, curr_rel_y], green[curr_rel_x, curr_rel_y], blue[curr_rel_x, curr_rel_y]);
                            //inter_col = TCODColor.Interpolate(inter_col, faded_col, (float)ls.Lightmap[x + ls.LightRadius, y + ls.LightRadius] / (float)ls.LightLevel);

                            faded_col = TCODColor.Interpolate(TCODColor.black, ls.ForeColor,
                                1.0f);
                                //Math.Max(((float)ls.Lightmap[x + ls.LightRadius, y + ls.LightRadius] / (float)ls.LightLevel),0.5f));

                            inter_col = new TCODColor(red[curr_rel_x, curr_rel_y], green[curr_rel_x, curr_rel_y], blue[curr_rel_x, curr_rel_y]);
                            inter_col = TCODColor.Interpolate(inter_col, faded_col, (float)ls.Lightmap[x + ls.LightRadius, y + ls.LightRadius] / (float)ls.LightLevel);

                            red[curr_rel_x, curr_rel_y] = red[curr_rel_x, curr_rel_y] > inter_col.Red ? red[curr_rel_x, curr_rel_y] : inter_col.Red;
                            green[curr_rel_x, curr_rel_y] = green[curr_rel_x, curr_rel_y] > inter_col.Green ? green[curr_rel_x, curr_rel_y] : inter_col.Green;
                            blue[curr_rel_x, curr_rel_y] = blue[curr_rel_x, curr_rel_y] > inter_col.Blue ? blue[curr_rel_x, curr_rel_y] : inter_col.Blue;

                            /*
                            red[curr_rel_x, curr_rel_y] = inter_col.Red;
                            green[curr_rel_x, curr_rel_y] = inter_col.Green;
                            blue[curr_rel_x, curr_rel_y] = inter_col.Blue;
                            */

                            /*
                            red[curr_rel_x, curr_rel_y] = red[curr_rel_x, curr_rel_y] > faded_col.Red ? red[curr_rel_x, curr_rel_y] : faded_col.Red;
                            green[curr_rel_x, curr_rel_y] = green[curr_rel_x, curr_rel_y] > faded_col.Green ? green[curr_rel_x, curr_rel_y] : faded_col.Green;
                            blue[curr_rel_x, curr_rel_y] = blue[curr_rel_x, curr_rel_y] > faded_col.Blue ? blue[curr_rel_x, curr_rel_y] : faded_col.Blue;
                            */

                            /*
                            red[curr_rel_x, curr_rel_y] = (byte)((float)(red[curr_rel_x, curr_rel_y] + faded_col.Red) / 2.0f);
                            green[curr_rel_x, curr_rel_y] = (byte)((float)(green[curr_rel_x, curr_rel_y] + faded_col.Green) / 2.0f);
                            blue[curr_rel_x, curr_rel_y] = (byte)((float)(blue[curr_rel_x, curr_rel_y] + faded_col.Blue) / 2.0f);
                            */
                        }

                    }
                }
            }

            for (int x = 0; x < vp_width; x++)
            {
                for (int y = 0; y < vp_height; y++)
                {
                    light_tint[x, y] = Util.EncodeRGB(red[x, y], green[x, y], blue[x, y]);
                }
            }
        }
Exemple #52
0
        // /////////////////////////////////////////////////////////////////////////////////
        // /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Scales value (brightness) by given amount (0.0 --> 1.0)
        /// Returns new instance - original instance is unchanged
        /// </summary>
        /// <param name="scale"></param>
        /// <returns></returns>
        public Color ScaleValue(float scale)
        {
            TCODColor ret = new TCODColor();

            float h, s, v;
            color.getHSV(out h, out s, out v);

            ret.setHSV(h, s, v * scale);

            return new Color(ret);
        }
Exemple #53
0
 public void WriteLine(object item, TCODColor col)
 {
     string item2 = item.ToString();
     AddLine(item2, col);
 }
Exemple #54
0
 private void AddLine(string item, TCODColor col)
 {
     consoleLines.Add(new ConsoleLine(item, col));
     if (consoleLines.Count > 24)
     {
         consoleLines.RemoveAt(0);
     }
 }
Exemple #55
0
        public static TCODColor getTCODColor(ConsoleRGB consoleRGB)
        {
            TCODColor color = null;

            if (consoleRGB.GetColorEnum() != null)
            {
                ColorEnum consoleColor = (ColorEnum)consoleRGB.GetColorEnum();

                switch (consoleColor)
                {
                    case ColorEnum.Black:
                        color = TCODColor.black;
                        break;
                    case ColorEnum.White:
                        color = TCODColor.white;
                        break;
                    case ColorEnum.Gray:
                        color = TCODColor.grey;
                        break;
                    case ColorEnum.Red:
                        color = TCODColor.red;
                        break;
                    case ColorEnum.Blue:
                        color = TCODColor.blue;
                        break;
                    case ColorEnum.Yellow:
                        color = TCODColor.yellow;
                        break;
                    case ColorEnum.DarkGray:
                        color = TCODColor.darkGrey;
                        break;
                    case ColorEnum.DarkRed:
                        color = TCODColor.darkRed;
                        break;
                    case ColorEnum.LightGray:
                        color = TCODColor.lightGrey;
                        break;
                    case ColorEnum.LightRed:
                        color = TCODColor.lightRed;
                        break;
                    default:
                        color = TCODColor.black;
                        break;
                }
            }
            else
            {
                int key = consoleRGB.R * 0x10000 + consoleRGB.G * 0x100 + consoleRGB.B;
                //TCODColor color;

                if (!TCODColors.TryGetValue(key, out color))
                {

                    color = new TCODColor();
                    color.Red = consoleRGB.R;
                    color.Green = consoleRGB.G;
                    color.Blue = consoleRGB.B;

                    TCODColors.Add(key, color);
                }
            }

            return color;
        }
Exemple #56
0
 public void SendMessage(String text, TCODColor fore, TCODColor back)
 {
     log.Add(new Message(text, new MessageColor(fore, back)));
 }
Exemple #57
0
 public Message(String text, TCODColor fore, TCODColor back)
 {
     MessageText = text;
     ForeColor = fore;
     BackColor = back;
 }
Exemple #58
0
 public ConsoleLine(string str, TCODColor col)
 {
     Str = str;
     Color = col;
 }
Exemple #59
0
        // /////////////////////////////////////////////////////////////////////////////////
        // /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Replaces value (brightness) with given value (0.0 --> 1.0)
        /// Returns new instance - original instance is unchanged
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public Color ReplaceValue(float value)
        {
            TCODColor ret = new TCODColor();

            float h, s, v;
            color.getHSV(out h, out s, out v);

            ret.setHSV(h, s, value);

            return new Color(ret);
        }
Exemple #60
0
        // /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Scales saturation by given amount (0.0 --> 1.0)
        /// Returns new instance - original instance is unchanged
        /// </summary>
        public Color ScaleSaturation(float scale)
        {
            TCODColor ret = new TCODColor();

            float h, s, v;
            color.getHSV(out h, out s, out v);

            ret.setHSV(h, s * scale, v);

            return new Color(ret);
        }