Exemplo n.º 1
0
    // this is the pure event, with no modifications applied prior
    public void Damage(Projectile p_projectile, IDamageable p_damageable)
    {
        int finalDamage = p_projectile.m_info.m_damage;

        finalDamage += m_entity.m_stats.GetStatEffect((Stats)Enum.Parse(typeof(Stats), p_projectile.m_info.m_statApplied));
        p_damageable.OnDamage(this, DamageType.Get(p_projectile.m_info.m_damageType), finalDamage, p_projectile.m_info.m_armorPiercing, false);
    }
Exemplo n.º 2
0
    public void SetAbilitySkill(AbilitySkillWrapper p_wrapper)
    {
        if (m_modifiableInfo.Count == 0)
        {
            FillModifiableInfo();
        }

        foreach (TooltipInfo info in m_modifiableInfo)
        {
            info.m_info.SetActive(false);
        }

        m_panelHeight       = m_tooltipBorderSize * 2 + 12;
        m_tooltipInfoOffset = -(m_panelHeight / 2);
        Ability ability = p_wrapper.AbilityWrapper != null?p_wrapper.AbilityWrapper.GetAbility() : null;

        Skill skill = p_wrapper.SkillWrapper != null?p_wrapper.SkillWrapper.GetSkill() : null;

        DamageType type = ability != null?DamageType.Get(ability.m_domain) : null;

        TextMeshProUGUI name = m_modifiableInfo.Find(ti => ti.m_name == "AbilitySkill Name Text")
                               .Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset);

        name.text  = Get(p_wrapper.GetDisplayName());
        name.color = ability != null ? type.m_nameColor.Value : skill.m_nameColor.Value;

        if (ability != null)
        {
            TextMeshProUGUI domain = m_modifiableInfo.Find(ti => ti.m_name == "Domain Text").GetAligned <TextMeshProUGUI>(ref m_tooltipInfoOffset);
            domain.text  = Get(ability.m_domain);
            domain.color = type.m_nameColor.Value;

            TextMeshProUGUI active = m_modifiableInfo.Find(ti => ti.m_name == "Active Text")
                                     .Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset);
            active.text = Get(ability.m_isPassive ? "Passive" : "Active");
        }

        ShowSeparator(1);

        string prefixColorTag = "<color=#" + ColorUtility.ToHtmlStringRGBA(Constants.YELLOW) + ">";
        string suffixColorTag = "</color>";

        TextMeshProUGUI trainingLevel = m_modifiableInfo.Find(ti => ti.m_name == "Training Level")
                                        .Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset);

        trainingLevel.text = Game.m_languages.FormatTexts(Get("Training Level: {0}"), prefixColorTag + p_wrapper.GetTrainingLevel().ToString() + suffixColorTag);

        if (p_wrapper.GetTrainingLevel() < p_wrapper.GetMaxTrainingLevel())
        {
            TextMeshProUGUI expToNextLevel = m_modifiableInfo.Find(ti => ti.m_name == "Training Exp Next Level")
                                             .Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset);
            expToNextLevel.text = Game.m_languages.FormatTexts(Get("EXP to next level: {0}"),
                                                               prefixColorTag + p_wrapper.GetTrainingExpCost(p_wrapper.GetTrainingLevel() + 1).ToString() + suffixColorTag);
        }

        if (ability != null && p_wrapper.Learned())
        {
            TextMeshProUGUI cd = m_modifiableInfo.Find(ti => ti.m_name == "Cooldown").Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset);
            cd.text = Game.m_languages.FormatTexts(Get("{0}s cooldown"),
                                                   prefixColorTag + p_wrapper.GetCooldown(p_wrapper.GetTrainingLevel()).ToString() + suffixColorTag);
        }

        ShowSeparator(2);

        TextMeshProUGUI sellPrice = m_modifiableInfo.Find(ti => ti.m_name == "Sell Price").Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset);

        sellPrice.text  = Game.m_languages.FormatTexts(Get("Sell Price: {0}g"), prefixColorTag + p_wrapper.GetSellPrice() + suffixColorTag);
        sellPrice.color = Constants.WHITE;

        TooltipInfo     descInfo    = m_modifiableInfo.Find(ti => ti.m_name == "Item Description Text");
        TextMeshProUGUI description = descInfo.Get <TextMeshProUGUI>();

        description.text     = p_wrapper.GetDescription(p_wrapper.GetTrainingLevel(), true);
        description.color    = Constants.YELLOW;
        m_tooltipInfoOffset += description.rectTransform.rect.y;

        Show(m_panelHeight, true);         // activating the description to allow the preferred height to be fetched

        float descPrefHeight = LayoutUtility.GetPreferredHeight(description.rectTransform);

        m_tooltipInfoOffset += descPrefHeight / 2;

        description = descInfo.Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset, descPrefHeight);

        Show(m_panelHeight, false);         // resizing the panel again to fit
    }
