Exemple #1
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));
        }
Exemple #2
0
        public override void DrawNewFrame(TCODConsole screen)
        {
            const int WelcomeScreenOffset = 13;
            if (m_enabled)
            {
                m_yesEnabled = TCODSystem.getElapsedSeconds() > m_timeToEnableYes;

                if (Preferences.Instance.DebuggingMode)
                    m_yesEnabled = true;

                m_dialogColorHelper.SaveColors(screen);
                screen.printFrame(WelcomeScreenOffset, WelcomeScreenOffset + 5, UIHelper.ScreenWidth - (2 * WelcomeScreenOffset), 11, true);
                string saveString = "Saving the game will end your current session and allow you to pickup playing later.";
                screen.printRectEx(UIHelper.ScreenWidth / 2, 7 + WelcomeScreenOffset, UIHelper.ScreenWidth - 4 - (2 * WelcomeScreenOffset), UIHelper.ScreenHeight - (2 * WelcomeScreenOffset), TCODBackgroundFlag.Set, TCODAlignment.CenterAlignment, saveString);

                screen.printEx(UIHelper.ScreenWidth / 2, 11 + WelcomeScreenOffset, TCODBackgroundFlag.Set, TCODAlignment.CenterAlignment, "Really Save?");

                m_dialogColorHelper.SetColors(screen, m_yesSelected, m_yesEnabled);
                screen.print((UIHelper.ScreenWidth / 2) - 6, 13 + WelcomeScreenOffset, "Yes");
                m_dialogColorHelper.SetColors(screen, !m_yesSelected, true);
                screen.print((UIHelper.ScreenWidth / 2) + 4, 13 + WelcomeScreenOffset, "No");

                m_dialogColorHelper.ResetColors(screen);
            }
        }
Exemple #3
0
        public override void DrawNewFrame(TCODConsole screen)
        {
            const int WelcomeScreenOffset = 13;
            if (m_enabled)
            {
                m_yesEnabled = TCODSystem.getElapsedSeconds() > m_timeToEnableYes;

                // Don't make debugger wait
                if (Preferences.Instance.DebuggingMode)
                    m_yesEnabled = true;

                m_dialogColorHelper.SaveColors(screen);
                screen.printFrame(WelcomeScreenOffset, WelcomeScreenOffset + 5, UIHelper.ScreenWidth - (2 * WelcomeScreenOffset), 11, true);
                string quitString;
                if (m_quitReason == QuitReason.quitAction)
                    quitString = "Quitting the game will delete your current character. To stop playing now and continue your adventure later, use save instead.";
                else
                    quitString = "Leaving the dungeon will end the game early and delete your current character. To stop playing now and continue your adventure later, use save instead.";

                screen.printRectEx(UIHelper.ScreenWidth / 2, 7 + WelcomeScreenOffset, UIHelper.ScreenWidth - 4 - (2 * WelcomeScreenOffset), UIHelper.ScreenHeight - (2 * WelcomeScreenOffset), TCODBackgroundFlag.Set, TCODAlignment.CenterAlignment, quitString);

                screen.printEx(UIHelper.ScreenWidth / 2, 11 + WelcomeScreenOffset, TCODBackgroundFlag.Set, TCODAlignment.CenterAlignment, "Really Quit?");

                m_dialogColorHelper.SetColors(screen, m_yesSelected, m_yesEnabled);
                screen.print((UIHelper.ScreenWidth / 2) - 6, 13 + WelcomeScreenOffset, "Yes");
                m_dialogColorHelper.SetColors(screen, !m_yesSelected, true);
                screen.print((UIHelper.ScreenWidth / 2) + 4, 13 + WelcomeScreenOffset, "No");

                m_dialogColorHelper.ResetColors(screen);
            }
        }
        public override void DrawNewFrame(TCODConsole screen)
        {
            if (m_enabled)
            {
                screen.printFrame(SelectedItemOffsetX, SelectedItemOffsetY, SelectedItemWidth, SelectedItemHeight, true);

                // Draw Header.
                screen.hline(SelectedItemOffsetX + 1, SelectedItemOffsetY + 2, SelectedItemWidth - 2);
                screen.putChar(SelectedItemOffsetX, SelectedItemOffsetY + 2, (int)TCODSpecialCharacter.TeeEast);
                screen.putChar(SelectedItemOffsetX + SelectedItemWidth - 1, SelectedItemOffsetY + 2, (int)TCODSpecialCharacter.TeeWest);
                screen.printEx(SelectedItemOffsetX + (SelectedItemWidth / 2), SelectedItemOffsetY + 1, TCODBackgroundFlag.Set, TCODAlignment.CenterAlignment, m_selectedItem.DisplayName);

                // Split in half for description.
                screen.vline(SelectedItemOffsetX + (SelectedItemWidth / 3), SelectedItemOffsetY + 2, SelectedItemHeight - 3);
                screen.putChar(SelectedItemOffsetX + (SelectedItemWidth / 3), SelectedItemOffsetY + 2, (int)TCODSpecialCharacter.TeeSouth);
                screen.putChar(SelectedItemOffsetX + (SelectedItemWidth / 3), SelectedItemOffsetY + SelectedItemHeight - 1, (int)TCODSpecialCharacter.TeeNorth);

                DrawItemInRightPane(screen);

                m_dialogColorHelper.SaveColors(screen);
                
                // Print option list.
                for (int i = 0; i < m_optionList.Count; ++i)
                {
                    m_dialogColorHelper.SetColors(screen, i == m_cursorPosition, m_optionList[i].Enabled);
                    screen.print(SelectedItemOffsetX + 2, SelectedItemOffsetY + 4 + (i * 2), m_optionList[i].Option);
                }

                m_dialogColorHelper.ResetColors(screen);
            }   
        }
        public override void DrawNewFrame(TCODConsole screen)
        {
            if (m_enabled)
            {
                m_higherRange = m_isScrollingNeeded ? m_lowerRange + NumberOfLinesDisplayable : m_itemList.Count;
                screen.printFrame(InventoryWindowOffset, InventoryWindowOffset, InventoryItemWidth, InventoryItemHeight, true, TCODBackgroundFlag.Set, m_title);
                
                // Start lettering from our placementOffset.
                char currentLetter = 'a';

                if (m_useCharactersNextToItems)
                {
                    for (int i = 0; i < m_lowerRange; ++i)
                        currentLetter = IncrementLetter(currentLetter);
                }

                int positionalOffsetFromTop = 0;
                m_dialogColorHelper.SaveColors(screen);

                int farRightPaddingAmount = DetermineFarRightPaddingForMagicList();

                for (int i = m_lowerRange; i < m_higherRange; ++i)
                {
                    string displayString = m_itemList[i].DisplayName;
                    m_dialogColorHelper.SetColors(screen, i == m_cursorPosition, m_shouldBeSelectedDelegate(m_itemList[i]));
                    if (displayString.Contains('\t'.ToString()))
                    {
                        // This is the case for Tab Seperated Spaces, used for magic lists and such
                        string[] sectionArray = displayString.Split(new char[] { '\t' }, 3);

                        screen.print(InventoryWindowOffset + 1, InventoryWindowOffset + 1 + positionalOffsetFromTop, currentLetter + " - " + sectionArray[0]);
                        if (sectionArray.Length > 1)
                        {
                            screen.print(InventoryWindowOffset + (InventoryItemWidth / 2), InventoryWindowOffset + 1 + positionalOffsetFromTop, sectionArray[1]);
                            if (sectionArray.Length > 2)
                            {
                                screen.printEx(InventoryWindowOffset - 2 + InventoryItemWidth, InventoryWindowOffset + 1 + positionalOffsetFromTop, TCODBackgroundFlag.Set, TCODAlignment.RightAlignment, sectionArray[2].PadRight(farRightPaddingAmount));
                            }
                        }
                    }
                    else
                    {
                        string printString;
                        if (m_useCharactersNextToItems)
                            printString = string.Format("{0} - {1}", currentLetter, displayString);
                        else
                            printString = " - " + displayString;
                        screen.print(InventoryWindowOffset + 1, InventoryWindowOffset + 1 + positionalOffsetFromTop, printString);
                    }

                    currentLetter = IncrementLetter(currentLetter);
                    positionalOffsetFromTop++;
                }
                m_dialogColorHelper.ResetColors(screen);
            }
        }
