Exemplo n.º 1
0
        private void WriteResist(ITerminal terminal, Element element, Vec pos)
        {
            int numResists = mHero.GetNumResists(element);

            TermColor color  = GameArt.GetColor(element);
            string    letter = element.ToString().Substring(0, 1);

            switch (numResists)
            {
            case 0: terminal[pos][TermColor.DarkGray].Write("-"); break;

            case 1: terminal[pos][color].Write(letter.ToLower()); break;

            default: terminal[pos][color].Write(letter); break;
            }
        }
Exemplo n.º 2
0
        protected override void OnPaint(ITerminal terminal)
        {
            terminal.Clear();

            Monster monster = mThing as Monster;

            if (monster != null)
            {
                // draw the object
                terminal.Write(GameArt.Get(monster));

                // draw its name
                terminal[2, 0].Write(monster.NounText);

                // draw its health if alive
                if (monster.Health.Current > 0)
                {
                    for (int i = 0; i < 10; i++)
                    {
                        if (monster.Health.Current * 10 / monster.Health.Max >= i)
                        {
                            terminal[-10 + i, 0][TermColor.DarkRed].Write(Glyph.Solid);
                        }
                        else
                        {
                            terminal[-10 + i, 0][TermColor.DarkGray].Write(Glyph.Gray);
                        }
                    }
                }

                // draw its description
                CharacterString text = new CharacterString(monster.GetDescription(mHero), TermColor.LightGray, TermColor.Black);

                int y = 1;
                foreach (CharacterString line in text.WordWrap(terminal.Size.X))
                {
                    // bail if we run out of room
                    if (y >= terminal.Size.Y)
                    {
                        break;
                    }

                    terminal[0, y++].Write(line);
                }
            }
        }
Exemplo n.º 3
0
        private Character GetTileCharacter(Vec dungeonTile)
        {
            if (mGame.Dungeon.Bounds.Contains(dungeonTile))
            {
                Tile tile = mGame.Dungeon.Tiles[dungeonTile];

                // effects and entities must be on a visible tile
                if (tile.IsVisible)
                {
                    Effect effect = mGame.Effects.GetAt(dungeonTile);
                    if (effect != null)
                    {
                        // show the effect
                        return(GameArt.Get(effect));
                    }

                    // entities must be a on a lit tile
                    if (tile.IsLit)
                    {
                        Entity entity = mGame.Dungeon.Entities.GetAt(dungeonTile);
                        if (entity != null)
                        {
                            // show the entity
                            return(GameArt.Get(entity));
                        }
                    }
                }

                // items must be seen
                if (tile.IsExplored)
                {
                    Item item = mGame.Dungeon.Items.GetAt(dungeonTile);

                    if (item != null)
                    {
                        return(GameArt.Get(item));
                    }
                }

                // no entity, so show the dungeon tile
                return(GameArt.Get(tile));
            }

            // outside the dungeon
            return(new Character(Glyph.Space));
        }
Exemplo n.º 4
0
        private void PaintItem(int index, Item item)
        {
            Vec pos = new Vec(0, index) + 1;

            ITerminal terminal = Terminal;

            if (IsChoosable(item))
            {
                // hilight the item since it is choosable
                terminal[pos][TermColor.White].Write(GetKey(index));
                terminal[pos.OffsetX(1)][TermColor.Yellow].Write(Glyph.TriangleRight);
            }
            else
            {
                // don't hilight the item since it can't be chosen
                terminal[pos][TermColor.DarkGray].Write(GetKey(index));

                if (item != null)
                {
                    terminal[pos.OffsetX(1)][TermColor.DarkGray].Write(Glyph.TriangleRight);
                }
            }

            if (item != null)
            {
                // show the item in the slot
                terminal[pos.OffsetX(2)].Write(GameArt.Get(item));

                TermColor itemColor;
                TermColor priceColor;

                if (!HasFocus || IsChoosable(item))
                {
                    itemColor = TermColor.White;
                }
                else
                {
                    itemColor = TermColor.DarkGray;
                }

                if (IsChoosable(item))
                {
                    priceColor = (mViewing == Viewing.Store) ? TermColor.Green : TermColor.Gold;
                }
                else
                {
                    priceColor = (mViewing == Viewing.Store) ? TermColor.DarkGreen : TermColor.DarkGold;
                }

                terminal[pos.OffsetX(4)][itemColor].Write(item.ToString());

                // show its price
                if (mStore != null)
                {
                    int price;
                    if (mViewing == Viewing.Store)
                    {
                        price = mStore.GetBuyPrice(mGame.Hero, item);
                    }
                    else
                    {
                        price = mStore.GetSellPrice(mGame.Hero, item);
                    }

                    terminal[new Vec(-9, pos.Y)][priceColor].Write(price.ToString("n0").PadLeft(8, ' '));
                }
            }
            else
            {
                // no item in the slot, so show the category of item that can go there
                terminal[pos.OffsetX(4)][TermColor.DarkGray].Write(Items.GetCategory(index));
            }
        }
