Пример #1
0
    /// <summary>
    /// Replaces text and such with what would happen if the skill was upgraded
    /// </summary>
    /// <param name="allyGrim">Grimoire of the selected</param>
    /// <param name="previewMagicStat">The amount the magic will potentially increase</param>
    public void PreviewSkillUpgrade(AllyGrimoire allyGrim, int amountIncrease)
    {
        // Default values
        string skillName        = " None";
        string skillDescription = "Upgrade magic to gain a skill";
        int    skillDmg         = 0;
        int    skillRange       = 0;
        int    skillCooldown    = 0;
        Sprite skillIcon        = null;

        // For if the values were changed at all
        bool isSkillNameBuff     = false;
        bool isSkillDmgBuff      = false;
        bool isSkillRangeBuff    = false;
        bool isSkillCooldownBuff = false;

        // Get the starting values for the skill
        AllySkillController skillContRef = allyGrim.GetComponent <AllySkillController>();

        if (skillContRef != null)
        {
            Skill activeSkill = skillContRef.SpecialSkill;
            if (activeSkill != null)
            {
                skillName        = " " + SkillHolder.GetSkillName(activeSkill.GetSkillNum());
                skillDescription = SkillHolder.GetSkillDescription(activeSkill.GetSkillNum());
                skillIcon        = SkillHolder.GetSkillImage(activeSkill.GetSkillNum());
                skillDmg         = activeSkill.GetDamage();
                skillRange       = activeSkill.GetRange();
                skillCooldown    = activeSkill.GetCoolDown();
            }


            // Iterate over the buffs
            for (int i = 1; i <= amountIncrease; ++i)
            {
                // Get the next buff
                MagicBuff nextBuff = allyGrim.PeekForward(i);

                switch (nextBuff)
                {
                // If the next buff is to acquire a skill, get that skill and set the defaults
                case (MagicBuff.SKILLACQ):
                    // We are going to temporarily give this character the skill in question to get the starting values
                    Skill gainSkill = _skillHolderRef.GiveSkill(skillContRef, allyGrim.SkillToGain);

                    skillName        = " " + SkillHolder.GetSkillName(allyGrim.SkillToGain);
                    skillDescription = SkillHolder.GetSkillDescription(allyGrim.SkillToGain);
                    skillIcon        = SkillHolder.GetSkillImage(allyGrim.SkillToGain);
                    skillDmg         = gainSkill.GetDamage();
                    skillRange       = gainSkill.GetRange();
                    skillCooldown    = gainSkill.GetCoolDown();

                    isSkillNameBuff     = true;
                    isSkillDmgBuff      = true;
                    isSkillRangeBuff    = true;
                    isSkillCooldownBuff = true;

                    // Get rid of the temporary skill
                    Destroy(gainSkill);
                    break;

                // If the next buff is just an increment, increment them
                case (MagicBuff.DMGINC):
                    ++skillDmg;
                    isSkillDmgBuff = true;
                    break;

                case (MagicBuff.RANGEINC):
                    isSkillRangeBuff = true;
                    ++skillRange;
                    break;

                case (MagicBuff.COOLLWR):
                    isSkillCooldownBuff = true;
                    --skillCooldown;
                    break;

                default:
                    Debug.Log("Unhandled MagicBuff in SkillPreviewController");
                    break;
                }
            }
            // Set the values
            _skillNameText.text        = skillName;
            _skillDescriptionText.text = skillDescription;
            _skillIconImage.sprite     = skillIcon;
            if (skillIcon == null)
            {
                _skillIconImage.color = new Color(0, 0, 0, 0);
            }
            else
            {
                _skillIconImage.color = new Color(1, 1, 1, 1);
            }
            _skillDmgText.text      = skillDmg.ToString();
            _skillRangeText.text    = skillRange.ToString();
            _skillCooldownText.text = skillCooldown.ToString();
            // Set the ones that were buffed to green
            if (isSkillNameBuff)
            {
                _skillNameText.color = CharDetailedMenuController.UpgradeTextCol;
            }
            if (isSkillDmgBuff)
            {
                _skillDmgText.color = CharDetailedMenuController.UpgradeTextCol;
            }
            if (isSkillRangeBuff)
            {
                _skillRangeText.color = CharDetailedMenuController.UpgradeTextCol;
            }
            if (isSkillCooldownBuff)
            {
                _skillCooldownText.color = CharDetailedMenuController.UpgradeTextCol;
            }
        }
    }