Exemplo n.º 1
0
 public void SetColors(TCODConsole screen, bool selected, bool enabled)
 {
     if (enabled)
     {
         if (selected)
         {
             screen.setForegroundColor(ColorPresets.LightGray);
             screen.setBackgroundColor(ColorPresetsFromTCOD.BrightBlue);
         }
         else
         {
             screen.setForegroundColor(ColorPresets.Gray);
             screen.setBackgroundColor(ColorPresets.Black);
         }
     }
     else
     {
         if (selected)
         {
             screen.setForegroundColor(ColorPresets.Red);
             screen.setBackgroundColor(ColorPresetsFromTCOD.BrightYellow);
         }
         else
         {
             screen.setForegroundColor(ColorPresets.Red);
             screen.setBackgroundColor(ColorPresets.Black);
         }
     }
 }
Exemplo n.º 2
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);
                }
            }
        }
Exemplo n.º 3
0
        public void Render(TCODConsole con)
        {
            int maxchars = con.getWidth() - 4;
            int y = 2;

            con.setForegroundColor(TCODColor.darkerAzure);
            con.printFrame(0, 0, con.getWidth(), con.getHeight());
            con.setForegroundColor(TCODColor.white);

            foreach (String line in wrapLine(Text, maxchars))
            {
                con.print(2, y, line);
                y++;
            }
        }
Exemplo n.º 4
0
 public MapPainter()
 {
     m_offscreenConsole = new TCODConsole(OffscreenWidth, OffscreenHeight);
     m_offscreenConsole.setForegroundColor(UIHelper.ForegroundColor);
     m_honorFOV = true;
     LoadMonsterSymbols();
 }
Exemplo n.º 5
0
        public void Draw()
        {
            int lightLenght = (int)((1 - _player.Light.Used) * 80);

            _root.setBackgroundColor(TCODColor.black);
            _root.setForegroundColor(TCODColor.white);
            Map.Draw(_mapConsole);
            _messages.Draw();
            TCODConsole.blit(_mapConsole, 0, 0, 80, 50, _root, 0, 1);
            TCODConsole.blit(_messages.Console, 0, 0, 80, 10, _root, 0, 51);
            _root.hline(0, 0, 80, TCODBackgroundFlag.Set);
            _root.setBackgroundColor(TCODColor.amber);
            _root.setForegroundColor(TCODColor.amber);
            _root.hline(0, 0, lightLenght, TCODBackgroundFlag.Set);
            TCODConsole.flush();
        }
Exemplo n.º 6
0
        private static void RenderCompetitorConsole(Game gameInstance, TCODConsole console, Rectangle bounds)
        {
            console.clear();
            console.setForegroundColor(ColorPresets.White);
            console.printFrame(0, 0, bounds.Width, bounds.Height, true, TCODBackgroundFlag.Set, "Competitors");


            List <IActor> competitors = gameInstance.AllActors.Where(x => x != gameInstance.Player).ToList();

            for (int i = 0; i < competitors.Count; i++)
            {
                console.setForegroundColor(competitors[i].IsAlive ? ColorPresets.White : ColorPresets.Red);
                console.printEx(1, (i * 2) + 1, TCODBackgroundFlag.Set, TCODAlignment.LeftAlignment, string.Format("{0} is {1} with {2} kills", competitors[i], competitors[i].IsAlive ? "Alive" : "Dead",
                                                                                                                   competitors[i].Kills.Count));
            }
        }
Exemplo n.º 7
0
        private static void RenderAllConsoles(Game game, TCODConsole rootConsole, TCODConsole playConsole, TCODColor fogOfWarColour,
                                              TCODConsole playerConsole, TCODConsole competitorConsole,
                                              TCODConsole eventsConsole, Rectangle playBounds, Rectangle playerBounds,
                                              Rectangle competitorBounds, Rectangle eventBounds)
        {
            rootConsole.clear();
            rootConsole.setForegroundColor(ColorPresets.White);
            rootConsole.setBackgroundColor(ColorPresets.Black);

            RenderPlayConsole(game, playConsole, fogOfWarColour, playBounds);
            RenderPlayerConsole(game.Player, playerConsole, playerBounds);
            //RenderThreatConsole(game.Player, game.Actors, threatConsole, threatBounds);
            RenderCompetitorConsole(game, competitorConsole, competitorBounds);
            RenderEventsConsole(game, eventsConsole, eventBounds);

            TCODConsole.blit(playConsole, 0, 0, playBounds.Width, playBounds.Height, rootConsole, playBounds.X, playBounds.Y);
            TCODConsole.blit(playerConsole, 0, 0, playerBounds.Width, playerBounds.Height, rootConsole, playerBounds.X, playerBounds.Y);
            TCODConsole.blit(competitorConsole, 0, 0, competitorBounds.Width, competitorBounds.Height, rootConsole, competitorBounds.X, competitorBounds.Y);
            TCODConsole.blit(eventsConsole, 0, 0, eventBounds.Width, eventBounds.Height, rootConsole, eventBounds.X, eventBounds.Y);

            //playConsole.Blit(0, 0, playBounds.Width, playBounds.Height, rootConsole, playBounds.X, playBounds.Y);
            //playerConsole.Blit(0, 0, playerBounds.Width, playerBounds.Height, rootConsole, playerBounds.X,
            //                   playerBounds.Y);

            //competitorConsole.Blit(0, 0, competitorBounds.Width, competitorBounds.Height, rootConsole,
            //                       competitorBounds.X, competitorBounds.Y);
            //eventsConsole.Blit(0, 0, eventBounds.Width, eventBounds.Height, rootConsole, eventBounds.X, eventBounds.Y);
        }
