예제 #1
0
    //public void SetHealthPreview(int currentHealth, int maxHealth, int maxHealthBonus)
    //{
    //    Text healthText = transform.Find("Panel/UnitHealth/Value").GetComponent<Text>();
    //    // display without bonus
    //    healthText.text = currentHealth.ToString() + "/" + maxHealth.ToString();
    //    // show bonuses calculation
    //    healthText.text += "(";
    //    // show original health without bonuses
    //    healthText.text += maxHealth - maxHealthBonus;
    //    // show health bonus
    //    AddBonusInfoToText(healthText, maxHealthBonus, statsBonusPreviewStyleStart, statsBonusPreviewStyleEnd);
    //    healthText.text += ")";
    //    //// verify if max health bonus is not zero (this is possible, when we downgrade to the initial point)
    //    //if (0 == maxHealthBonus)
    //    //{
    //    //    // do not display + info
    //    //    transform.Find("Panel/UnitHealth/Value").GetComponent<Text>().text = currentHealth.ToString() + "/" + maxHealth.ToString();
    //    //}
    //    //else
    //    //{
    //    //    // display + bonus info
    //    //    transform.Find("Panel/UnitHealth/Value").GetComponent<Text>().text = currentHealth.ToString() + "/" + maxHealth.ToString() + statsBonusPreviewStyleStart + maxHealthBonus.ToString() + statsBonusPreviewStyleEnd;
    //    //}
    //}

    public void SetUnitHealthInfo(PartyUnit partyUnit)
    {
        // Get health value text
        Text attributeText = transform.Find("Panel/UnitHealth/Value").GetComponent <Text>();

        // Display effective current and max health
        attributeText.text = partyUnit.UnitHealthCurr.ToString() + "/" + partyUnit.GetUnitEffectiveMaxHealth().ToString();
        // get base max health without stat upgrades
        int baseMaxHealth = partyUnit.UnitHealthMax - GetStatsHealthBonus(partyUnit);

        // verify if effective resistance does not equal base resistance
        if (baseMaxHealth != partyUnit.GetUnitEffectiveMaxHealth())
        {
            // Display how max health is calculated
            // open brackets
            attributeText.text += "(";
            // set default unit health without bonuses
            attributeText.text += baseStatPreviewStyleStart + baseMaxHealth.ToString() + baseStatPreviewStyleEnd;
            // get and add stats bonus to text
            AddBonusInfoToText(attributeText, GetStatsHealthBonus(partyUnit), statsBonusPreviewStyleStart, statsBonusPreviewStyleEnd);
            // get and add items bonus to text
            AddBonusInfoToText(attributeText, partyUnit.GetItemsHealthBonus(), itemBonusPreviewStyleStart, itemBonusPreviewStyleEnd);
            // close brackets
            attributeText.text += ")";
        }
        // Display effective health regeneration per day
        attributeText.text += " " + partyUnit.GetUnitEffectiveHealthRegenPerDay().ToString();
        // add per day indication
        attributeText.text += "/day";
        // get base health regen
        int baseHealthRegen = partyUnit.GetUnitHealthRegenPerDay() - GetUnitStatsBonusHealthRegenPerDay(partyUnit);

        // verify if base health regen does not equal effecitve health regen
        if (partyUnit.GetUnitEffectiveHealthRegenPerDay() != baseHealthRegen)
        {
            // Display how regen is calculated
            // open brackets
            attributeText.text += "(";
            // set base unit regen without bonuses
            attributeText.text += baseStatPreviewStyleStart + baseHealthRegen.ToString() + baseStatPreviewStyleEnd;
            // get and add stats bonus regen
            //attributeText.text += statsBonusPreviewStyleStart + "+" + GetUnitStatsBonusHealthRegenPerDay(partyUnit) + statsBonusPreviewStyleEnd;
            AddBonusInfoToText(attributeText, GetUnitStatsBonusHealthRegenPerDay(partyUnit), statsBonusPreviewStyleStart, statsBonusPreviewStyleEnd);
            // get and add skill bonus to text
            AddBonusInfoToText(attributeText, partyUnit.GetUnitHealSkillHealthRegenBonusPerDay(), skillBonusPreviewStyleStart, skillBonusPreviewStyleEnd);
            // get and add item bonus to text
            AddBonusInfoToText(attributeText, partyUnit.GetUnitHealItemsHealthRegenBonusPerDay(), itemBonusPreviewStyleStart, itemBonusPreviewStyleEnd);
            // close brackets
            attributeText.text += ")";
        }
    }