private bool IsItemPresentInInventory(ObjectContainedInventory cell) { bool itemIsPresentInInventory = false; foreach (ObjectContainedInventory item in ListInventory) { if ((item.GetItem() as AmmoPack) && (cell.GetItem() as AmmoPack)) { if ((cell.GetItem() as AmmoPack).AmmoType == (item.GetItem() as AmmoPack).AmmoType) { item.AddCompteur(); itemIsPresentInInventory = true; NotifyInventoryChange(); } } else if (item == cell && item.GetItem().Level == cell.GetItem().Level) { item.AddCompteur(); itemIsPresentInInventory = true; NotifyInventoryChange(); break; } } return(itemIsPresentInInventory); }
public void UnequipBag() { if (bag != null) { if (!IsItemPresentInInventory(bag)) { ListInventory.Add(bag); } ChangeMaxWeight((bag.GetItem() as Bag).Capacity, false); AddWeight(bag.GetItem().GetWeight()); bag = null; NotifyInventoryChange(); } }
public void Drop(ObjectContainedInventory itemToDrop) { itemToDrop.GetItem().Player = Parent; while (itemToDrop.GetCompteur() > 1) { RemoveWeight(itemToDrop.GetItem().GetWeight()); itemToDrop.RemoveOneFromCompteur(); NotifySpawnDroppedItem(itemToDrop); NotifyInventoryChange(); } RemoveWeight(itemToDrop.GetItem().GetWeight()); ListInventory.Remove(itemToDrop); NotifySpawnDroppedItem(itemToDrop); NotifyInventoryChange(); }
public Item[] GetProtections() { ObjectContainedInventory helmet = inventory.GetHelmet(); ObjectContainedInventory vest = inventory.GetVest(); return(new[] { helmet == null ? null : helmet.GetItem(), vest == null ? null : vest.GetItem() }); }
private void AddItemCellToInventory(GameObject game, GameObject player = null) { if (inventoryOf == InventoryOf.Item) { ObjectContainedInventory cell = CreateItemCell(game); if (cell.GetItem() != null && AddWeight(cell.GetItem().GetWeight())) { if (!IsItemPresentInInventory(cell)) { ListInventory.Add(cell); } cell.GetItem().Player = player; } NotifyInventoryChange(); } }
private void OnSwitchThirdWeapon() { ObjectContainedInventory grenade = inventory.GetGrenade(); currentGrenade = grenade == null ? null : grenade.GetItem() as Grenade; if (currentGrenade != null) { isHoldingGrenade = true; } }
public void EquipBag(ObjectContainedInventory itemToEquip) { if (bag != null) { UnequipBag(); } bag = itemToEquip; CheckMultiplePresenceAndRemove(itemToEquip); ChangeMaxWeight((itemToEquip.GetItem() as Bag).Capacity); NotifyProtectionEquipped(bag); }
public void UnequipGrenade() { if (grenade != null) { if (!IsItemPresentInInventory(grenade)) { ListInventory.Add(grenade); } AddWeight(grenade.GetItem().GetWeight()); grenade = null; NotifyInventoryChange(); } }
public void UnequipVest() { if (vest != null) { if (!IsItemPresentInInventory(vest)) { ListInventory.Add(vest); } AddWeight(vest.GetItem().GetWeight()); vest = null; NotifyInventoryChange(); } }
public void UnequipHelmet() { if (helmet != null) { if (!IsItemPresentInInventory(helmet)) { ListInventory.Add(helmet); } AddWeight(helmet.GetItem().GetWeight()); helmet = null; NotifyInventoryChange(); } }
private void UpdateImage(Inventory inventory) { ObjectContainedInventory vestCell = inventory.GetVest(); ObjectContainedInventory helmetCell = inventory.GetHelmet(); if (type == ItemType.Vest && vestCell != null) { Item vest = vestCell.GetItem(); } if (type == ItemType.Helmet && helmetCell != null) { Item helmet = helmetCell.GetItem(); } }
public void NotifyProtectionEquipped(ObjectContainedInventory objectContainedInventory) { Item itemOfProtection = objectContainedInventory.GetItem(); ProtectionOfPlayer protectionOfPlayer = new ProtectionOfPlayer { LevelProtection = itemOfProtection.Level, TypeProtection = itemOfProtection.Type.ToString() }; if (ProtectionEquipped != null) { ProtectionEquipped(protectionOfPlayer); } }
public void CheckMultiplePresenceAndRemove(ObjectContainedInventory temp) { if (temp.GetCompteur() >= 2) { temp.RemoveOneFromCompteur(); NotifyInventoryChange(); } else { ListInventory.Remove(temp); NotifyInventoryChange(); } RemoveWeight(temp.GetItem().GetWeight()); }
private void OnSwitchSecondaryWeapon() { SetCurrentWeaponActive(false); ObjectContainedInventory weapon = inventory.GetSecondaryWeapon(); currentWeapon = weapon == null ? null : weapon.GetItem() as Weapon; SetCurrentWeaponActive(true); inventory.NotifyInventoryChange(); isHoldingGrenade = false; if (currentWeapon != null) { currentWeapon.ChangeWeaponSound(); } }
private void UpdateProtectionKnowledge() { Actor.EquipmentManager.SelectHelmet(); Actor.EquipmentManager.SelectVest(); vestProtectionRatio = 0.0f; helmetProtectionRatio = 0.0f; ObjectContainedInventory cellHelmet = Actor.AIInventory.GetHelmet(); ObjectContainedInventory cellVest = Actor.AIInventory.GetVest(); Vest equippedVest = null; Helmet equippedHelmet = null; if (cellVest != null) { equippedVest = (Vest)cellVest.GetItem(); } if (equippedVest != null) { hasVestEquipped = true; vestProtectionRatio += equippedVest.ProtectionValue; } else { hasVestEquipped = false; } if (cellHelmet != null) { equippedHelmet = (Helmet)cellHelmet.GetItem(); } if (equippedHelmet != null) { hasHelmetEquipped = true; helmetProtectionRatio += equippedHelmet.ProtectionValue; } else { hasHelmetEquipped = false; } helmetProtectionRatio /= HelmetProtectionMaximum; vestProtectionRatio /= VestProtectionMaximum; }
private void UpdateWeaponKnowledge() { ObjectContainedInventory cell = Actor.AIInventory.GetPrimaryWeapon(); Weapon equippedPrimaryWeapon = null; if (cell != null) { equippedPrimaryWeapon = (Weapon)cell.GetItem(); } if (equippedPrimaryWeapon != null) { hasPrimaryWeaponEquipped = true; } else { hasPrimaryWeaponEquipped = false; } Actor.EquipmentManager.SelectWeapon(); }
private void UpdateSupportKnowledge() { //Bag Actor.EquipmentManager.SelectBag(); bagCapacityRatio = 0.0f; ObjectContainedInventory cellBag = Actor.AIInventory.GetBag(); Bag equippedBag = null; if (cellBag != null) { equippedBag = (Bag)cellBag.GetItem(); } if (equippedBag != null) { hasBagEquipped = true; bagCapacityRatio += equippedBag.Capacity; } else { hasBagEquipped = false; } bagCapacityRatio /= BagCapacityMaximum; //Boost boostNumberStorageRatio = (float)Actor.AIInventory.GetItemQuantityInInventory(ItemType.Boost, AmmoType.None) / MaxUsefulStoredBoostItem; boostNumberStorageRatio = Mathf.Clamp(boostNumberStorageRatio, 0.0f, 1.0f); //Heal healthRatio = Actor.AIHealth.HealthPoints / Actor.AIHealth.MaxHealthPoints; healNumberStorageRatio = (float)Actor.AIInventory.GetItemQuantityInInventory(ItemType.Heal, AmmoType.None) / MaxUsefulStoredHealItem; healNumberStorageRatio = Mathf.Clamp(healNumberStorageRatio, 0.0f, 1.0f); //Ammopack for (int i = 0; i < NumberOfAmmoPackType; i++) { ammoPackNumberStorageRatio[i] = (float)Actor.AIInventory.GetItemQuantityInInventory(ItemType.AmmoPack, (AmmoType)i) / MaxUsefulStoredAmmoPackItem; ammoPackNumberStorageRatio[i] = Mathf.Clamp(ammoPackNumberStorageRatio[i], 0.0f, 1.0f); } }
public void UnequipWeaponAt(EquipWeaponAt selection) { if (selection == ProjetSynthese.EquipWeaponAt.Primary && primaryWeapon != null) { if (!IsItemPresentInInventory(primaryWeapon)) { ListInventory.Add(primaryWeapon); } AddWeight(primaryWeapon.GetItem().GetWeight()); primaryWeapon = null; NotifyInventoryChange(); } if (selection == ProjetSynthese.EquipWeaponAt.Secondary && secondaryWeapon != null) { if (!IsItemPresentInInventory(secondaryWeapon)) { ListInventory.Add(secondaryWeapon); } AddWeight(secondaryWeapon.GetItem().GetWeight()); secondaryWeapon = null; NotifyInventoryChange(); } }
public Weapon GetWeapon() { ObjectContainedInventory weapon = inventory.GetPrimaryWeapon(); return(weapon == null ? null : weapon.GetItem() as Weapon); }
//public bool IsExplorePathBlocked(Vector3 destination, float range) //{ // Vector3 direction = Vector3.zero; // direction = destination - Actor.transform.position; // range += SafetyMargin; // return Actor.Sensor.IsGameObjectHasLineOfSightToMapPosition(Actor.transform.position, direction, range); //} private void UpdateInventoryKnowledge() { //garder meilleur bag, helmet,vest,boost,heal dans l'inventaire if (Actor.AIInventory.ListInventory != null) { Item item = null; foreach (ObjectContainedInventory cell in Actor.AIInventory.ListInventory) { item = cell.GetItem(); switch (item.Type) { case ItemType.Helmet: if (inventoryBestHelmet == null) { InventoryBestHelmet = cell; } else { Helmet helmet = (Helmet)item; if (((Helmet)inventoryBestHelmet.GetItem()).ProtectionValue < helmet.ProtectionValue) { InventoryBestHelmet = cell; } } break; case ItemType.Vest: if (inventoryBestVest == null) { InventoryBestVest = cell; } else { Vest vest = (Vest)item; if (((Vest)inventoryBestVest.GetItem()).ProtectionValue < vest.ProtectionValue) { InventoryBestVest = cell; } } break; case ItemType.Bag: if (inventoryBestBag == null) { InventoryBestBag = cell; } else { Bag bag = (Bag)item; if (((Bag)inventoryBestBag.GetItem()).Capacity < bag.Capacity) { InventoryBestBag = cell; } } break; case ItemType.Heal: if (inventoryBestHeal == null) { InventoryBestHeal = cell; } else { Heal heal = (Heal)item; if (((Heal)inventoryBestHeal.GetItem()).Efficacity < heal.Efficacity) { InventoryBestHeal = cell; } } break; case ItemType.Boost: if (inventoryBestBoost == null) { InventoryBestBoost = cell; } else { Boost boost = (Boost)item; if (((Boost)inventoryBestBoost.GetItem()).Efficacity < boost.Efficacity) { InventoryBestBoost = cell; } } break; default: break; } } } }