Exemple #6
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--;
            }
        }
        public override void DrawNewFrame(TCODConsole screen)
        {
            if (m_isSelectionCursor)
            {
                screen.setCharBackground(ScreenCenter.X + 1, ScreenCenter.Y + 1, TCODColor.darkYellow);

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

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

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

                            screen.setBackgroundColor(ColorPresets.DarkGray);

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

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

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

                            screen.setBackgroundColor(ColorPresets.Black);
                        }
                    }
                }
            }
        }
Exemple #8
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]));
            }
        }
Exemple #9
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));
            }
        }
Exemple #10
0
        public override void DrawNewFrame(TCODConsole screen)
        {
            const int DialogOffset = 13;
            if (Enabled)
            {
                m_dialogColorHelper.SaveColors(screen);
                screen.printFrame(DialogOffset, DialogOffset + 5, UIHelper.ScreenWidth - (2 * DialogOffset), 11, true);

                screen.printRectEx(UIHelper.ScreenWidth / 2, 7 + DialogOffset, UIHelper.ScreenWidth - 4 - (2 * DialogOffset), UIHelper.ScreenHeight - (2 * DialogOffset), TCODBackgroundFlag.Set, TCODAlignment.CenterAlignment, Text);

                m_dialogColorHelper.SetColors(screen, true, true);
                screen.printEx(UIHelper.ScreenWidth / 2, 13 + DialogOffset, TCODBackgroundFlag.Set, TCODAlignment.CenterAlignment, "OK");

                m_dialogColorHelper.ResetColors(screen);
            }
        }
Exemple #11
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;
        }
Exemple #12
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);
            }
        }
Exemple #13
0
 public void PrintString(int x, int y, string text, TCODAlignment alignment, params object[] args)
 {
     _console.printEx(x, y, TCODBackgroundFlag.None, alignment, string.Format(text, args));
 }
Exemple #14
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);
        }