Exemplo n.º 3
0
    private void ShowShotPattern(float p_shotNumber, ShotPattern p_pattern, ref float p_panelHeight)
    {
        string shot           = "Shot " + p_shotNumber;
        string prefixColorTag = "<color=#" + ColorUtility.ToHtmlStringRGBA(Constants.YELLOW) + ">";
        string suffixColorTag = "</color>";

        TextMeshProUGUI cd = m_modifiableInfo.Find(ti => ti.m_name == shot + " CD").GetAligned <TextMeshProUGUI>(ref m_tooltipInfoOffset);

        cd.text  = Game.m_languages.FormatTexts(Get("{0}s cooldown"), prefixColorTag + p_pattern.m_patternCooldown.ToString() + suffixColorTag);
        cd.color = Constants.WHITE;

        string statColor = ColorUtility.ToHtmlStringRGBA(((Stats)Enum.Parse(typeof(Stats), p_pattern.m_projectileInfo.m_statApplied)).GetColor());

        m_modifiableInfo.Find(ti => ti.m_name == shot + " Label").Get <TextMeshProUGUI>(ref p_panelHeight, ref m_tooltipInfoOffset).text =
            Game.m_languages.FormatTexts(Get("Shot {0}"), p_shotNumber.ToString()) +
            " (+<color=#" + statColor + ">" +
            p_pattern.m_projectileInfo.m_statApplied.ToString() + "</color>)";

        if (p_pattern.m_projectileInfo.m_piercing)
        {
            m_modifiableInfo.Find(ti => ti.m_name == shot + " Piercing Text").GetAligned <TextMeshProUGUI>(ref m_tooltipInfoOffset).color = Constants.PURPLE;
        }

        m_modifiableInfo.Find(ti => ti.m_name == shot + " Background").GetAligned <Image>(ref m_tooltipInfoOffset);
        Image shotSprite = m_modifiableInfo.Find(ti => ti.m_name == shot + " Sprite").Get <Image>();

        shotSprite.sprite = Projectile.Get(p_pattern.m_projectile).GetComponent <SpriteRenderer>().sprite;

        TextMeshProUGUI shots = m_modifiableInfo.Find(ti => ti.m_name == shot + " Shots").Get <TextMeshProUGUI>(ref p_panelHeight, ref m_tooltipInfoOffset);

        shots.text  = Game.m_languages.FormatTexts(Get("Shots: {0}"), prefixColorTag + p_pattern.m_shots.ToString() + suffixColorTag);
        shots.color = Constants.WHITE;

        if (p_pattern.m_projectileInfo.m_armorPiercing)
        {
            m_modifiableInfo.Find(ti => ti.m_name == shot + " Armor Piercing Text")
            .GetAligned <TextMeshProUGUI>(ref m_tooltipInfoOffset).color = Constants.RED;
        }

        TextMeshProUGUI damage = m_modifiableInfo.Find(ti => ti.m_name == shot + " Damage").Get <TextMeshProUGUI>(ref p_panelHeight, ref m_tooltipInfoOffset);

        damage.text  = Game.m_languages.FormatTexts(Get("Damage: {0}"), prefixColorTag + p_pattern.m_projectileInfo.m_damage.ToString() + suffixColorTag);
        damage.color = Constants.WHITE;

        Sprite damageTypeIcon = DamageType.Get(p_pattern.m_projectileInfo.m_damageType).m_icon;

        if (damageTypeIcon)
        {
            Image damageType = m_modifiableInfo.Find(ti => ti.m_name == shot + " DamageType").Get <Image>();
            damageType.sprite = damageTypeIcon;
        }

        TextMeshProUGUI mana = m_modifiableInfo.Find(ti => ti.m_name == shot + " Mana").GetAligned <TextMeshProUGUI>(ref m_tooltipInfoOffset);

        mana.text  = Game.m_languages.FormatTexts(Get("{0} Mana"), p_pattern.m_manaPerStep.ToString());
        mana.color = Constants.MANA_BLUE;

        TextMeshProUGUI range = m_modifiableInfo.Find(ti => ti.m_name == shot + " Range").Get <TextMeshProUGUI>(ref p_panelHeight, ref m_tooltipInfoOffset);

        range.text  = Game.m_languages.FormatTexts(Get("Range: {0}"), prefixColorTag + p_pattern.m_projectileInfo.m_range.ToString() + suffixColorTag);
        range.color = Constants.WHITE;

        if (p_pattern.m_extraTooltipInfo.Length > 0)
        {
            TooltipInfo     extraInfo = m_modifiableInfo.Find(ti => ti.m_name == shot + " Extra Text");
            TextMeshProUGUI extra     = extraInfo.Get <TextMeshProUGUI>();
            extra.text = "";

            float basePrefHeight = LayoutUtility.GetPreferredHeight(extra.rectTransform);

            extra.text  = Get(p_pattern.m_extraTooltipInfo);
            extra.color = Constants.YELLOW;

            float extraPrefHeight = LayoutUtility.GetPreferredHeight(extra.rectTransform);
            if (basePrefHeight != extraPrefHeight)  // multiline
            {
                m_tooltipInfoOffset += extra.rectTransform.rect.y;
                m_tooltipInfoOffset += extraPrefHeight / 1.15f;

                // original 1.7f (pre-tmp)
                extra                = extraInfo.Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset, extraPrefHeight * 1.6f);
                m_panelHeight       -= extraPrefHeight * 1.6f - extraPrefHeight;
                m_tooltipInfoOffset -= extra.rectTransform.rect.y / 2;
            }
            else
            {
                extra = extraInfo.Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset);
            }
        }
    }