Exemplo n.º 5
0
        protected override void OnPaint(ITerminal terminal)
        {
            terminal.Clear();

            const int StrikeX = 3;
            const int DamageX = 9;
            const int DodgeX  = 16;
            const int ArmorX  = 23;
            const int ElemX   = 27;
            const int StatX   = 32;
            const int ResistX = 51;
            const int LabelX  = 80;

            // draw the table
            terminal[0, 0, 80, 28][TermColor.DarkGray].DrawBox();
            terminal[31, 0, 1, 28][TermColor.DarkGray].DrawBox(DrawBoxOptions.DoubleLines);
            terminal[50, 0, 1, 28][TermColor.DarkGray].DrawBox(DrawBoxOptions.DoubleLines);

            terminal[31, 0][TermColor.DarkGray].Write(Glyph.BarDoubleDownSingleLeftRight);
            terminal[50, 0][TermColor.DarkGray].Write(Glyph.BarDoubleDownSingleLeftRight);
            terminal[31, 27][TermColor.DarkGray].Write(Glyph.BarDoubleUpSingleLeftRight);
            terminal[50, 27][TermColor.DarkGray].Write(Glyph.BarDoubleUpSingleLeftRight);

            // write the header
            terminal[14, 0][TermColor.Gray].Write("Melee");
            terminal[39, 0][TermColor.Gray].Write("Stats");
            terminal[60, 0][TermColor.Gray].Write("Resistances");

            terminal[1, 1].Write("Strike Damage Dodge Armor Elem");
            terminal[StatX, 1].Write("StrAgiStaWilIntCha");

            // write the elements in color
            int x = ResistX;

            foreach (Element element in Enum.GetValues(typeof(Element)))
            {
                terminal[x, 1][GameArt.GetColor(element)].Write(GameArt.GetAbbreviation2(element));
                x += 2;
            }

            int y = 2;

            DrawRowLine(terminal, y++);

            // write the base values
            terminal[LabelX, y].Write("Base");

            // melee
            terminal[StrikeX, y].Write(" 0");
            terminal[DamageX, y].Write("x1.0");
            terminal[DodgeX, y].Write(Hero.DodgeBase.ToString());
            terminal[ArmorX, y].Write(" 0");
            terminal[ElemX, y][GameArt.GetColor(Element.Anima)].Write(GameArt.GetAbbreviation4(Element.Anima));

            // stats
            x = StatX;
            foreach (Stat stat in mHero.Stats)
            {
                terminal[x, y].Write(stat.Base.ToString().PadLeft(2));
                x += 3;
            }

            // resists
            terminal[ResistX, y].Write("0 0 0 0 0 0 0 0 0 0 0 0 0 0");

            y++;

            DrawRowLine(terminal, y++);

            // draw the equipment
            for (int i = 0; i < mHero.Equipment.Count; i++)
            {
                Item item = mHero.Equipment[i];

                if (item != null)
                {
                    terminal[LabelX, y].Write(item.ToString());
                }
                else
                {
                    terminal[LabelX, y][TermColor.DarkGray].Write(mHero.Equipment.GetCategory(i));
                }

                // melee stats
                if (item != null)
                {
                    // strike
                    WriteBonus(terminal, StrikeX, y, item.StrikeBonus);

                    // damage
                    float bonus = item.DamageBonus;
                    if (bonus < 1.0f)
                    {
                        terminal[DamageX, y][TermColor.Red].Write("x" + bonus.ToString("F2"));
                    }
                    else if (bonus == 1.0f)
                    {
                        terminal[DamageX, y][TermColor.DarkGray].Write("  -  ");
                    }
                    else
                    {
                        terminal[DamageX, y][TermColor.Green].Write("x" + bonus.ToString("F2"));
                    }

                    // dodge
                    terminal[DodgeX + 1, y][TermColor.DarkGray].Write(Glyph.Dash);

                    // armor
                    TermColor color = TermColor.White;
                    if (item.ArmorBonus < 0)
                    {
                        color = TermColor.Red;
                    }
                    else if (item.ArmorBonus > 0)
                    {
                        color = TermColor.Green;
                    }
                    else if (item.TotalArmor == 0)
                    {
                        color = TermColor.DarkGray;
                    }

                    if (item.TotalArmor < 0)
                    {
                        terminal[ArmorX, y][color].Write(Glyph.ArrowDown);
                        terminal[ArmorX + 1, y][color].Write(Math.Abs(item.TotalArmor).ToString());
                    }
                    else if (item.TotalArmor == 0)
                    {
                        terminal[ArmorX + 1, y][color].Write(Glyph.Dash);
                    }
                    else
                    {
                        terminal[ArmorX, y][color].Write(Glyph.ArrowUp);
                        terminal[ArmorX + 1, y][color].Write(item.TotalArmor.ToString());
                    }

                    // element
                    if (item.Attack != null)
                    {
                        Element element = item.Attack.Element;
                        terminal[ElemX, y][GameArt.GetColor(element)].Write(GameArt.GetAbbreviation4(element));
                    }
                }

                // stat bonuses
                x = StatX;
                foreach (Stat stat in mHero.Stats)
                {
                    if (item != null)
                    {
                        WriteBonus(terminal, x, y, item.GetStatBonus(stat));
                    }
                    x += 3;
                }

                // resists
                x = ResistX;
                foreach (Element element in Enum.GetValues(typeof(Element)))
                {
                    if (item != null)
                    {
                        if (item.Resists(element))
                        {
                            terminal[x, y][TermColor.Green].Write(Glyph.ArrowUp);
                        }
                        else
                        {
                            terminal[x, y][TermColor.DarkGray].Write(Glyph.Dash);
                        }
                    }
                    x += 2;
                }

                y++;
            }

            DrawRowLine(terminal, y++);

            // draw the stats
            foreach (Stat stat in mHero.Stats)
            {
                terminal[LabelX, y].Write(stat.Name);

                // melee bonuses

                // strike
                if (stat == mHero.Stats.Agility)
                {
                    WriteBonus(terminal, StrikeX, y, mHero.Stats.Agility.StrikeBonus);
                }

                // damage
                if (stat == mHero.Stats.Strength)
                {
                    float bonus = mHero.Stats.Strength.DamageBonus;
                    if (bonus < 1.0f)
                    {
                        terminal[DamageX, y][TermColor.Red].Write("x" + bonus.ToString("F1"));
                    }
                    else if (bonus == 1.0f)
                    {
                        terminal[DamageX, y][TermColor.DarkGray].Write("  -  ");
                    }
                    else
                    {
                        terminal[DamageX, y][TermColor.Green].Write("x" + bonus.ToString("F1"));
                    }
                }

                // dodge
                if (stat == mHero.Stats.Agility)
                {
                    WriteBonus(terminal, DodgeX, y, mHero.Stats.Agility.StrikeBonus);
                }

                // armor

                y++;
            }

            DrawRowLine(terminal, y++);

            terminal[LabelX, y].Write("Total");

            // melee totals
            if (mHero.MeleeStrikeBonus < 0)
            {
                terminal[StrikeX, y][TermColor.Red].Write(mHero.MeleeStrikeBonus.ToString());
            }
            else if (mHero.MeleeStrikeBonus == 0)
            {
                terminal[StrikeX + 1, y][TermColor.DarkGray].Write(Glyph.Digit0);
            }
            else
            {
                terminal[StrikeX, y][TermColor.Green].Write(Glyph.Plus);
                terminal[StrikeX + 1, y][TermColor.Green].Write(mHero.MeleeStrikeBonus.ToString());
            }

            // damage
            if (mHero.MeleeDamageBonus < 1.0f)
            {
                terminal[DamageX, y][TermColor.Red].Write("x" + mHero.MeleeDamageBonus.ToString("F1"));
            }
            else if (mHero.MeleeDamageBonus == 1.0f)
            {
                terminal[DamageX, y][TermColor.DarkGray].Write("x" + mHero.MeleeDamageBonus.ToString("F1"));
            }
            else
            {
                terminal[DamageX, y][TermColor.Green].Write("x" + mHero.MeleeDamageBonus.ToString("F1"));
            }

            // dodge
            if (mHero.GetDodge() < Hero.DodgeBase)
            {
                terminal[DodgeX, y][TermColor.Red].Write(mHero.GetDodge().ToString());
            }
            else
            {
                terminal[DodgeX, y].Write(mHero.GetDodge().ToString());
            }

            // armor
            if (mHero.Armor < 0)
            {
                terminal[ArmorX, y][TermColor.Red].Write(mHero.Armor.ToString());
            }
            else if (mHero.Armor == 0)
            {
                terminal[ArmorX + 1, y][TermColor.DarkGray].Write("0");
            }
            else
            {
                terminal[ArmorX + 1, y][TermColor.Green].Write(mHero.Armor.ToString());
            }

            // stat totals
            x = StatX;
            foreach (Stat stat in mHero.Stats)
            {
                if (stat.IsLowered)
                {
                    terminal[x, y][TermColor.Red].Write(stat.Current.ToString().PadLeft(2));
                }
                else if (stat.IsRaised)
                {
                    terminal[x, y][TermColor.Green].Write(stat.Current.ToString().PadLeft(2));
                }
                else
                {
                    terminal[x, y].Write(stat.Current.ToString().PadLeft(2));
                }
                x += 3;
            }

            // resistance totals
            x = ResistX;
            foreach (Element element in Enum.GetValues(typeof(Element)))
            {
                int resists = mHero.GetNumResists(element);

                if (resists == 0)
                {
                    terminal[x, y].Write(Glyph.Digit0);
                }
                else
                {
                    terminal[x, y][TermColor.Green].Write(resists.ToString());
                }
                x += 2;
            }

            // element
            Element attackElement = Element.Anima;
            Item    weapon        = mHero.Equipment.MeleeWeapon;

            if (weapon != null)
            {
                if (weapon.Attack != null)
                {
                    attackElement = weapon.Attack.Element;
                }
            }
            terminal[ElemX, y][GameArt.GetColor(attackElement)].Write(GameArt.GetAbbreviation4(attackElement));

            y += 2;
            terminal[1, y].Write("A total armor of " + mHero.Armor + " reduces damage by " + (100 - (int)(100.0f * Entity.GetArmorReduction(mHero.Armor))) + "%.");
        }