Beispiel #1
0
        public void Draw()
        {
            _console.rect(0, 0, 80, _lines, true);
            int size = _messages.Count;

            for (int i = 0; i < System.Math.Min(_lines, size); i++)
            {
                _console.print(0, _lines - i - 1, _messages[size - i - 1]);
            }
        }
Beispiel #2
0
        private void DrawTabBar(TCODConsole screen)
        {
            const int HorizontalTabOffset = 2;
            screen.rect(UpperLeft + 1, UpperLeft + 1, SkillTreeWidth - 2, HorizontalTabOffset - 1, true);

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

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

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

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

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

                if (m_currentTabName == name)
                {
                    int lengthReductionToDueTee = name == "Water" ? 0 : 2;
                    for (int i = x - 4 - name.Length; i < x - lengthReductionToDueTee; i++)
                    {
                        screen.setCharBackground(i, y, TCODColor.grey);
                    }
                }
            }
        }
Beispiel #3
0
 public void SetBackgroundColour(Rectangle area, TCODColor colour)
 {
     SetBackgroundColour(colour);
     _console.rect(area.X, area.Y, area.Width, area.Height, true);
 }
Beispiel #4
0
        public void DrawHUD()
        {
            TCODConsole r                  = TCODConsole.root;
            int         sidebarWidth       = 33;
            int         windowWidth        = 80;
            int         windowHeight       = 50;
            int         vWidth             = 47;
            int         vHeight            = 47;
            int         weaponBoxWidth     = 16;
            int         weaponBoxHeight    = 4;
            int         characterBoxHeight = 11;


            // bottom bar
            r.printFrame(0, windowHeight - 3, windowWidth - sidebarWidth, 3);
            r.printEx(vHeight / 2 + 1, windowHeight - 2, TCODBackgroundFlag.Default, TCODAlignment.CenterAlignment, Area.Current.DescribeTile(Player.Position));


            // character box
            r.printFrame(vWidth, 0, windowWidth - vWidth, characterBoxHeight);
            r.print(vWidth + 2, 0, "CHARACTER");
            r.print(vWidth + 2, 2, "Adam");
            r.print(vWidth + 2, 3, "LVL: " + Convert.ToString(Player.Level));
            r.print(vWidth + 2, 4, "ATK: " + (Player.AttackMultiplier > 1 ? Player.AttackMultiplier.ToString() : "") + "d" + Player.AttackDie.ToString() + (Player.AttackModifier > 0 ? "+" + Player.AttackModifier.ToString() : ""));

            float barHP      = ((float)Player.HP / (float)Player.MaxHP) * (windowWidth - vWidth - 4);
            float barStamina = ((float)Player.Stamina / (float)Player.MaxStamina) * (windowWidth - vWidth - 4);
            float barXP      = ((float)(Player.XP - Character.LevelXP(Player.Level)) / (float)(Character.LevelXP(Player.Level + 1) - Character.LevelXP(Player.Level))) * (windowWidth - vWidth - 4);

            r.setBackgroundFlag(TCODBackgroundFlag.Set);
            r.setBackgroundColor(TCODColor.darkGreen);
            r.rect(vWidth + 2, 6, (int)barHP, 1, false);
            r.setBackgroundColor(TCODColor.grey);
            r.printEx(vWidth + 2 + ((windowWidth - vWidth - 4) / 2), 6, TCODBackgroundFlag.Darken, TCODAlignment.CenterAlignment, " HP: " + Convert.ToString(Player.HP) + "/" + Convert.ToString(Player.MaxHP) + " ");
            r.setBackgroundColor(TCODColor.darkBlue);
            r.rect(vWidth + 2, 7, (int)barStamina, 1, false);
            r.setBackgroundColor(TCODColor.grey);
            r.printEx(vWidth + 2 + ((windowWidth - vWidth - 4) / 2), 7, TCODBackgroundFlag.Darken, TCODAlignment.CenterAlignment, " STM: " + Convert.ToString(Math.Round((float)Player.Stamina / (float)Player.MaxStamina * 100)) + "%% ");
            r.setBackgroundColor(TCODColor.darkYellow);
            r.rect(vWidth + 2, 8, (int)barXP, 1, false);
            r.setBackgroundColor(TCODColor.grey);
            r.printEx(vWidth + 2 + ((windowWidth - vWidth - 4) / 2), 8, TCODBackgroundFlag.Darken, TCODAlignment.CenterAlignment, " XP: " + Convert.ToString(Player.XP) + " / " + Convert.ToString(Character.LevelXP(Player.Level + 1)) + " ");
            r.setBackgroundColor(TCODColor.black);

            r.print(vWidth + 16, 2, "STR: " + Convert.ToString(Player.Strength));
            r.print(vWidth + 16, 3, "DEX: " + Convert.ToString(Player.Dexterity));
            r.print(vWidth + 24, 2, "CON: " + Convert.ToString(Player.Constitution));
            r.print(vWidth + 24, 3, "INT: " + Convert.ToString(Player.Intelligence));
            r.print(vWidth + 16, 4, "DEF: " + Convert.ToString(Player.Defense));
            r.print(vWidth + 24, 4, "SPD: " + Convert.ToString(Player.Speed));



            // console box
            r.printFrame(vWidth, characterBoxHeight, windowWidth - vWidth, windowHeight - weaponBoxHeight - characterBoxHeight);
            r.print(vWidth + 2, characterBoxHeight, "CONSOLE");
            int remainingLines = windowHeight - weaponBoxHeight - characterBoxHeight - 2;
            int i = Console.Lines.Count - 1;

            while (remainingLines > 0 && i > -1)
            {
                string         text      = Console.Lines[i].Text;
                Queue <string> lines     = new Queue <string>();
                int            maxLength = windowWidth - vWidth - 2;
                while (text.Length > maxLength)
                {
                    string split = text.Substring(0, maxLength);
                    if (text.Substring(maxLength, 1) != " ")
                    {
                        split = split.Substring(0, split.LastIndexOf(" ")).TrimEnd();
                    }
                    split = split.TrimEnd();
                    lines.Enqueue(split);
                    text = " " + text.Substring(split.Length).Trim();
                }
                lines.Enqueue(text);
                remainingLines -= lines.Count;
                int j = 0;
                while (lines.Count > 0)
                {
                    string line = lines.Dequeue();
                    if (characterBoxHeight + 1 + remainingLines + j > characterBoxHeight)
                    {
                        r.print(vWidth + 1, characterBoxHeight + 1 + remainingLines + j, line);
                    }
                    j++;
                }

                i -= 1;
            }



            // weapon box
            r.printFrame(vWidth, windowHeight - weaponBoxHeight, weaponBoxWidth, weaponBoxHeight);
            r.print(vWidth + 1, windowHeight - weaponBoxHeight + 1, Player.Weapon == null ? "unarmed" : Player.Weapon.ToString());


            // time box
            r.printFrame(vWidth + weaponBoxWidth, windowHeight - weaponBoxHeight, windowWidth - vWidth - weaponBoxWidth, weaponBoxHeight);
            string strKilled = Convert.ToString(Player.Kills) + " KILLED";
            string strTime   = "DAY 1 00:00.00";

            r.print(80 - strKilled.Length - 1, 48, strKilled);
            r.print(80 - strTime.Length - 1, 47, strTime);
        }