Exemplo n.º 8
0
 public void ResetColors(TCODConsole screen)
 {
     if (m_stuffSaved)
     {
         screen.setForegroundColor(m_savedForeground);
         screen.setBackgroundColor(m_savedBackground);
         m_stuffSaved = false;
     }
 }
Exemplo n.º 9
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);
                }
            }
        }
Exemplo n.º 10
0
        private static void RenderEventsConsole(Game gameInstance, TCODConsole console, Rectangle bounds)
        {
            console.clear();
            console.setForegroundColor(ColorPresets.White);
            console.printFrame(0, 0, bounds.Width, bounds.Height, true, TCODBackgroundFlag.Set, "Events");

            int j = gameInstance.GameEvents.Count - 1;
            int i = 1;

            if (!gameInstance.IsActive)
            {
                console.setForegroundColor(gameInstance.AllMonstersAreDead() ? ColorPresets.Gold : ColorPresets.Red);
                console.printEx(
                    1,
                    i, TCODBackgroundFlag.Set, TCODAlignment.LeftAlignment, gameInstance.AllMonstersAreDead() ? "You are the last man standing!" : "You have been eliminated");
                i++;
            }

            for (; i < bounds.Height; i++)
            {
                console.setForegroundColor(ColorPresets.White);

                if ((j < 0) || (j >= gameInstance.GameEvents.Count))
                {
                    break;
                }

                while ((j >= 0) &&
                       !(gameInstance.GameEvents[j].Command is AttackCommand ||
                         gameInstance.GameEvents[j].Command is OpenDoorCommand))
                {
                    j--;
                }

                if ((j < 0) || (j >= gameInstance.GameEvents.Count))
                {
                    break;
                }
                console.printEx(1, i, TCODBackgroundFlag.Set, TCODAlignment.LeftAlignment, gameInstance.GameEvents[j].Result.Message);
                j--;
            }
        }
Exemplo n.º 11
0
        private static void RenderPlayerConsole(IActor player, TCODConsole console, Rectangle bounds)
        {
            console.clear();
            console.setForegroundColor(ColorPresets.White);
            console.printFrame(0, 0, bounds.Width, bounds.Height, true, TCODBackgroundFlag.Set, "Player");


            console.printEx(1, 2, TCODBackgroundFlag.Set, TCODAlignment.LeftAlignment, string.Format("Health : {0}", player.Health));
            console.printEx(1, 4, TCODBackgroundFlag.Set, TCODAlignment.LeftAlignment, string.Format("Damage : {0}", player.Damage));
            console.printEx(1, 6, TCODBackgroundFlag.Set, TCODAlignment.LeftAlignment, string.Format("Kills : {0}", player.Kills.Count));
        }
Exemplo n.º 12
0
        private static void RenderThreatConsole(IActor player, IList <IActor> monsters, TCODConsole console, Rectangle bounds)
        {
            console.clear();
            console.setForegroundColor(ColorPresets.White);
            console.printFrame(0, 0, bounds.Width, bounds.Height, true, TCODBackgroundFlag.Set, "Threats");

            List <IActor> threats = player.Intellect.IdentifyThreats(monsters).ToList();

            for (int i = 1; i < threats.Count; i++)
            {
                console.printEx(1, (i * 2) + 1, TCODBackgroundFlag.Set, TCODAlignment.LeftAlignment, string.Format("{0} : {1}", threats[i].Race.Symbol, threats[i]));
            }
        }
Exemplo n.º 13
0
        // Display the main menu text
        public void PrintMainMenu()
        {
            DisplayText(Menu[0], 22, 25, TCODColor.white, TCODColor.black, 0);
            DisplayText(Menu[1], 22, 26, TCODColor.white, TCODColor.black, 1);
            DisplayText(Menu[2], 22, 27, TCODColor.white, TCODColor.black, 2);

            rootConsole.setForegroundColor(TCODColor.celadon);
            //rootConsole.printFrame(22, 24, 38, 5, false);

            topOfMenu = topOfMenu + 6;
            DisplayText("[UP]/[DOWN] to choose an option, [SCQ, ENTER] to select", -1, 30, TCODColor.grey, TCODColor.black, -1);
        }
Exemplo n.º 14
0
        public void Render(TCODConsole con, bool linewrap = true)
        {
            int maxlines = con.getHeight()-2;   //Corrected for border
            int maxchars = con.getWidth()-2;
            List<String> lines = new List<string>();
            List<MessageColor> colors = new List<MessageColor>();
            string temp;

            if (log.Count == 0)
                return;

            int i = log.Count-maxlines-1;
            if (log.Count <= maxlines)
                i = 0;
            while (i < log.Count)
            {
                if (log[i].MessageText.Length > maxchars && linewrap)
                {
                    //Oh god the horror that is this function
                    //
                    //Further down, lines are printed from latest to newest (added to "lines")
                    //so in order to display multiline messages correctly, the last of the multiple
                    //lines must be added to lines first and the first last. This is done via
                    //a temporary array which is filled from highest to lowest and then added to lines.
                    int templines =(int)Math.Ceiling((double)log[i].MessageText.Length / (double)maxchars);
                    string[] temparr = new string[templines];
                    int k = templines-1;

                    temp = log[i].MessageText;
                    while (temp.Length > maxchars)
                    {
                        temparr[k] = temp.Substring(0, maxchars);
                        colors.Add(log[i].GetMessageColor());
                        temp = temp.Remove(0, maxchars);
                        k--;
                    }
                    temparr[k] = temp;

                    foreach (String s in temparr)
                    {
                        lines.Add(s);
                    }

                    colors.Add(log[i].GetMessageColor());
                }
                else
                {
                    lines.Add(log[i].MessageText);
                    colors.Add(log[i].GetMessageColor());
                }
                i++;
            }

            int endcount = lines.Count - maxlines;
            if (lines.Count < maxlines)
                endcount = 0;
            int y = 0;
            for (int j = lines.Count-1; j >= endcount; j--)
            {
                con.setForegroundColor(colors[j].ForeColor);
                con.setBackgroundFlag(TCODBackgroundFlag.None);
                if (colors[j].BackColor != null)
                {
                    con.setBackgroundColor(colors[j].BackColor);
                    con.setBackgroundFlag(TCODBackgroundFlag.Screen);
                }

                con.print(1, 1 + y, lines[j]);
                y++;
            }
        }
