예제 #1
0
    void SetUnitDefenseInfo(PartyUnit partyUnit)
    {
        // Get defense text
        Text attributeText = transform.Find("Panel/UnitDefense/Value").GetComponent <Text>();

        // display effective defense
        attributeText.text = partyUnit.GetEffectiveDefense().ToString();
        // verify if base unit defense does not equal to effective defense
        if (partyUnit.GetEffectiveDefense() != partyUnit.UnitBaseDefense)
        {
            // Display how defense is calculated
            // open brackets
            attributeText.text += "(";
            // set base unit defense without bonuses
            attributeText.text += baseStatPreviewStyleStart + partyUnit.UnitBaseDefense.ToString() + baseStatPreviewStyleEnd;
            // get and add defense skill bonus to text
            AddBonusInfoToText(attributeText, partyUnit.GetSkillDefenseBonus(), skillBonusPreviewStyleStart, skillBonusPreviewStyleEnd);
            // get and add items bonus
            AddBonusInfoToText(attributeText, partyUnit.GetItemsDefenseBonus(), itemBonusPreviewStyleStart, itemBonusPreviewStyleEnd);
            // get and add city bonus to text
            AddBonusInfoToText(attributeText, partyUnit.GetCityDefenseBonus(), cityBonusPreviewStyleStart, cityBonusPreviewStyleEnd);
            // get and add status bonus (example: defense stance) to text
            AddBonusInfoToText(attributeText, (int)(partyUnit.GetDefensiveStanceBonus() * (100 - partyUnit.GetTotalAdditiveDefense())), statusBonusPreviewStyleStart, statusBonusPreviewStyleEnd);
            // not needed - stats do no give defense bonus
            // close brackets
            attributeText.text += ")";
        }
    }