Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
0
        public override void DrawNewFrame(TCODConsole screen)
        {
            if (m_enabled)
            {
                screen.printFrame(EquipmentWindowOffset, EquipmentWindowTopY, EquipmentItemWidth, EquipmentItemHeight, true, TCODBackgroundFlag.Set, "Equipment");

                screen.printFrame(EquipmentWindowOffset + 1, EquipmentWindowTopY + EquipmentItemHeight - 6, EquipmentItemWidth - 2, 5, true);

                string weaponString = string.Format("Damage: {0}     Evade: {1}      Stamina Bonus: {2}", m_player.CurrentWeapon.Damage, m_player.Evade, GetStaminaTotalBonus());
                screen.print(EquipmentWindowOffset + 3, EquipmentWindowTopY + EquipmentItemHeight - 4, weaponString);

                List<INamedItem> equipmentList = CreateEquipmentListFromPlayer();

                m_dialogColorHelper.SaveColors(screen);
                for (int i = 0; i < equipmentList.Count; ++i)
                {
                    m_dialogColorHelper.SetColors(screen, i == m_cursorPosition, true);
                    screen.print(EquipmentWindowOffset + 2, EquipmentWindowTopY + (2 * i) + 2, m_equipmentListTypes[i] + ":");
                    if (equipmentList[i] != null && !(equipmentList[i].DisplayName == "Melee" && m_equipmentListTypes[i] == "Secondary Weapon"))
                        screen.print(EquipmentWindowOffset + 22, EquipmentWindowTopY + (2 * i) + 2, equipmentList[i].DisplayName);
                    else
                        screen.print(EquipmentWindowOffset + 22, EquipmentWindowTopY + (2 * i) + 2, "None");
                }
                m_dialogColorHelper.ResetColors(screen);
            }   
        }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
        // Display a line of text
        public void DisplayText(string textToDisplay, int x, int y, TCODColor foregroundColor, TCODColor backgroundColor, int Index)
        {
            // Handle mainmenu colour-swapping
            if (Index == (int)currentMenuOption)
            {
                foregroundColor   = TCODColor.black;
                colourInterpolate = colourInterpolate + colourInterpolateStep;
                if (colourInterpolate >= 0.91)
                {
                    colourInterpolateStep = -0.01;
                }
                else if (colourInterpolate <= 0.11)
                {
                    colourInterpolateStep = 0.01;
                }
                backgroundColor = TCODColor.Interpolate(TCODColor.yellow, TCODColor.red, (float)colourInterpolate);
            }

            rootConsole.setBackgroundColor(backgroundColor);
            rootConsole.setForegroundColor(foregroundColor);

            if (Index != -1)
            {
                System.Text.StringBuilder OffSetString = new System.Text.StringBuilder();
                OffSetString.Append(' ', (36 - textToDisplay.Length) / 2);
                textToDisplay = OffSetString + textToDisplay + OffSetString;
            }
            else
            {
                if (x == -1)
                {
                    x = (consoleWidth - textToDisplay.Length) / 2;
                }
            }

            int offset = 0;

            foreach (char value in textToDisplay)
            {
                if (value == '[')
                {
                    rootConsole.setForegroundColor(foregroundColor);
                }
                else if (value == ']')
                {
                    rootConsole.setForegroundColor(foregroundColor);
                }
                else if (offset == 1 && textToDisplay[0] == '[')
                {
                    rootConsole.setForegroundColor(foregroundColor);
                }
                else
                {
                    rootConsole.setForegroundColor(foregroundColor);
                }
                offset++;
                rootConsole.setCharBackground(x + offset, y, backgroundColor, TCODBackgroundFlag.Set);
                rootConsole.print(x + offset, y, value.ToString());
            }
        }
Exemplo n.º 6
0
        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);
            }   
        }
Exemplo n.º 7
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]);
            }
        }