Exemplo n.º 15
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);
                }
        }
Exemplo n.º 16
0
 public void SetForegroundColour(TCODColor colour)
 {
     _console.setForegroundColor(colour);
 }
Exemplo n.º 17
0
Arquivo: Game.cs Projeto: bilwis/SH2RL
        public void RenderInventory(TCODConsole con, int con_x, int con_y, int width, int height)
        {
            con.setForegroundColor(TCODColor.darkAzure);
            con.setBackgroundColor(TCODColor.darkestBlue);
            con.setBackgroundFlag(TCODBackgroundFlag.Set);

            con.printFrame(con_x + 1, con_y + 1, width - 2, height - 2);

            con.setBackgroundFlag(TCODBackgroundFlag.Default);

            con.vline(width / 2, con_y + 2 + 5, height - 4 - 5);
            con.hline(con_x + 2, con_y + 1 + 5, width - 4);

            con.print(con_x + 2, con_y + 2, "GRZ64 INTEGRATED BACKPACK INTERFACE V1.14 REV 1984");
            con.print(con_x + 2, con_y + 3, "UNREGISTERED TRIAL VERSION");

            con.print(con_x + 2, con_y + 5, "LOADING INVENTORY DATA...");

            if (player.Inventory.Count > 0)
            {
                int cap = (height - 5) - (con_y + 7);
                int count = player.Inventory.Count;

                if (menu_selection >= count)
                    menu_selection = (menu_selection - count);

                if (menu_selection < 0)
                    menu_selection = count - 1;

                int top = menu_selection > cap ? (menu_selection - cap) : 0;
                int bottom = top + count > cap ? cap : top + count;

                int it = 0;

                List<Item> item_list = player.Inventory.GetItemList();
                Item sel_item = item_list[menu_selection];

                //Item list
                for (int i = top; i < bottom; i++)
                {
                    con.setBackgroundFlag(TCODBackgroundFlag.Default);

                    if (i == menu_selection)
                    {
                        //con.setBackgroundFlag(TCODBackgroundFlag.Set);
                        //con.setBackgroundColor(TCODColor.azure);
                        con.setForegroundColor(TCODColor.azure);
                    }
                    if (i == menu_selection + 1)
                    {
                        con.setForegroundColor(TCODColor.darkAzure);
                    }

                    if (item_list[i].GetType().IsSubclassOf(typeof(EquippableItem)))
                    {
                        EquippableItem ei = (EquippableItem)item_list[i];
                        if (ei.IsEquipped())
                        {
                            con.setBackgroundFlag(TCODBackgroundFlag.Set);
                            con.setBackgroundColor(TCODColor.lightAzure);
                        }
                    }

                    con.print(con_x + 3, con_y + 7 + it, item_list[i].Name);
                    it++;
                }

                con.setBackgroundFlag(TCODBackgroundFlag.Default);

                con.setForegroundColor(TCODColor.darkAzure);
                int left_offset = width / 2 + 1;
                int top_offset = con_y + 7;

                //Item stats
                con.print(left_offset, top_offset + 0, "NAME         : " + sel_item.Name);
                con.print(left_offset, top_offset + 1, "WEIGHT       : " + sel_item.Weight);

                // type specifics
                if (sel_item.GetType() == typeof(Firearm))
                {
                    Firearm f = (Firearm)sel_item;
                    con.print(left_offset, top_offset + 3, "TYPE         : Firearm");
                    con.print(left_offset, top_offset + 5, "CLASS        : " + f.type.ToString());

                    String fm_str = "";

                    foreach (FireMode fm in f.modes)
                    {
                        fm_str += fm.ToString() + " ";
                    }
                    con.print(left_offset, top_offset + 6, "FIREMODES    : " + fm_str);

                    con.print(left_offset, top_offset + 8, "CALIBER      : " + f.caliber.ToString());
                    con.print(left_offset, top_offset + 9, "MAG. CAPACITY: " + f.MagazineCapacity);

                }

                //Item description
                List<String> lines = wrap(sel_item.Description, width / 2 - 2);
                top_offset = con_y + (int)(height * 0.45d);

                for (int j = 0; j < lines.Count; j++)
                {
                    con.print(left_offset, top_offset + j, lines[j]);
                }

                con.hline(left_offset, top_offset - 1, width / 2 - 2);

                //Item actions
                con.hline(width / 2 + 1, height - 4 - 5, width / 2 - 2);
                //con.print(width / 2 + 2, height - 4 - 4, "R/M/T - Equip Rngd/Mlee/Thrwn");
                //con.print(width / 2 + 2, height - 4 - 3, "  E/L - Equip Armor/Lightsrc");
                con.print(width / 2 + 2, height - 4 - 4, "    E - Equip");
                con.print(width / 2 + 2, height - 4 - 3, "    U - Unequip");
                con.print(width / 2 + 2, height - 4 - 2, "    D - Drop Item");
                con.print(width / 2 + 2, height - 4 - 1, "    Q - Quit");
                con.print(width / 2 + 2, height - 4 + 0, "  +,- - Select");
                con.print(width / 2 + 2, height - 4 + 1, "    C - Consume");
                con.print(width / 2 + 2, height - 4 + 2, "    U - Use");
            }
        }
