public void SetUnitResistancesInfo(PartyUnit partyUnit) { // initialise resistances string string resistances = ""; string resistance = ""; PowerSource source; // source = resistance bool firstResistanceInAString = true; // loop throug all power sources and find if unit has resistances for (int i = 0; i < (int)PowerSource.None; i++) // None is the last element { source = (PowerSource)i; // get effective resistance int effectiveResistance = partyUnit.GetUnitEffectiveResistance(source); // verify if effective resistance is higher than 0 and it is not equal to base resistance if (effectiveResistance > 0) { // form resistance string // set resistance name resistance = source.ToString(); // add effective resistance to string resistance += ":" + effectiveResistance; // get base resistance int baseResistance = partyUnit.GetUnitBaseResistance(source); // verify if effective resistance does not equal base resistance if (baseResistance != effectiveResistance) { // Display how resistance is calculated // open brackets resistance += "("; // verify if base resistance is higher than 0 if (baseResistance > 0) { // add base resistance to string resistance += baseStatPreviewStyleStart + baseResistance + baseStatPreviewStyleEnd; } // get skill resistance int skillResistance = partyUnit.GetUnitResistanceSkillBonus(source); // verify if skill resistance is higher than 0 if (skillResistance > 0) { // add skill resistance to string resistance += skillBonusPreviewStyleStart + "+" + skillResistance + skillBonusPreviewStyleEnd; } // get item resistance int itemsResistance = partyUnit.GetUnitResistanceItemsBonusBySource(source); // verify if skill resistance is higher than 0 if (itemsResistance > 0) { // add item bonus to text resistance += itemBonusPreviewStyleStart + "+" + itemsResistance + itemBonusPreviewStyleEnd; } // close brackets resistance += ")"; } // verify if this is first resistace in a string if (firstResistanceInAString) { // this is first resistance // add it to the list of resistances resistances = resistance; firstResistanceInAString = false; } else { // this is not first resistance // add it to the list of resistances after ', ' separator resistances += ", " + resistance; } } //for (int i = 0; i < partyUnit.Resistances.Length; i++) //{ // source = partyUnit.Resistances[i].source; // // set resistance name // resistance = source.ToString(); // // get hero skill resistance bonus for the same resistance type // int resistanceSkillBonus = partyUnit.GetUnitResistanceSkillBonus(source); // // verify if hero knows resistance skill with the same type // if (resistanceSkillBonus != 0) // { // // add skill bonus to the total value // resistance += ":" + baseStatPreviewStyleStart + partyUnit.Resistances[i].percent.ToString() + baseStatPreviewStyleEnd; // } // // get and add base resistance to string // resistance += ":" + baseStatPreviewStyleStart + partyUnit.Resistances[i].percent.ToString() + baseStatPreviewStyleEnd; //} } transform.Find("Panel/UnitResistances/Value").GetComponent <Text>().text = resistances; }