Exemplo n.º 8
0
        public void Draw(TCODConsole cons)
        {
            TCODConsole temp = new TCODConsole(50, 30);
            int         x    = 2;

            foreach (int i in _taken.Keys)
            {
                temp.print(2, x, String.Format("{0} - {1}", (char)(i + 97), _items[i].Item));
                x++;
            }
            TCODConsole.blit(temp, 0, 0, 50, x + 2, cons, 0, 0);
        }
Exemplo n.º 9
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.º 10
0
Arquivo: Game.cs Projeto: rezich/zday
        public void Draw()
        {
            TCODConsole r = TCODConsole.root;

            r.clear();

            // world box
            r.printFrame(0, 0, 47, 47);
            r.print(2, 0, "Z-DAY v0.01");
            Point offset = new Point(Player.Position.X - 23, Player.Position.Y - 23);

            Area.Current.Map.computeFov(Player.Position.X, Player.Position.Y, Player.ViewRadius, true, TCODFOVTypes.BasicFov);
            foreach (Terrain t in Area.Current.Terrain)
            {
                if (Area.Current.Map.isInFov(t.Position.X, t.Position.Y))
                {
                    t.Draw(TCODConsole.root, offset);
                }
            }
            foreach (Decal d in Area.Current.Decals)
            {
                if (Area.Current.Map.isInFov(d.Position.X, d.Position.Y))
                {
                    d.Draw(TCODConsole.root, offset);
                }
            }
            foreach (Item i in Area.Current.Items)
            {
                if (Area.Current.Map.isInFov(i.Position.X, i.Position.Y))
                {
                    i.Draw(TCODConsole.root, offset);
                }
            }
            foreach (Character c in Area.Current.Characters)
            {
                if (Area.Current.Map.isInFov(c.Position.X, c.Position.Y))
                {
                    c.Draw(TCODConsole.root, offset);
                }
            }

            DrawHUD();
            TCODConsole.flush();
        }
Exemplo n.º 11
0
        public void Draw(TCODConsole screen)
        {
            const int LinesInTextConsole = TextBoxHeight - 2;
            screen.printFrame(0, TextBoxYPosition, TextBoxWidth, TextBoxHeight, true);

            if (m_textList.Count == 0)
                return;        // No Text == Nothing to Draw.

            // Draw either all the text, or all that will fit
            int numberToDraw = ((m_textList.Count - m_textBoxPosition) < LinesInTextConsole) ?
                (m_textList.Count - m_textBoxPosition) : LinesInTextConsole;

            int currentElement = 0;
            for (int i = 0; i < LinesInTextConsole; ++i)
            {
                if (currentElement == numberToDraw)
                    break;
                
                string currentString = m_textList[m_textBoxPosition + currentElement];
                
                // If it's over 1 line long, we treat it special. See if it will be early.
                int numberOfLinesLong = screen.getHeightRect(1, TextBoxYPosition, TextBoxWidth - 2, 8, currentString);

                if (numberOfLinesLong > 1)
                {
                    i += numberOfLinesLong - 1;
                    if (i >= LinesInTextConsole)
                        break;
                    screen.printRect(1, TextBoxYPosition + LinesInTextConsole - i, TextBoxWidth - 2, numberOfLinesLong, currentString);
                }
                else
                {
                    screen.print(1, TextBoxYPosition + LinesInTextConsole - i, currentString);
                }
                currentElement++;
            }
        }
Exemplo n.º 12
0
        public override void DrawNewFrame(TCODConsole screen)
        {
            const int DialogOffset = 13;
            if (Enabled)
            {
                m_leftEnabled = TCODSystem.getElapsedSeconds() > m_timeToEnableYes;

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

                m_dialogColorHelper.SaveColors(screen);
                screen.printFrame(DialogOffset, DialogOffset + 5, UIHelper.ScreenWidth - (2 * DialogOffset), 9, true);

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

                m_dialogColorHelper.SetColors(screen, m_leftSelected, m_leftEnabled);
                screen.print((UIHelper.ScreenWidth / 2) - 13, 11 + DialogOffset, m_leftButton);
                m_dialogColorHelper.SetColors(screen, !m_leftSelected, true);
                screen.print((UIHelper.ScreenWidth / 2) + 5, 11 + DialogOffset, m_rightButton);

                m_dialogColorHelper.ResetColors(screen);
            }
        }