Exemplo n.º 18
0
Arquivo: Game.cs Projeto: bilwis/SH2RL
        public void RenderDebugInfo(TCODConsole con)
        {
            con.setForegroundColor(TCODColor.white);
            con.print(2, 0, "Turn: " + turn + " | Gameturn: " + gameTurn);
            con.print(2, 1, "Z_LEVEL: " + player.Z);
            string mem_use = "Memory Usage: " + System.Environment.WorkingSet / 1048576 + " MB";
            con.print(WINDOW_WIDTH - (mem_use.Length + 1), 1, mem_use);

            if (map.initialized)
                con.setForegroundColor(TCODColor.green);
            else
                con.setForegroundColor(TCODColor.red);

            con.print(WINDOW_WIDTH - 1, 0, "+");
        }
Exemplo n.º 19
0
 public int WriteString(TCODConsole console, int x, int y, string msg, TCODColor col)
 {
     console.setForegroundColor(col);
     return console.printRect(x, y, console.getWidth()-2, 0, msg);
 }
Exemplo n.º 20
0
        public void PickupItem()
        {
            List<int> items = GetEntitiesSharingTileWithThis();
            if(items.Count == 0)
            {
                DarkRL.WriteMessage("There's nothing to pick up..");
                return;
            }
            else if (items.Count == 1)
                base.PickupItem((Item)level.GetEntity(items[0]));
            else //there's multiple items here
            {
                TCODConsole pickup = new TCODConsole(30, items.Count+1);
                pickup.setBackgroundColor(TCODColor.black);
                pickup.setForegroundColor(TCODColor.white);
                char sym = 'a';
                int y = 0;
                //now display them all
                foreach (Item i in items.Select(t => level.GetEntity(t)))
                {

                    pickup.print(0, y, sym.ToString() + ")" + i.ToString());
                    ++y;
                    ++sym;
                }
                DarkRL.WriteMessage("What do you want to pick up?");
                DarkRL.AddOverlayConsole(pickup, 0, 0, pickup.getWidth(), pickup.getHeight(), TCODConsole.root, Window.StatusPanelWidth,
                    Window.MessagePanelHeight);
                Key input = InputSystem.WaitForAndReturnInput();
                char index = (char)(input.Character - 'a');
                if (index >= items.Count|| index < 0)
                {
                    DarkRL.WriteMessage("Couldn't find anything..");
                    return;
                }
                //so pick it up
                base.PickupItem((Item)level.GetEntity(items[index]));
                DarkRL.WriteMessage("You pick up the " + level.GetEntity(items[index]).Name);
                return;
            }
            DarkRL.WriteMessage("You pick up the " + level.GetEntity(items[0]).Name);
        }
Exemplo n.º 21
0
        private void DrawSkillPopup(TCODConsole console, List<ISkill> selectedSkillList, int skillPointsLeft, SkillSquare cursorSkillSquare, ISkill cursorOverSkill, Point cursorPosition)
        {
            Point drawUpperLeft = ConvertGridToDrawCoord(cursorSkillSquare.UpperRight + new Point(1, 1), cursorPosition);
            
            int numberOfDependencies = cursorSkillSquare.DependentSkills.Count();
            int dialogHeight = ExplainPopupHeight;
            if (numberOfDependencies > 0)
            {
                int linesOfDependencies = numberOfDependencies;
                foreach (string dependentSkillName in cursorSkillSquare.DependentSkills)
                    linesOfDependencies += console.getHeightRect(drawUpperLeft.X + 2 + 3, 0, 20, 2, dependentSkillName);
                
                dialogHeight += 2 + linesOfDependencies;
                drawUpperLeft += new Point(0, 2 + linesOfDependencies);
            }

            string title = cursorOverSkill.Name;
            if (title.Length > 22)
                title = title.Substring(0, 22);

            console.printFrame(drawUpperLeft.X, drawUpperLeft.Y - dialogHeight, ExplainPopupWidth, dialogHeight, true, TCODBackgroundFlag.Set, title);

            int textX = drawUpperLeft.X + 2;
            int textY = drawUpperLeft.Y - dialogHeight + 2;

            // If we can't afford it and it isn't already selected, show the cost in red
            if (!selectedSkillList.Contains(cursorOverSkill) && cursorOverSkill.Cost > skillPointsLeft)
            {
                m_dialogHelper.SaveColors(console);
                console.setForegroundColor(TCODColor.red);
                console.print(textX, textY, string.Format("Skill Point Cost: {0}", cursorOverSkill.Cost));
                m_dialogHelper.ResetColors(console);
            }
            else
            {
                console.print(textX, textY, string.Format("Skill Point Cost: {0}", cursorOverSkill.Cost));
            }
            textY++;

            if (numberOfDependencies > 0)
            {
                textY++;
                console.print(textX, textY, "Dependencies:");
                textY++;
                m_dialogHelper.SaveColors(console);
                foreach (string dependentSkillName in cursorSkillSquare.DependentSkills)
                {
                    if (SkillTreeModelHelpers.IsSkillSelected(selectedSkillList, dependentSkillName))
                        m_dialogHelper.SetColors(console, false, true);
                    else
                        m_dialogHelper.SetColors(console, false, false);

                    console.printRect(textX + 3, textY, 20, 2, dependentSkillName);
                    textY++;
                }
                m_dialogHelper.ResetColors(console);
            }
            textY++;

            console.printRectEx(textX, textY, ExplainPopupWidth - 4, ExplainPopupHeight - 6, TCODBackgroundFlag.Set, TCODAlignment.LeftAlignment, cursorOverSkill.Description);
        }
