Esempio n. 1
0
        private void DrawDescription(SpriteBatch spriteBatch, AbilityDefinition ability)
        {
            DoTariaPlayer doTariaPlayer = DoTariaPlayer.Get(Main.LocalPlayer);
            PlayerAbility currentPlayerAbility;

            if (doTariaPlayer.HasAbility(ability))
            {
                currentPlayerAbility = doTariaPlayer.GetPlayerAbility(ability);
            }
            else
            {
                currentPlayerAbility = new PlayerAbility(ability, 1, 0);
            }

            int
                panelWidth  = 300,
                panelHeight = 34;

            Vector2 position = Main.MouseWorld + new Vector2(Main.cursorTextures[0].Width, Main.cursorTextures[0].Height * 2) - Main.screenPosition;

            StringBuilder description = new StringBuilder("Ability: ");


            if (ability.AbilityTargetType == AbilityTargetType.NoTarget && ability.AbilityType == AbilityType.Passive)
            {
                description.Append(ability.AbilityType);
            }
            else
            {
                description.Append(ability.AbilityTargetType.ToString().AddSpaceBeforeCapitals());
            }

            description.AppendLine();

            if (ability.AbilityTargetUnitType != AbilityTargetUnitType.None)
            {
                description.Append("Affects: ");

                if (!(ability.AbilityTargetUnitFaction == AbilityTargetFaction.Self || ability.AbilityTargetUnitFaction == (AbilityTargetFaction.Enemies & AbilityTargetFaction.Allies)))
                {
                    description.Append(ability.AbilityTargetUnitFaction).Append(" ");
                }

                description.Append(ability.AbilityTargetUnitType.ToString().AddSpaceBeforeCapitals()).AppendLine();
            }

            description.Append(ability.GetAbilityTooltip(doTariaPlayer, currentPlayerAbility));

            DispelType dispelType = ability.GetDispelType(doTariaPlayer, currentPlayerAbility);

            if (dispelType != DispelType.None)
            {
                description.AppendLine().Append("Dispel type: ").Append(dispelType.ToString()).Append(" Dispel");
            }

            description.AppendLine();
            string finaliziedDescription = SpliceText(description.ToString(), 34);

            panelHeight += finaliziedDescription.Split('\n').Length * 26;

            spriteBatch.Draw(Main.magicPixel, position, new Rectangle(0, 0, panelWidth, panelHeight), Color.Black * 0.75f, 0f, Vector2.Zero, 1f, SpriteEffects.None, 1f);
            spriteBatch.Draw(Main.magicPixel, position + new Vector2(2, 2), new Rectangle(0, 0, panelWidth - 4, 32), Color.Gray * 0.75f, 0f, Vector2.Zero, 1f, SpriteEffects.None, 1f);
            spriteBatch.DrawString(Main.fontMouseText, ability.DisplayName, position + new Vector2(6, 8), Color.White);
            spriteBatch.DrawString(Main.fontMouseText, "Level: " + CurrentLevel, position + new Vector2(panelWidth - 56, 12), Color.White, 0, Vector2.Zero, 0.75f, SpriteEffects.None, 1f);

            spriteBatch.DrawString(Main.fontMouseText, finaliziedDescription, position + new Vector2(10, 40), Color.Gray, 0, Vector2.Zero, 0.85f, SpriteEffects.None, 1f);

            Texture2D manacostTexture = DoTariaMod.Instance.GetTexture("UserInterfaces/Abilities/ManacostIcon");
            Texture2D cooldownTexture = DoTariaMod.Instance.GetTexture("UserInterfaces/Abilities/CooldownIcon");

            Func <DoTariaPlayer, PlayerAbility, float> cooldownGetter = (player, playerAbility) => (float)Math.Round((double)playerAbility.Ability.InternalGetCooldown(player, playerAbility), 2);

            List <float> differentCooldowns = AbilitiesHelper.GetDifferentValues(cooldownGetter, doTariaPlayer, ability);

            if (!(differentCooldowns.Count == 1 && differentCooldowns[0] == 0f))
            {
                spriteBatch.Draw(cooldownTexture, position + new Vector2(10, panelHeight - 22), null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 1f);
                spriteBatch.DrawString(Main.fontMouseText,
                                       AbilitiesHelper.GenerateCleanSlashedString(AbilitiesHelper.GetAllValues((player, pAbility) => (float)Math.Round((double)pAbility.Ability.InternalGetCooldown(player, pAbility), 2),
                                                                                                               doTariaPlayer, ability), differentCooldowns), position + new Vector2(30, panelHeight - 24), Color.Gray);
            }

            if (ability.AbilityType == AbilityType.Active)
            {
                spriteBatch.Draw(manacostTexture, position + new Vector2(panelWidth / 2, panelHeight - 22), null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 1f);
                spriteBatch.DrawString(Main.fontMouseText, AbilitiesHelper.GenerateCleanSlashedString((player, playerAbility) => (float)Math.Ceiling(playerAbility.Ability.InternalGetManaCost(player, playerAbility)), doTariaPlayer, ability),
                                       position + new Vector2(panelWidth / 2 + 20, panelHeight - 24), Color.Gray);
            }
        }