Exemplo n.º 13
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.º 14
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);
                    }
                }
            }
        }
Exemplo n.º 15
0
 private void DrawSkillPointTotalFrame(TCODConsole screen)
 {
     screen.printFrame(5, 48, 16, 7, true);
     screen.putChar(5, 48, (int)TCODSpecialCharacter.TeeEast);
     screen.putChar(20, 54, (int)TCODSpecialCharacter.TeeNorth);
     screen.print(6, 49, "Skill Points:");
     screen.print(6, 51, "SP Earned:" + m_engine.Player.SkillPoints.ToString());
     int selectedSkillCost = NewlySelectedSkills.Sum(x => x.Cost);
     screen.print(6, 52, "SP Spent: " + selectedSkillCost);
     screen.print(6, 53, "SP Left:  " + (m_engine.Player.SkillPoints - selectedSkillCost).ToString());
 }
Exemplo n.º 16
0
        public override void DrawNewFrame(TCODConsole screen)
        {
            const int LeftThird = UIHelper.ScreenWidth / 6;
            const int RightThird = 4 * UIHelper.ScreenWidth / 6;

            if (m_enabled)
            {
                screen.clear();

                if (m_firstFrame)
                {
                    TCODConsole.resetCredits();
                    m_firstFrame = false;
                }

                if (!m_creditsDone)
                {
                    m_dialogColorHelper.SaveColors(screen);
                    m_creditsDone = TCODConsole.renderCredits(RightThird + 10, 54, true);
                    m_dialogColorHelper.ResetColors(screen);
                }

                screen.printFrame(0, 0, UIHelper.ScreenWidth, UIHelper.ScreenHeight, false, TCODBackgroundFlag.Set, "Help");

                screen.printRect(RightThird - 19, 52, 45, 7, "Copyright Chris Hamons 2010.\nThank you Ben for\nearly development help.\n\nSoli Deo Gloria");

                const int SymbolStartY = 3;
                const int SymbolVerticalOffset = -8;
                screen.print(LeftThird + SymbolVerticalOffset, SymbolStartY, "Map Symbols");
                screen.print(LeftThird + SymbolVerticalOffset, SymbolStartY + 1, "------------------------");
                screen.print(LeftThird + SymbolVerticalOffset, SymbolStartY + 2, "@ - You");
                screen.print(LeftThird + SymbolVerticalOffset, SymbolStartY + 3, "; - Open Door");
                screen.print(LeftThird + SymbolVerticalOffset, SymbolStartY + 4, ": - Closed Door");
                screen.print(LeftThird + SymbolVerticalOffset, SymbolStartY + 5, "_ - Cosmetic");
                screen.print(LeftThird + SymbolVerticalOffset, SymbolStartY + 6, "& - Item on Ground");
                screen.print(LeftThird + SymbolVerticalOffset, SymbolStartY + 7, "%% - Stack of Items");

                const int ActionStartY = SymbolStartY + 10;
                const int ActionVerticalOffset = -8;
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY, "Action Keys");
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 1, "------------------------");
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 2, "Attack (or reload) - " + m_keyMappings["Attack"]);
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 3, "Get Item           - " + m_keyMappings["GetItem"]);
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 4, "Cast Spell         - " + m_keyMappings["CastSpell"]);
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 5, "Inventory          - " + m_keyMappings["Inventory"]);
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 6, "Equipment          - " + m_keyMappings["Equipment"]);
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 7, "Skill Tree         - " + m_keyMappings["ShowSkillTree"]);
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 8, "Show Status Effects- " + m_keyMappings["ShowEffects"]);
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 9, "Operate            - " + m_keyMappings["Operate"]);
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 10, "Wait               - " + m_keyMappings["Wait"]);
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 11, "Rest Until Healed  - " + m_keyMappings["RestTillHealed"]);
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 12, "Move To Location   - " + m_keyMappings["MoveToLocation"]);
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 13, "View Mode          - " + m_keyMappings["ViewMode"]);
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 14, "Down Stairs        - " + m_keyMappings["DownStairs"]);
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 15, "Up Stairs          - " + m_keyMappings["UpStairs"]);
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 16, "Swap Weapons       - " + m_keyMappings["SwapWeapon"]);

                const int RebindingStartY = SymbolStartY;
                string rebindingText = "To change keystroke bindings, edit KeyMappings.xml and restart magecrawl.\n\nA list of possible keys can be found at: http://tinyurl.com/ya5l8sj\n\nOther preferences can be found in Preferences.xml";
                screen.printFrame(RightThird - 12, RebindingStartY, 31, 12, true);
                screen.printRect(RightThird - 11, RebindingStartY + 1, 29, 10, rebindingText);

                const int DirectionStartY = ActionStartY + 19;
                const int DirectionVerticalOffset = -8;
                screen.print(LeftThird + DirectionVerticalOffset, DirectionStartY, string.Format("Direction Keys (+{0} to Run)", (bool)Preferences.Instance["UseAltInsteadOfCtrlForRunning"] ? "Alt" : "Ctrl"));
                screen.print(LeftThird + DirectionVerticalOffset, DirectionStartY + 1, "------------------------");
                screen.print(LeftThird + DirectionVerticalOffset, DirectionStartY + 2, "North      - " + m_keyMappings["North"]);
                screen.print(LeftThird + DirectionVerticalOffset, DirectionStartY + 3, "West       - " + m_keyMappings["West"]);
                screen.print(LeftThird + DirectionVerticalOffset, DirectionStartY + 4, "East       - " + m_keyMappings["East"]);
                screen.print(LeftThird + DirectionVerticalOffset, DirectionStartY + 5, "South      - " + m_keyMappings["South"]);
                screen.print(LeftThird + DirectionVerticalOffset, DirectionStartY + 6, "North West - " + m_keyMappings["Northwest"]);
                screen.print(LeftThird + DirectionVerticalOffset, DirectionStartY + 7, "North East - " + m_keyMappings["Northeast"]);
                screen.print(LeftThird + DirectionVerticalOffset, DirectionStartY + 8, "South West - " + m_keyMappings["Southwest"]);
                screen.print(LeftThird + DirectionVerticalOffset, DirectionStartY + 9, "South East - " + m_keyMappings["Southeast"]);

                const int OtherKeysStartY = ActionStartY + 4;
                const int OtherKeysVerticalOffset = -12;
                screen.print(RightThird + OtherKeysVerticalOffset, OtherKeysStartY, "Other Keys");
                screen.print(RightThird + OtherKeysVerticalOffset, OtherKeysStartY + 1, "----------------------------");
                screen.print(RightThird + OtherKeysVerticalOffset, OtherKeysStartY + 2, "Text Box Page Up   - " + m_keyMappings["TextBoxPageUp"]);
                screen.print(RightThird + OtherKeysVerticalOffset, OtherKeysStartY + 3, "Text Box Page Down - " + m_keyMappings["TextBoxPageDown"]);
                screen.print(RightThird + OtherKeysVerticalOffset, OtherKeysStartY + 4, "Text Box Clear     - " + m_keyMappings["TextBoxClear"]);
                screen.print(RightThird + OtherKeysVerticalOffset, OtherKeysStartY + 5, "Escape             - " + m_keyMappings["Escape"]);
                screen.print(RightThird + OtherKeysVerticalOffset, OtherKeysStartY + 6, "Select             - " + m_keyMappings["Select"]);
                screen.print(RightThird + OtherKeysVerticalOffset, OtherKeysStartY + 7, "Save               - " + m_keyMappings["Save"]);
                screen.print(RightThird + OtherKeysVerticalOffset, OtherKeysStartY + 8, "Help               - " + m_keyMappings["Help"]);
                screen.print(RightThird + OtherKeysVerticalOffset, OtherKeysStartY + 9, "Quit               - " + m_keyMappings["Quit"]);
            }
        }