Exemplo n.º 22
0
        public new void Render(TCODConsole con)
        {
            int maxchars = con.getWidth() - 4;
            int y = 2;
            int cap_lines = 0;

            con.setBackgroundColor(TCODColor.black);
            con.setBackgroundFlag(TCODBackgroundFlag.Set);
            con.clear();
            con.setBackgroundFlag(TCODBackgroundFlag.Default);

            con.setForegroundColor(TCODColor.darkerAzure);
            con.printFrame(0, 0, con.getWidth(), con.getHeight());
            con.setForegroundColor(TCODColor.white);

            List<string> lines = new List<string>();

            lines.AddRange(wrapLine(Text, maxchars));
            cap_lines = lines.Count;

            foreach (KeyValuePair<char, string> kv in responses)
            {
                lines.Add(kv.Key + ") " + kv.Value);
            }

            for (int i = 0; i < lines.Count; i++)
            {
                con.setBackgroundFlag(TCODBackgroundFlag.Set);
                if (i - cap_lines == selectedIndex)
                    con.setBackgroundColor(TCODColor.sepia);
                else
                    con.setBackgroundColor(TCODColor.black);

                con.print(2, y+i, lines[i]);
                con.setBackgroundFlag(TCODBackgroundFlag.Default);
            }
        }
Exemplo n.º 23
0
        public int Run(string[] args)
        {
            fillSampleList();

            int curSample = 0; // index of the current sample
            bool first = true; // first time we render a sample
            TCODKey key = new TCODKey();
            string font = "celtic_garamond_10x10_gs_tc.png";
            int numberCharsHorz = 32;
            int numberCharsVert = 8;
            int fullscreenWidth = 0;
            int fullscreenHeight = 0;
            bool fullscreen = false;
            bool credits = false;
            TCODFontFlags flags = TCODFontFlags.Grayscale | TCODFontFlags.LayoutTCOD;
            TCODFontFlags newFlags = 0;

            for (int i = 1; i < args.Length; i++)
            {
                if (args[i] == "-font" && ArgsRemaining(args, i, 1))
                {
                    i++;
                    font = args[i];
                }
                else if (args[i] == "-font-char-numberRows" && ArgsRemaining(args, i, 2))
                {
                    i++;
                    numberCharsHorz = System.Convert.ToInt32(args[i]);
                    i++;
                    numberCharsVert = System.Convert.ToInt32(args[i]);
                }
                else if (args[i] == "-fullscreen-resolution" && ArgsRemaining(args, i, 2))
                {
                    i++;
                    fullscreenWidth = System.Convert.ToInt32(args[i]);
                    i++;
                    fullscreenHeight = System.Convert.ToInt32(args[i]);
                }
                else if (args[i] == "-fullscreen")
                {
                    fullscreen = true;
                }
                else if (args[i] == "-font-in-row")
                {
                    flags = 0;
                    newFlags |= TCODFontFlags.LayoutAsciiInRow;
                }
                else if (args[i] == "-font-greyscale")
                {
                    flags = 0;
                    newFlags |= TCODFontFlags.Grayscale;
                }
                else if (args[i] == "-font-tcod")
                {
                    flags = 0;
                    newFlags |= TCODFontFlags.LayoutTCOD;
                }
                else if (args[i] == "-help")
                {
                    System.Console.Out.WriteLine("options : \n");
                    System.Console.Out.WriteLine("-font <filename> : use a custom font\n");
                    System.Console.Out.WriteLine("-font-char-size <char_width> <char_height> : size of the custom font's characters\n");
                    System.Console.Out.WriteLine("-font-in-row : the font layout is in row instead of columns\n");
                    System.Console.Out.WriteLine("-font-tcod : the font uses TCOD layout instead of ASCII\n");
                    System.Console.Out.WriteLine("-font-greyscale : antialiased font using greyscale bitmap\n");
                    System.Console.Out.WriteLine("-fullscreen : start in fullscreen\n");
                    System.Console.Out.WriteLine("-fullscreen-resolution <screen_width> <screen_height> : force fullscreen resolution\n");
                    return 0;
                }
            }
            if (flags == 0)
                flags = newFlags;

            if (fullscreenWidth > 0)
                TCODSystem.forceFullscreenResolution(fullscreenWidth, fullscreenHeight);

            TCODConsole.setCustomFont(font, (int)flags, numberCharsHorz, numberCharsVert);
            TCODConsole.initRoot(80, 50, "tcodlib C# sample", fullscreen, TCODRendererType.SDL);
            rootConsole = TCODConsole.root;
            sampleConsole = new TCODConsole(SAMPLE_SCREEN_WIDTH, SAMPLE_SCREEN_HEIGHT);

            setupStaticData();
            rootConsole.setBackgroundFlag(TCODBackgroundFlag.Set);
            rootConsole.setAlignment(TCODAlignment.LeftAlignment);
            do
            {
                rootConsole.clear();
                if (!credits)
                    credits = TCODConsole.renderCredits(60, 42, false);
                for (int i = 0; i < sampleList.Length; i++)
                {
                    if (i == curSample)
                    {
                        // set colors for currently selected sample
                        rootConsole.setForegroundColor(TCODColor.white);
                        rootConsole.setBackgroundColor(TCODColor.blue);
                    }
                    else
                    {
                        // set colors for other samples
                        rootConsole.setForegroundColor(TCODColor.grey);
                        rootConsole.setBackgroundColor(TCODColor.black);
                    }
                    rootConsole.print(2, 45 - sampleList.Length + i, sampleList[i].name);
                }
                rootConsole.setForegroundColor(TCODColor.grey);
                rootConsole.setBackgroundColor(TCODColor.black);
                rootConsole.printEx(79, 46, TCODBackgroundFlag.Set, TCODAlignment.RightAlignment, "last frame : " + ((int)(TCODSystem.getLastFrameLength() * 1000)).ToString() + " ms ( " + TCODSystem.getFps() + "fps)");
                rootConsole.printEx(79, 47, TCODBackgroundFlag.Set, TCODAlignment.RightAlignment, "elapsed : " + TCODSystem.getElapsedMilli() + "ms " + (TCODSystem.getElapsedSeconds().ToString("0.00")) + "s");
                rootConsole.putChar(2, 47, (char)TCODSpecialCharacter.ArrowNorth);
                rootConsole.putChar(3, 47, (char)TCODSpecialCharacter.ArrowSouth);
                rootConsole.print(4, 47, " : select a sample");
                rootConsole.print(2, 48, "ALT-ENTER : switch to " + (TCODConsole.isFullscreen() ? "windowed mode  " : "fullscreen mode"));

                sampleList[curSample].render(first, key);
                first = false;

                TCODConsole.blit(sampleConsole, 0, 0, SAMPLE_SCREEN_WIDTH, SAMPLE_SCREEN_HEIGHT, rootConsole, SAMPLE_SCREEN_X, SAMPLE_SCREEN_Y);

                TCODConsole.flush();
                key = TCODConsole.checkForKeypress((int)TCODKeyStatus.KeyPressed);

                if (key.KeyCode == TCODKeyCode.Down)
                {
                    // down arrow : next sample
                    curSample = (curSample + 1) % sampleList.Length;
                    first = true;
                }
                else if (key.KeyCode == TCODKeyCode.Up)
                {
                    // up arrow : previous sample
                    curSample--;
                    if (curSample < 0)
                        curSample = sampleList.Length - 1;
                    first = true;
                }
                else if (key.KeyCode == TCODKeyCode.Enter && (key.LeftAlt || key.RightAlt))
                {
                    // ALT-ENTER : switch fullscreen
                    TCODConsole.setFullscreen(!TCODConsole.isFullscreen());
                }
                else if (key.KeyCode == TCODKeyCode.F1)
                {
                    System.Console.Out.WriteLine("key.pressed" + " " +
                        key.LeftAlt + " " + key.LeftControl + " " + key.RightAlt +
                        " " + key.RightControl + " " + key.Shift);
                }

            }
            while (!TCODConsole.isWindowClosed());
            return 0;
        }
