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 Item[] GetProtections() { ObjectContainedInventory helmet = inventory.GetHelmet(); ObjectContainedInventory vest = inventory.GetVest(); return(new[] { helmet == null ? null : helmet.GetItem(), vest == null ? null : vest.GetItem() }); }
public void NotifySpawnDroppedItem(ObjectContainedInventory itemToSpawn) { if (SpawnItem != null) { SpawnItem(itemToSpawn); } }
public void EquipGrenade(ObjectContainedInventory itemToEquip) { if (grenade != null) { UnequipGrenade(); } grenade = itemToEquip; CheckMultiplePresenceAndRemove(itemToEquip); }
private void OnSwitchThirdWeapon() { ObjectContainedInventory grenade = inventory.GetGrenade(); currentGrenade = grenade == null ? null : grenade.GetItem() as Grenade; if (currentGrenade != null) { isHoldingGrenade = true; } }
public void EquipVest(ObjectContainedInventory itemToEquip) { if (vest != null) { UnequipVest(); } vest = itemToEquip; CheckMultiplePresenceAndRemove(itemToEquip); NotifyProtectionEquipped(vest); }
public void ResetInventory() { currentWeight = 0; primaryWeapon = null; secondaryWeapon = null; helmet = null; vest = null; ListInventory = null; grenade = null; }
public void EquipBag(ObjectContainedInventory itemToEquip) { if (bag != null) { UnequipBag(); } bag = itemToEquip; CheckMultiplePresenceAndRemove(itemToEquip); ChangeMaxWeight((itemToEquip.GetItem() as Bag).Capacity); NotifyProtectionEquipped(bag); }
private void AddPlayerCellToInventory(GameObject game) { if (inventoryOf == InventoryOf.Player) { ObjectContainedInventory cell = CreatePlayerCell(game); if (!IsItemPresentInInventory(cell)) { ListInventory.Add(cell); } NotifyInventoryChange(); } }
public void UnequipGrenade() { if (grenade != null) { if (!IsItemPresentInInventory(grenade)) { ListInventory.Add(grenade); } AddWeight(grenade.GetItem().GetWeight()); grenade = null; NotifyInventoryChange(); } }
public void UnequipHelmet() { if (helmet != null) { if (!IsItemPresentInInventory(helmet)) { ListInventory.Add(helmet); } AddWeight(helmet.GetItem().GetWeight()); helmet = null; NotifyInventoryChange(); } }
public void InstantiateCellObjectFromCell(ObjectContainedInventory cell) { InstantiateCellObjectVariables(); CellContained = cell; int compteur = CellContained.GetCompteur(); SetTextName(GetNameOfCellObject()); if (cellObjectType != CellObjectType.Weapon) { SetTextNumber(compteur); } SetImageBackground(); }
public void Remove(GameObject game) { if (inventoryOf == InventoryOf.Item) { ObjectContainedInventory temp = CreateItemCell(game); CheckMultiplePresenceAndRemove(temp); } if (inventoryOf == InventoryOf.Player) { ObjectContainedInventory temp = CreatePlayerCell(game); CheckMultiplePresenceAndRemove(temp); } }
public void UnequipVest() { if (vest != null) { if (!IsItemPresentInInventory(vest)) { ListInventory.Add(vest); } AddWeight(vest.GetItem().GetWeight()); vest = null; NotifyInventoryChange(); } }
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 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 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(); }
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 InstantiateCellObject(GameObject cellPrefabs, Transform grid, ObjectContainedInventory item, EquipWeaponAt equipWeaponAt = EquipWeaponAt.Primary) { GameObject gameCellObject = Instantiate(cellPrefabs); gameCellObject.transform.SetParent(grid, false); CellObject cellObject = gameCellObject.GetComponentInChildren <CellObject>(); cellObject.Inventory = inventory; cellObject.Control = this; cellObject.InstantiateCellObjectFromCell(item); if (cellPrefabs == cellEquippedWeaponPrefabs) { cellObject.EquipAt = equipWeaponAt; } }
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 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 EquipWeaponAt(EquipWeaponAt selection, ObjectContainedInventory itemToEquip) { if (selection == ProjetSynthese.EquipWeaponAt.Primary) { if (primaryWeapon != null) { UnequipWeaponAt(ProjetSynthese.EquipWeaponAt.Primary); } primaryWeapon = itemToEquip; CheckMultiplePresenceAndRemove(itemToEquip); NotifyWeaponEquip(); } if (selection == ProjetSynthese.EquipWeaponAt.Secondary) { if (secondaryWeapon != null) { UnequipWeaponAt(ProjetSynthese.EquipWeaponAt.Secondary); } secondaryWeapon = itemToEquip; CheckMultiplePresenceAndRemove(itemToEquip); NotifyWeaponEquip(); } }
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 void RemoveThrownGrenade() { this.grenade = null; NotifyInventoryChange(); }
public SpawnItemDropEvent(ObjectContainedInventory itemToSpawn) { ItemToSpawn = itemToSpawn; }
private void ItemToSpawn_SpawnItem(ObjectContainedInventory itemToSpawn) { spawnItemDropEventChannel.Publish(new SpawnItemDropEvent(itemToSpawn)); }