示例#1
0
        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);
        }
示例#2
0
        public Item[] GetProtections()
        {
            ObjectContainedInventory helmet = inventory.GetHelmet();
            ObjectContainedInventory vest   = inventory.GetVest();

            return(new[] { helmet == null ? null : helmet.GetItem(), vest == null ? null : vest.GetItem() });
        }
示例#3
0
 public void NotifySpawnDroppedItem(ObjectContainedInventory itemToSpawn)
 {
     if (SpawnItem != null)
     {
         SpawnItem(itemToSpawn);
     }
 }
示例#4
0
 public void EquipGrenade(ObjectContainedInventory itemToEquip)
 {
     if (grenade != null)
     {
         UnequipGrenade();
     }
     grenade = itemToEquip;
     CheckMultiplePresenceAndRemove(itemToEquip);
 }
示例#5
0
        private void OnSwitchThirdWeapon()
        {
            ObjectContainedInventory grenade = inventory.GetGrenade();

            currentGrenade = grenade == null ? null : grenade.GetItem() as Grenade;
            if (currentGrenade != null)
            {
                isHoldingGrenade = true;
            }
        }
示例#6
0
 public void EquipVest(ObjectContainedInventory itemToEquip)
 {
     if (vest != null)
     {
         UnequipVest();
     }
     vest = itemToEquip;
     CheckMultiplePresenceAndRemove(itemToEquip);
     NotifyProtectionEquipped(vest);
 }
示例#7
0
 public void ResetInventory()
 {
     currentWeight   = 0;
     primaryWeapon   = null;
     secondaryWeapon = null;
     helmet          = null;
     vest            = null;
     ListInventory   = null;
     grenade         = null;
 }
示例#8
0
 public void EquipBag(ObjectContainedInventory itemToEquip)
 {
     if (bag != null)
     {
         UnequipBag();
     }
     bag = itemToEquip;
     CheckMultiplePresenceAndRemove(itemToEquip);
     ChangeMaxWeight((itemToEquip.GetItem() as Bag).Capacity);
     NotifyProtectionEquipped(bag);
 }
示例#9
0
 private void AddPlayerCellToInventory(GameObject game)
 {
     if (inventoryOf == InventoryOf.Player)
     {
         ObjectContainedInventory cell = CreatePlayerCell(game);
         if (!IsItemPresentInInventory(cell))
         {
             ListInventory.Add(cell);
         }
         NotifyInventoryChange();
     }
 }
示例#10
0
 public void UnequipGrenade()
 {
     if (grenade != null)
     {
         if (!IsItemPresentInInventory(grenade))
         {
             ListInventory.Add(grenade);
         }
         AddWeight(grenade.GetItem().GetWeight());
         grenade = null;
         NotifyInventoryChange();
     }
 }
示例#11
0
 public void UnequipHelmet()
 {
     if (helmet != null)
     {
         if (!IsItemPresentInInventory(helmet))
         {
             ListInventory.Add(helmet);
         }
         AddWeight(helmet.GetItem().GetWeight());
         helmet = null;
         NotifyInventoryChange();
     }
 }
示例#12
0
        public void InstantiateCellObjectFromCell(ObjectContainedInventory cell)
        {
            InstantiateCellObjectVariables();
            CellContained = cell;
            int compteur = CellContained.GetCompteur();

            SetTextName(GetNameOfCellObject());
            if (cellObjectType != CellObjectType.Weapon)
            {
                SetTextNumber(compteur);
            }
            SetImageBackground();
        }
示例#13
0
 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);
     }
 }
示例#14
0
 public void UnequipVest()
 {
     if (vest != null)
     {
         if (!IsItemPresentInInventory(vest))
         {
             ListInventory.Add(vest);
         }
         AddWeight(vest.GetItem().GetWeight());
         vest = null;
         NotifyInventoryChange();
     }
 }
示例#15
0
        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);
            }
        }
示例#16
0
 public void CheckMultiplePresenceAndRemove(ObjectContainedInventory temp)
 {
     if (temp.GetCompteur() >= 2)
     {
         temp.RemoveOneFromCompteur();
         NotifyInventoryChange();
     }
     else
     {
         ListInventory.Remove(temp);
         NotifyInventoryChange();
     }
     RemoveWeight(temp.GetItem().GetWeight());
 }
示例#17
0
        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();
            }
        }
示例#18
0
 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();
     }
 }
示例#19
0
 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();
 }
示例#20
0
        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();
            }
        }
示例#21
0
        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;
            }
        }
示例#22
0
 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();
     }
 }
示例#23
0
        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;
        }
示例#24
0
        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();
        }
示例#25
0
        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);
            }
        }
示例#26
0
 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();
     }
 }
示例#27
0
 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();
     }
 }
示例#28
0
 public void RemoveThrownGrenade()
 {
     this.grenade = null;
     NotifyInventoryChange();
 }
示例#29
0
 public SpawnItemDropEvent(ObjectContainedInventory itemToSpawn)
 {
     ItemToSpawn = itemToSpawn;
 }
示例#30
0
 private void ItemToSpawn_SpawnItem(ObjectContainedInventory itemToSpawn)
 {
     spawnItemDropEventChannel.Publish(new SpawnItemDropEvent(itemToSpawn));
 }