Exemplo n.º 24
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);
            }
        }
Exemplo n.º 25
0
        public override bool use(Actor actor, Actor owner, Engine engine)
        {
            if (!used)
            {
                string message = "";
                TCODConsole con = new TCODConsole(Globals.INV_WIDTH, Globals.INV_HEIGHT);
                con.setForegroundColor(new TCODColor(200, 200, 150));
                con.printFrame(0, 0, Globals.INV_WIDTH, Globals.INV_HEIGHT, true, TCODBackgroundFlag.Default, "Story");
                if (triggernum == '(')
                {
                    message = Globals.story[engine.gameState.curLevel, 9];
                }
                else if (triggernum == ')')
                {
                    message = Globals.story[engine.gameState.curLevel, 10];
                }
                else
                {
                    message = Globals.story[engine.gameState.curLevel, (int)Char.GetNumericValue(triggernum) - 1];
                }
                if (message.Length > 41)
                {
                    string sub1 = message.Substring(0, 41);
                    string sub2 = message.Substring(41, message.Length - 41);
                    if (sub2.Length > 41)
                    {
                        string sub3 = sub2.Substring(0, 41);
                        sub2 = sub2.Substring(41, sub2.Length - 41);

                        con.print(3, 3, sub1);
                        con.print(3, 4, sub3);
                        con.print(3, 5, sub2);
                    }
                    else
                    {
                        con.print(3, 3, sub1);
                        con.print(3, 4, sub2);
                    }
                }
                else
                {
                    con.print(3, 3, message);
                }

                con.print(13, 15, "Press Enter to Continue");

                TCODConsole.blit(con, 0, 0, Globals.INV_WIDTH, Globals.INV_HEIGHT, TCODConsole.root, Globals.WIDTH / 2 - Globals.INV_WIDTH / 2, Globals.HEIGHT / 2 - Globals.INV_HEIGHT / 2);
                TCODConsole.flush();

                while(true)
                {
                    TCODKey key = TCODConsole.checkForKeypress();
                    if(key.KeyCode == TCODKeyCode.Enter){
                        break;
                    }
                }

                used = true;
                return used;
            }

            return false;
        }
