コード例 #1
0
ファイル: MessagePanel.cs プロジェクト: jzhang113/GeomaceRL
        public void Draw(LayerInfo layer)
        {
            // draw borders
            Terminal.Color(Colors.BorderColor);
            layer.DrawBorders(new BorderInfo
            {
                TopLeftChar  = '┤',
                TopRightChar = '│',
                LeftChar     = '│',
                RightChar    = '│'
            });

            Terminal.Color(Colors.Text);
            Terminal.Font("message");

            // draw messages
            int maxCount = Math.Min(_messages.Count, layer.Height);
            int yPos     = layer.Height - 1;

            for (int i = 0; i < maxCount; i++)
            {
                layer.Print(yPos, _messages[_messages.Count - i - 1]);
                yPos--;
            }

            Terminal.Font("");
        }
コード例 #2
0
        public static void Draw(LayerInfo layer)
        {
            // draw borders, right border will be fixed at the end
            Terminal.Color(Colors.BorderColor);
            layer.DrawBorders(new BorderInfo
            {
                TopLeftChar    = '├',
                BottomLeftChar = '┴',
                TopChar        = '─',
                BottomChar     = '─',
                LeftChar       = '│'
            });

            const int boxWidth = 7;
            int       casting  = -1;

            Game.StateHandler.Peek().MatchSome(state =>
            {
                if (state is TargettingState targetting)
                {
                    casting = targetting.CurrentSpell;
                }
            });

            for (int x = 0; x < Constants.MAX_SPELLS; x++)
            {
                int startX = boxWidth * x;
                int endX   = boxWidth * (x + 1) - 1;

                if (x < Game.Player.SpellList.Count)
                {
                    ISpell spell = Game.Player.SpellList[x];
                    (int minMainCost, int maxMainCost) = spell.Cost.MainCost;
                    int minAltCost = spell.Cost.AltCost.Item1;

                    Terminal.Color(casting == x ? Colors.HighlightColor : Colors.Text);
                    string firstLine = $"{(char)(x + '1')} {spell.Abbrev}";
                    firstLine += spell.Abbrev.Length == 1 ? "  " : " ";
                    firstLine += spell.Charges > 0 ? spell.Charges.ToString() : "-";

                    layer.Print(
                        new Rectangle(startX, 0, boxWidth - 1, 1),
                        firstLine,
                        ContentAlignment.TopLeft);

                    DisplayManaCost(layer, startX, 1, spell.Cost.MainElem.Color(), spell.Cost.MainCost, spell.Cost.MainManaUsed());
                    DisplayManaCost(layer, startX, 2, spell.Cost.AltElem.Color(), spell.Cost.AltCost, spell.Cost.AltManaUsed());
                }
                else
                {
                    Terminal.Color(Colors.Text);
                    Terminal.Font("text");
                    layer.Put(startX, 0, x + '1');
                    Terminal.Font("");
                }

                Terminal.Color(Colors.BorderColor);
                for (int y = 0; y < layer.Height; y++)
                {
                    layer.Put(endX, y, '║');
                }
                layer.Put(endX, -1, '╥');
                layer.Put(endX, layer.Height, '╨');
            }

            // fix right border
            for (int y = 0; y < layer.Height; y++)
            {
                layer.Put(layer.Width, y, '│');
            }
            layer.Put(layer.Width, -1, '┤');
            layer.Put(layer.Width, layer.Height, '┘');
        }