Exemplo n.º 17
0
 public void PrintString(int x, int y, string text, params object[] args)
 {
     _console.print(x, y, string.Format(text, args));
 }
Exemplo n.º 18
0
Arquivo: Util.cs Projeto: bilwis/SH2RL
        public static string GetStringFromUser(string prompt, int x, int y, TCODConsole con)
        {
            string temp = "";
            TCODKey key;
            while (true)
            {
                con.print(x-prompt.Length, y, prompt);
                con.print(x, y, temp);

                TCODConsole.flush();

                key = TCODConsole.waitForKeypress(true);
                if (key.KeyCode == TCODKeyCode.Escape)
                {
                    con.print(x - prompt.Length, y, "                                                                         ");
                    break;
                }

                if (key.Character.ToString() == "\0")
                {
                    continue;
                }

                if (key.KeyCode == TCODKeyCode.Backspace)
                {
                    if (temp.Length > 0)
                        temp = temp.Remove(temp.Length - 1);

                    con.print(x, y, new String(' ', temp.Length + 1));
                    continue;
                }

                if (key.KeyCode == TCODKeyCode.Enter)
                {
                    con.print(x - prompt.Length, y, "                                                                         ");
                    return temp;
                }

                temp += key.Character.ToString();
            }
            return null;
        }