Exemplo n.º 26
0
        private void DrawItemInRightPane(TCODConsole screen)
        {
            int x = SelectedItemOffsetX + ((SelectedItemWidth * 2) / 6) + 2;
            int y = SelectedItemOffsetY + 4;
            int w = ((SelectedItemWidth * 2) / 3) - 4;
            int h = SelectedItemHeight - 6;

            string itemDescription = m_selectedItem.ItemDescription + "\n\n" + m_selectedItem.FlavorDescription;
            y += screen.printRect(x, y, w, h, itemDescription);
            y += 2;

            IConsumable asConsumable = m_selectedItem as IConsumable;
            if (asConsumable != null && asConsumable.MaxCharges > 1)
            {
                screen.print(x, y, string.Format("Charges: {0} of {1}", asConsumable.Charges, asConsumable.MaxCharges));
                y++;
            }

            IArmor asArmor = m_selectedItem as IArmor;
            if (asArmor != null)
            {
                screen.print(x, y, "Stamina Bonus: " + asArmor.StaminaBonus);
                y += 2;
                screen.print(x, y, "Evade: " + asArmor.Evade);
                y += 2;

                IList<EquipArmorReasons> armorReasons = m_player.CanNotEquipArmorReasons(asArmor);
                if (armorReasons.Contains(EquipArmorReasons.Weight))
                {
                    m_dialogColorHelper.SaveColors(screen);
                    screen.setForegroundColor(TCODColor.red);
                    screen.print(x, y, "Weight: " + asArmor.Weight);
                    y += 2;
                    m_dialogColorHelper.ResetColors(screen);
                }
                else
                {
                    screen.print(x, y, "Weight: " + asArmor.Weight);
                    y += 2;
                }

                if (armorReasons.Contains(EquipArmorReasons.RobesPreventBoots) || armorReasons.Contains(EquipArmorReasons.BootsPreventRobes))
                {
                    m_dialogColorHelper.SaveColors(screen);
                    screen.setForegroundColor(TCODColor.red);
                    string outputString = armorReasons.Contains(EquipArmorReasons.RobesPreventBoots) ? "Robes prevent boots from being worn." : "Boots prevent robes from being worn.";
                    screen.print(x, y, outputString);
                    y += 2;
                    m_dialogColorHelper.ResetColors(screen);
                }
            }

            IWeapon asWeapon = m_selectedItem as IWeapon;
            if (asWeapon != null)
            {
                m_dialogColorHelper.SaveColors(screen);                
                if (!m_player.CanEquipWeapon(asWeapon))
                    screen.setForegroundColor(TCODColor.red);
                screen.print(x, y, "Type : " + asWeapon.Type);
                m_dialogColorHelper.ResetColors(screen);

                y += 2;
                screen.print(x, y, "Damage: " + asWeapon.Damage);

                y += 2;
                screen.print(x, y, "Speed: " + asWeapon.CTCostToAttack);
            }
        }
