Ejemplo n.º 1
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);
                }
            }
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
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));
            }
        }