Exemplo n.º 19
0
 public static void DrawString(IntVector2 pos, string str)
 {
     displayConsole.print(pos.X, pos.Y, str);
 }
Exemplo n.º 20
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.º 21
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.º 22
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.º 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
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.º 26
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.º 27
0
Arquivo: Game.cs Projeto: rezich/zday
        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);
        }
Exemplo n.º 28
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.º 29
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.º 30
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.º 31
0
        public void Unequip()
        {
            List<Item> equipped = GetAllEquippedItems();
            if(equipped.Count == 0)
            {
                DarkRL.WriteMessage("There's nothing to unequip.");
                return;
            }
            TCODConsole overlay = new TCODConsole(40, equipped.Count);
            char sym = 'a';
            int y = 0;
            //now display them all
            foreach (Item i in equipped)
            {

                overlay.print(0, y, sym.ToString() + ")" + i.ToString());
                ++y;
                ++sym;
            }
            DarkRL.WriteMessage("What do you want to unequip?");
            DarkRL.AddOverlayConsole(overlay, 0, 0, overlay.getWidth(), overlay.getHeight(), TCODConsole.root, Window.StatusPanelWidth,
                Window.MessagePanelHeight);
            Key input = InputSystem.WaitForAndReturnInput();
            char index = (char)(input.Character - 'a');
            if (index >= equipped.Count || index < 0)
            {
                DarkRL.WriteMessage("Couldn't find anything..");
                return;
            }
            //so unequip
            Item item = Unequip(Backpack[index].Slot);
            return;
        }
Exemplo n.º 32
0
Arquivo: Map.cs Projeto: bilwis/SH2RL
        /// <summary>
        /// This function renders the particles of the given particle emitter onto the given console object.
        /// </summary>
        public void RenderParticles(ParticleEmitter emitter, TCODConsole con, int width, int height)
        {
            //Check if emitter is on player level
            if (emitter.abs_z != Player.Z)
                return;

            #region "Viewport setup"

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

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

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

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

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

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

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

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

            #endregion

            //Iterate through the particles and render them
            foreach (Particle p in emitter.particles)
            {
                if (tcod_map.isInFov((int)p.abs_x - cells[0, 0, 0].X, (int)p.abs_y - cells[0, 0, 0].Y))
                {
                    con.setBackgroundFlag(TCODBackgroundFlag.Screen);
                    con.setBackgroundColor(TCODColor.Interpolate(TCODColor.black, p.color, p.intensity));

                    con.print(1 + ((int)p.abs_x - left), 1 + ((int)p.abs_y - top), " ");
                }

            }
        }
Exemplo n.º 33
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;
        }