Exemplo n.º 27
0
Arquivo: Map.cs Projeto: bilwis/SH2RL
        public bool Render(TCODConsole con, int con_x, int con_y, int width, int height)
        {
            //This method is fairly convoluted because of all the intricacies of rendering ALL THE THINGS properly.
            //It could really use a makeover, but I'm not in the "OMGWTFBBQ MAJOR REWRITE UP IN THIS BIATCH" phase
            // and I'm afraid of breaking things.

            #region "Viewport setup"
            //In hnjah, the "viewport" is set up. The viewport is what the camera is in 3D games.
            //It determines what needs to be rendered (everything not in the viewport on any of the three
            //axes is "culled", i.e. not rendered).
            //The viewport is ALWAYS centered on the player.

            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 false;

            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

            #region "Map rendering"

            int abs_x, abs_y, abs_z;
            int rel_x, rel_y;
            int cell_rel_x, cell_rel_y;
            Tile t;
            TCODColor tinted_fore, tinted_back;
            bool floor = false;

            Random rand = new Random();

            int curr_z = Player.Z;
            abs_z = Player.Z - 1;

            String displ_string = " ";

            //Debug vars:
            Stopwatch sw = new Stopwatch();
            int debug_prints = 0;

            sw.Start();
            //AND THEY'RE OFF!

            //Buffer all tiles in the viewport into a two dimensional ushort array
            ushort[,] tilearr = new ushort[right - left + 1, bottom - top + 1];
            for (abs_x = left; abs_x < right; abs_x++)
            {
                for (abs_y = top; abs_y < bottom; abs_y++)
                {
                    tilearr[abs_x - left, abs_y - top] = getTileIDFromCells(abs_x, abs_y, abs_z);
                }
            }
            //Update tint
            UpdateTintMap(width, height);

            //Calculate the player's FOV
            tcod_map.computeFov(Player.X - cells[0, 0, 0].X, Player.Y - cells[0, 0, 0].Y, right - left, true, TCODFOVTypes.RestrictiveFov);

            float color_intensity = 1.0f;
            int light_level = 0;

            //Now go through all the tiles...
            for (abs_x = left; abs_x < right; abs_x++)
            {
                for (abs_y = top; abs_y < bottom; abs_y++)
                {
                    //...determine their relative coordinates (relative to the upper left
                    // corner of the viewport *and the tile byte array*, that is)
                    rel_x = abs_x - left;
                    rel_y = abs_y - top;
                    cell_rel_x = abs_x - cells[0, 0, 0].X;
                    cell_rel_y = abs_y - cells[0, 0, 0].Y;

                    //The light level determines the "color intensity", that is the gradient between the
                    // actual color and TCODColor.black, with intensity=1.0 meaning all color and 0.0 meaning
                    // all black.
                    //Since the light level is additive, it is clamped to MAX_LIGHT_LEVEL
                    light_level = wm.GetCellFromCoordinates(abs_x, abs_y, Player.Z).GetLightLevel(abs_x, abs_y, Player.Z);
                    //light_level = rand.Next((int)(light_level - (LIGHT_LEVEL_VARIANCE_LOWER * light_level)),
                    //    (int)(light_level + (LIGHT_LEVEL_VARIANCE_UPPER * light_level)));

                    light_level = light_level > MAX_LIGHT_LEVEL ? MAX_LIGHT_LEVEL : light_level;
                    light_level = light_level < MIN_LIGHT_LEVEL ? MIN_LIGHT_LEVEL : light_level;

                    color_intensity = (float)light_level / MAX_LIGHT_LEVEL;

                    //Check if the tile is in viewport and not in darkness
                    if (!tcod_map.isInFov(cell_rel_x, cell_rel_y) || wm.GetCellFromCoordinates(abs_x, abs_y, Player.Z).GetLightLevel(abs_x, abs_y, Player.Z) < LIGHT_LEVEL_CUTOFF_LOWER)
                    {
                        //if it is: If the tile was seen (is discovered) before, have a little bit of it be rendered
                        if (wm.GetCellFromCoordinates(abs_x, abs_y, Player.Z).IsDiscovered(abs_x, abs_y, Player.Z))
                            color_intensity = (float)MIN_LIGHT_LEVEL / (float)MAX_LIGHT_LEVEL;
                        else //or not
                            color_intensity = 0.0f;
                    }
                    else if (wm.GetCellFromCoordinates(abs_x, abs_y, Player.Z).GetLightLevel(abs_x, abs_y, Player.Z) > 0)
                        wm.GetCellFromCoordinates(abs_x, abs_y, Player.Z).DiscoverTile(abs_x, abs_y, Player.Z); //also if visible, discover!

                    //If current Tile is Air, skip ahead, because no hot rendering action is needed
                    if (tilearr[rel_x, rel_y] == 0) //Air Tile
                        continue;

                    //Retrieve the actual tile data
                    //If tile is transparent, display the tile BELOW (floor)
                    if (tcod_map.isTransparent(cell_rel_x, cell_rel_y))
                    {
                        t = wm.GetTileFromID(tilearr[rel_x, rel_y]);
                        floor = true;
                    }
                    else //the wall!
                    {
                        t = getTileFromCells(abs_x, abs_y, Player.Z);
                        floor = false;
                    }

                    //Safeguard
                    if (t.ForeColor == null)
                        continue;

                    //Prepare for render...
                    tinted_fore = t.ForeColor;//TCODColor.Interpolate(Util.DecodeRGB(light_tint[rel_x, rel_y]), t.ForeColor, 0.5f);

                    con.setBackgroundFlag(TCODBackgroundFlag.Default);
                    con.setForegroundColor(TCODColor.Interpolate(TCODColor.black, tinted_fore, color_intensity));
                    displ_string = t.DisplayString;

                    if (t.BackColor != null)
                    {
                        //
                        tinted_back = floor ? TCODColor.Interpolate(Util.DecodeRGB(light_tint[rel_x, rel_y]), t.BackColor, 0.5f) : t.BackColor;

                        con.setBackgroundColor(TCODColor.Interpolate(TCODColor.black, tinted_back, color_intensity));
                        con.setBackgroundFlag(TCODBackgroundFlag.Set);
                    }

                    //DO IT!
                    debug_prints++;
                    con.print(con_x + (abs_x - left), con_y + (abs_y - top), displ_string);
                }
            }
            sw.Stop();
            #endregion

            //Report the time it took to render one frame! (but only if in Debug mode!)
            if (DEBUG_OUTPUT)
            {
                _out.SendMessage("Drew frame, printed " + debug_prints + " tiles, took " + sw.ElapsedMilliseconds + "ms.");

                _out.SendMessage("Light Level at Player Pos:  " + cells[1, 1, 1].GetLightLevel(Player.X, Player.Y, Player.Z));
            }

            #region "Object rendering"
            //RenderAll the player
            con.setBackgroundFlag(TCODBackgroundFlag.Default);
            con.setForegroundColor(Player.ForeColor);

            con.print(con_x + (Player.X - left), con_y + (Player.Y - top), Player.DisplayString);

            //RenderAll the creatures
            foreach (Creature c in CreatureList.GetValues())
            {
                if (c.Z >= curr_z - Map.VIEW_DISTANCE_CREATURES_DOWN_Z && c.Z <= curr_z + Map.VIEW_DISTANCE_CREATURES_UP_Z)
                {
                    con.setForegroundColor(c.ForeColor);
                    con.print(con_x + (c.X - left), con_y + (c.Y - top), c.DisplayString);
                }
            }

            //RenderAll the items
            foreach (Item i in ItemList.GetValues())
            {
                if (!i.IsVisible)
                    continue;

                if (i.Z >= curr_z - Map.VIEW_DISTANCE_CREATURES_DOWN_Z && i.Z <= curr_z + Map.VIEW_DISTANCE_CREATURES_UP_Z)
                {
                    con.setForegroundColor(i.ForeColor);
                    con.print(con_x + (i.X - left), con_y + (i.Y - top), i.DisplayString);
                }
            }
            #endregion

            //DONE!
            return true;
        }
Exemplo n.º 28
0
        public Actor inventory(Actor player)
        {
            TCODConsole con = new TCODConsole(Globals.INV_WIDTH, Globals.INV_HEIGHT);
            con.setForegroundColor(new TCODColor(200,180,150));
            con.printFrame(0, 0, Globals.INV_WIDTH, Globals.INV_HEIGHT, true, TCODBackgroundFlag.Default, "Backpack");

            int y = 1;
            char shortcut = 'a';
            int itemIndex = 0;

            foreach(Actor item in player.contain.inventory)
            {
                con.print(2, y, String.Format("({0}) {1}", shortcut, item.name));
                y++;
                shortcut++;
            }
            TCODConsole.blit(con, 0, 0, Globals.INV_WIDTH, Globals.INV_HEIGHT, TCODConsole.root, Globals.WIDTH / 2 - Globals.INV_WIDTH / 2, Globals.HEIGHT / 2 - Globals.INV_HEIGHT / 2);
            TCODConsole.flush();

            TCODKey key = TCODConsole.waitForKeypress(false);

            if (key.Character >= 97 && key.Character <= 122)
            {
                itemIndex = key.Character - 'a';

                if (itemIndex >= 0 && itemIndex < player.contain.inventory.Count())
                {
                    return player.contain.inventory[itemIndex];
                }
            }
            return null;
        }