public Armour(int id, string name, string namePlural, ArmourMaterial material, ArmourSlot slot) : base(id, name, namePlural) { Material = material; Slot = slot; }
public void Init(int value, Armour.PossibleArmourSlots slotName) { this.ArmourValue = value; this.ArmourSlot = slotName; if (value == 0) { armourType = Armour.ArmourType.Cloth; } else { var slotArmourValue = Armour.GetArmourValue(slotName); if ((float)value / slotArmourValue < 0.25) { armourType = Armour.ArmourType.Light; } else if ((float)value / slotArmourValue < 0.75) { armourType = Armour.ArmourType.Medium; } else if ((float)value / slotArmourValue < 1) { armourType = Armour.ArmourType.Heavy; } } Strength = RandomNumberGenerator.GetRandom(6); Intellect = RandomNumberGenerator.GetRandom(6); Stamina = RandomNumberGenerator.GetRandom(6); var attributesSum = Strength + Intellect + Stamina; if (attributesSum <= 5) { rarity = Armour.Rarity.Common; } else if (attributesSum <= 10) { rarity = Armour.Rarity.Rare; } else if (attributesSum <= 14) { rarity = Armour.Rarity.Epic; } else { rarity = Armour.Rarity.Legendary; } name = string.Format("{0:9} {1:8} {2:10}", rarity.ToString(), armourType.ToString(), ArmourSlot.ToString()); var path = "images/" + ArmourSlot.ToString().ToLower(); icon = Resources.Load <Sprite>(path); if (icon == null) { Debug.Log(path); } }