public static bool CheckShieldCompability(IEquipmentCarrier equipmentCarrier, Equipment equipment, PersonSlotSubScheme slot, int slotIndex) { var equipmentTags = equipment.Scheme.Tags ?? new string[0]; var hasShieldTag = equipmentTags.Any(x => x == PropTags.Equipment.Shield); if (hasShieldTag) { // Проверяем наличие других щитов. // Если в другой руке щит уже экипирован, то выбрасываем исключение. // Учитываем, что предмет в целевом слоте заменяется. var targetSlotEquipment = equipmentCarrier[slotIndex]; var currentEquipments = equipmentCarrier.Where(x => x != null); var currentSheilds = from currentEquipment in currentEquipments where currentEquipment != targetSlotEquipment let currentEqupmentTags = currentEquipment.Scheme.Tags ?? new string[0] where currentEqupmentTags.Any(x => x == PropTags.Equipment.Shield) select currentEquipment; var hasShields = currentSheilds.Any(); if (hasShields) { return(false); } } return(true); }
private static bool CanBeEquiped( IEquipmentCarrier equipmentCarrier, int slotIndex, Equipment equipment) { return(EquipmentCarrierHelper.CanBeEquiped(equipmentCarrier, slotIndex, equipment)); }
/// <summary> /// Ищем предмет в уже экипированных. /// </summary> /// <param name="equipment"> Целевой предмет. </param> /// <param name="equipmentCarrier"> Объект для хранения экипировки. </param> /// <returns> Возвращает индекс слота, в котором находится указанный предмет. Или null, если предмет не найден. </returns> private int?FindPropInEquiped(Equipment equipment, IEquipmentCarrier equipmentCarrier) { for (var i = 0; i < equipmentCarrier.Count(); i++) { if (equipmentCarrier[i] == equipment) { return(i); } } return(null); }
public static bool CheckDualCompability(IEquipmentCarrier equipmentCarrier, Equipment equipment, PersonSlotSubScheme slot, int slotIndex) { var equipmentTags = equipment.Scheme.Tags ?? new string[0]; var hasRangedTag = equipmentTags.Any(x => x == PropTags.Equipment.Ranged); var hasWeaponTag = equipmentTags.Any(x => x == PropTags.Equipment.Weapon); if (hasRangedTag && hasWeaponTag) { // Проверяем наличие любого экипированного оружия. // Если находим, то выбрасываем исключение. // Учитываем, что предмет в целевом слоте заменяется. var targetSlotEquipment = equipmentCarrier[slotIndex]; var currentEquipments = equipmentCarrier.Where(x => x != null); var currentWeapons = from currentEquipment in currentEquipments where currentEquipment != targetSlotEquipment let currentEqupmentTags = currentEquipment.Scheme.Tags ?? new string[0] where currentEqupmentTags.Any(x => x == PropTags.Equipment.Weapon) select currentEquipment; var hasWeapon = currentWeapons.Any(); if (hasWeapon) { return(false); } } if (hasWeaponTag) { // проверяем наличие стрелкового оружия. // Если находим, то выбрасываем исключение. // Учитываем, что предмет в целевом слоте заменяется. var targetSlotEquipment = equipmentCarrier[slotIndex]; var currentEquipments = equipmentCarrier.Where(x => x != null); var currentWeapons = from currentEquipment in currentEquipments where currentEquipment != targetSlotEquipment let currentEqupmentTags = currentEquipment.Scheme.Tags ?? new string[0] let currentEqupmentHasWeapon = currentEqupmentTags.Any(x => x == PropTags.Equipment.Weapon) let currentEqupmentHasRanged = currentEqupmentTags.Any(x => x == PropTags.Equipment.Ranged) where currentEqupmentHasWeapon && currentEqupmentHasRanged select currentEquipment; var hasWeapon = currentWeapons.Any(); if (hasWeapon) { return(false); } } return(true); }
private void AddEquipmentToActor(IEquipmentCarrier equipmentCarrier, int slotIndex, string equipmentSid) { try { var equipmentScheme = _schemeService.GetScheme <IPropScheme>(equipmentSid); var equipment = _propFactory.CreateEquipment(equipmentScheme); equipmentCarrier[slotIndex] = equipment; } catch (KeyNotFoundException) { Debug.LogError($"Не найден объект {equipmentSid}"); } }
private void AddEquipment(IEquipmentCarrier equipmentCarrier, int slotIndex, string equipmentSid) { try { var equipmentScheme = _schemeService.GetScheme <IPropScheme>(equipmentSid); var equipment = _propFactory.CreateEquipment(equipmentScheme); equipmentCarrier[slotIndex] = equipment; } catch (KeyNotFoundException exception) { throw new CreatePersonException($"Не найден объект {equipmentSid}", exception); } }
private static void AddEquipmentToActor(IEquipmentCarrier equipmentCarrier, int slotIndex, string equipmentSid, ISchemeService schemeService, IPropFactory propFactory) { try { var equipmentScheme = schemeService.GetScheme <IPropScheme>(equipmentSid); var equipment = propFactory.CreateEquipment(equipmentScheme); equipmentCarrier[slotIndex] = equipment; } catch (KeyNotFoundException) { Debug.WriteLine($"Не найден объект {equipmentSid}"); } }
public static bool CanBeEquiped(IEquipmentCarrier equipmentCarrier, int slotIndex, Equipment equipment) { var slot = equipmentCarrier.Slots[slotIndex]; if (!CheckSlotCompability(equipment, slot)) { return(false); } if (!CheckDualCompability(equipmentCarrier, equipment, slot, slotIndex)) { return(false); } if (!CheckShieldCompability(equipmentCarrier, equipment, slot, slotIndex)) { return(false); } return(true); }
private void AddEquipment(IEquipmentCarrier equipmentCarrier, int slotIndex, Equipment equipment) { equipmentCarrier[slotIndex] = equipment; }