예제 #1
0
        private void PrintWeapon(int dX, int dY, CellSurface surface)
        {
            surface.Fill(1, dY, Width - 2, FrameColor, DefaultBackground, Glyphs.GetGlyph('═'));
            surface.Print(0, dY, new ColoredGlyph(Glyphs.GetGlyph('╠'), FrameColor, DefaultBackground));
            surface.Print(Width - 1, dY, new ColoredGlyph(Glyphs.GetGlyph('╣'), FrameColor, DefaultBackground));

            surface.PrintStyledText(dX, dY + 1, new StyledLine
            {
                "Right Hand: ",
                new StyledString(Player.Equipment.RightHandItem.Name, ItemDrawingHelper.GetItemColor(Player.Equipment.RightHandItem))
            }.ToColoredString(DefaultBackground));

            surface.Fill(1, dY + 2, Width - 2, FrameColor, DefaultBackground, Glyphs.GetGlyph('─'));
            surface.Print(0, dY + 2, new ColoredGlyph(Glyphs.GetGlyph('╟'), FrameColor, DefaultBackground));
            surface.Print(Width - 1, dY + 2, new ColoredGlyph(Glyphs.GetGlyph('╢'), FrameColor, DefaultBackground));

            var rightWeaponDetails = GetHoldableDetails(Player.Equipment.RightHandItem);

            for (int yShift = 0; yShift < rightWeaponDetails.Length; yShift++)
            {
                var y = dY + 3 + yShift;
                surface.PrintStyledText(dX, y, rightWeaponDetails[yShift].ToColoredString(DefaultBackground));
            }

            var leftDy = dY + rightWeaponDetails.Length + 4;

            surface.Fill(1, leftDy, Width - 2, FrameColor, DefaultBackground, Glyphs.GetGlyph('═'));
            surface.Print(0, leftDy, new ColoredGlyph(Glyphs.GetGlyph('╠'), FrameColor, DefaultBackground));
            surface.Print(Width - 1, leftDy, new ColoredGlyph(Glyphs.GetGlyph('╣'), FrameColor, DefaultBackground));

            surface.PrintStyledText(dX, leftDy + 1, new StyledLine
            {
                "Left Hand:  ",
                new StyledString(Player.Equipment.LeftHandItem.Name, ItemDrawingHelper.GetItemColor(Player.Equipment.LeftHandItem))
            }.ToColoredString(DefaultBackground));

            surface.Fill(1, leftDy + 2, Width - 2, FrameColor, DefaultBackground, Glyphs.GetGlyph('─'));
            surface.Print(0, leftDy + 2, new ColoredGlyph(Glyphs.GetGlyph('╟'), FrameColor, DefaultBackground));
            surface.Print(Width - 1, leftDy + 2, new ColoredGlyph(Glyphs.GetGlyph('╢'), FrameColor, DefaultBackground));

            var leftWeaponDetails = GetHoldableDetails(Player.Equipment.LeftHandItem);

            for (int yShift = 0; yShift < leftWeaponDetails.Length; yShift++)
            {
                var y = leftDy + 3 + yShift;
                surface.PrintStyledText(dX, y, leftWeaponDetails[yShift].ToColoredString(DefaultBackground));
            }
        }
예제 #2
0
        private void PrintPlayerStats(int dX, int dY, CellSurface surface)
        {
            surface.Print(dX, dY, "Stats:");

            var stats     = Enum.GetValues(typeof(PlayerStats)).Cast <PlayerStats>().ToArray();
            var maxLength = stats.Select(TextHelper.GetStatName).Select(name => name.Length).Max();

            for (var index = 0; index < stats.Length; index++)
            {
                var stat = stats[index];

                var pureValue  = Player.GetPureStat(stat);
                var bonusValue = Player.Equipment.GetStatsBonus(stat);

                var name = TextHelper.GetStatName(stat);

                var y = dY + 2 + index;
                surface.Print(dX, y, name);
                var bonusText = new StyledLine
                {
                    pureValue.ToString()
                };
                if (bonusValue != 0)
                {
                    var bonusSymbol = bonusValue > 0 ? "+" : "-";
                    var bonusColor  = bonusValue > 0 ? TextHelper.PositiveValueColor : TextHelper.NegativeValueColor;
                    bonusText.Add(" (");
                    bonusText.Add($"{bonusSymbol}{bonusValue}", bonusColor);
                    bonusText.Add(")");
                }
                surface.PrintStyledText(dX + maxLength + 1, y, bonusText.ToColoredString(DefaultBackground));
            }

            var xPos = dX + maxLength + 10;

            surface.PrintStyledText(xPos, dY + 2, new StyledLine {
                "Max Health           ", new StyledString(Player.MaxHealth.ToString(), TextHelper.HealthColor)
            }.ToColoredString(DefaultBackground));
            surface.PrintStyledText(xPos, dY + 3, new StyledLine {
                "Max Mana             ", new StyledString(Player.MaxMana.ToString(), TextHelper.ManaColor)
            }.ToColoredString(DefaultBackground));
            surface.PrintStyledText(xPos, dY + 4, new StyledLine {
                "Mana Regeneration    ", new StyledString(Player.ManaRegeneration.ToString(), TextHelper.ManaRegenerationColor)
            }.ToColoredString(DefaultBackground));
            surface.PrintStyledText(xPos, dY + 5, new StyledLine {
                "Dodge Chance         ", $"{Player.DodgeChance}%"
            }.ToColoredString(DefaultBackground));

            surface.PrintStyledText(dX, dY + 4 + stats.Length, new StyledLine {
                $"Level: {Player.Level}"
            }.ToColoredString(DefaultBackground));
            surface.PrintStyledText(dX, dY + 5 + stats.Length, new StyledLine {
                "XP:    ", new StyledString($"{Player.Experience} / {Player.GetXpToLevelUp()}", TextHelper.XpColor)
            }.ToColoredString(DefaultBackground));
        }
예제 #3
0
        public void Draw(CellSurface surface, int y, int maxWidth, bool selected)
        {
            var backColor = selected ? SelectedItemBackColor : DefaultBackColor;

            surface.Fill(0, y, maxWidth, null, backColor, null);

            var text = GetNameText(selected, backColor);

            var afterNameText = new List <ColoredString>();

            if (Stack.TopItem is DurableItem durableItem)
            {
                var durabilityColor = TextHelper.GetDurabilityColor(durableItem.Durability, durableItem.MaxDurability);
                afterNameText.Add(new ColoredString(
                                      new ColoredGlyph(Glyphs.GetGlyph('•'), durabilityColor.ToXna(), backColor)));
            }
            afterNameText.AddRange(GetAfterNameText(backColor));
            var formattedText = FormatText(text, afterNameText.ToArray(), backColor, maxWidth - 1);

            surface.Print(1, y, formattedText);
            surface.PrintStyledText(1 + formattedText.Count, y, afterNameText.ToArray());
            surface.Print(maxWidth - 6, y, new ColoredString(GetWeightText(), WeightColor, backColor));
        }