private string GetDamagedIconName(DurableItem item) { if (item is ArmorItem armor) { switch (armor.ArmorType) { case ArmorType.Helmet: return("DamagedEquipment_Helmet"); case ArmorType.Chest: return("DamagedEquipment_Chest"); case ArmorType.Leggings: return("DamagedEquipment_Leggings"); default: throw new ArgumentException($"Unknown armor type: {armor.ArmorType}"); } } if (item is WeaponItem weapon) { if (game.Player.Equipment.RightHandItem.Equals(weapon)) { return("DamagedEquipment_Weapon_Right"); } else { return("DamagedEquipment_Weapon_Left"); } } throw new ApplicationException($"Unknown durable equipment: {item.GetType().Name}"); }
private SymbolsImage GetDamagedIcon(DurableItem item) { var damageColor = TextHelper.GetDurabilityColor(item.Durability, item.MaxDurability); var iconName = GetDamagedIconName(item); var image = ImagesStorage.Current.GetImage(iconName); return(SymbolsImage.Recolor(image, new Dictionary <System.Drawing.Color, System.Drawing.Color> { { System.Drawing.Color.FromArgb(255, 0, 0), damageColor } })); }
private bool ItemDamaged(DurableItem durable) { if (durable.Durability <= DurabilityIconValue) { return(true); } var percent = (double)durable.Durability / durable.MaxDurability * 100; if (percent <= DurabilityIconPercent) { return(true); } return(false); }