Esempio n. 1
0
        public string GetReputationRewardText(Location currLocation)
        {
            List <string> reputationRewardTexts = new List <string>();

            foreach (var reputationReward in ReputationRewards)
            {
                string name = "";

                if (reputationReward.Key.Equals("location", StringComparison.OrdinalIgnoreCase))
                {
                    name = $"‖color:gui.orange‖{currLocation.Name}‖end‖";
                }
                else
                {
                    var faction = FactionPrefab.Prefabs.Find(f => f.Identifier.Equals(reputationReward.Key, StringComparison.OrdinalIgnoreCase));
                    if (faction != null)
                    {
                        name = $"‖color:{XMLExtensions.ColorToString(faction.IconColor)}‖{faction.Name}‖end‖";
                    }
                    else
                    {
                        name = TextManager.Get(reputationReward.Key);
                    }
                }
                float  normalizedValue = MathUtils.InverseLerp(-100.0f, 100.0f, reputationReward.Value);
                string formattedValue  = ((int)reputationReward.Value).ToString("+#;-#;0"); //force plus sign for positive numbers
                string rewardText      = TextManager.GetWithVariables(
                    "reputationformat",
                    new string[] { "[reputationname]", "[reputationvalue]" },
                    new string[] { name, $"‖color:{XMLExtensions.ColorToString(Reputation.GetReputationColor(normalizedValue))}‖{formattedValue}‖end‖" });
                reputationRewardTexts.Add(rewardText);
            }
            return(TextManager.AddPunctuation(':', TextManager.Get("reputation"), string.Join(", ", reputationRewardTexts)));
        }
Esempio n. 2
0
        public static void DrawReputationBar(SpriteBatch sb, Rectangle rect, float normalizedReputation)
        {
            int segmentWidth = rect.Width / 5;

            rect.Width = segmentWidth * 5;
            for (int i = 0; i < 5; i++)
            {
                GUI.DrawRectangle(sb, new Rectangle(rect.X + (segmentWidth * i), rect.Y, segmentWidth, rect.Height), Reputation.GetReputationColor(i / 5.0f), isFilled: true);
                GUI.DrawRectangle(sb, new Rectangle(rect.X + (segmentWidth * i), rect.Y, segmentWidth, rect.Height), GUI.Style.ColorInventoryBackground, isFilled: false);
            }
            GUI.DrawRectangle(sb, rect, GUI.Style.ColorInventoryBackground, isFilled: false);

            GUI.Arrow.Draw(sb, new Vector2(rect.X + rect.Width * normalizedReputation, rect.Y), GUI.Style.ColorInventoryBackground, scale: GUI.Scale, spriteEffect: SpriteEffects.FlipVertically);
            GUI.Arrow.Draw(sb, new Vector2(rect.X + rect.Width * normalizedReputation, rect.Y), GUI.Style.TextColor, scale: GUI.Scale * 0.8f, spriteEffect: SpriteEffects.FlipVertically);

            GUI.DrawString(sb, new Vector2(rect.X, rect.Bottom), "-100", GUI.Style.TextColor, font: GUI.SmallFont);
            Vector2 textSize = GUI.SmallFont.MeasureString("100");

            GUI.DrawString(sb, new Vector2(rect.Right - textSize.X, rect.Bottom), "100", GUI.Style.TextColor, font: GUI.SmallFont);
        }