예제 #1
0
    protected bool AddFoodItem(InventoryItemFood inventoryItem, CollectableItem collectableItem)
    {
        foreach (var food in _foods)
        {
            if (food.Item == null)
            {
                food.Item         = inventoryItem;
                food.attachedItem = collectableItem;
                inventoryItem.Pickup(collectableItem.transform.position);
                return(true);
            }
        }

        return(false);
    }
예제 #2
0
    protected virtual void Invalidate()
    {
        _selectedPanelType = InventoryPanelType.None;

        if (_weaponMount != null)
        {
            if (_weaponMountImage != null)
            {
                _weaponMountImage.sprite = null;
            }
            if (_weaponMountName != null)
            {
                _weaponMountName.text = "";
            }
            if (_weaponMountWeight != null)
            {
                _weaponMountWeight.text = "";
            }
            if (_weaponMountID != null)
            {
                _weaponMountID.text = "";
            }
            if (_weaponMountRounds != null)
            {
                _weaponMountRounds.text = "";
            }

            _weaponMount.SetActive(false);
            _weaponMount.transform.GetComponent <Image>().fillCenter = false;
        }

        if (_foodMount != null)
        {
            if (_foodMountImage != null)
            {
                _foodMountImage.sprite = null;
            }
            if (_foodMountName != null)
            {
                _foodMountName.text = "";
            }
            if (_foodMountWeight != null)
            {
                _foodMountWeight.text = "";
            }
            if (_foodMountID != null)
            {
                _foodMountID.text = "";
            }

            _foodMount.SetActive(false);
            _foodMount.transform.GetComponent <Image>().fillCenter = false;
        }

        if (_ammoMount != null)
        {
            if (_ammoMountImage != null)
            {
                _ammoMountImage.sprite = null;
            }
            if (_ammoMountName != null)
            {
                _ammoMountName.text = "";
            }
            if (_ammoMountWeight != null)
            {
                _ammoMountWeight.text = "";
            }
            if (_ammoMountID != null)
            {
                _ammoMountID.text = "";
            }

            _ammoMount.SetActive(false);
            _ammoMount.transform.GetComponent <Image>().fillCenter = false;
        }

        if (_inventory != null)
        {
            if (_weaponMount != null)
            {
                var weaponMountInfo        = _inventory.GetWeapon(0);
                InventoryItemWeapon weapon = null;
                if (weaponMountInfo != null)
                {
                    weapon = weaponMountInfo.Weapon;
                }

                if (weapon != null)
                {
                    if (_weaponMountImage != null)
                    {
                        _weaponMountImage.sprite = weapon.Image;
                    }
                    if (_weaponMountName != null)
                    {
                        _weaponMountName.text = weapon.Name;
                    }
                    if (_weaponMountWeight != null)
                    {
                        _weaponMountWeight.text = weapon.Weight.ToString() + " kg";
                    }
                    if (_weaponMountID != null)
                    {
                        _weaponMountID.text = weapon.Identifier;
                    }
                    if (_weaponMountRounds != null)
                    {
                        _weaponMountRounds.text = weaponMountInfo.Rounds.ToString();
                    }

                    _weaponMount.SetActive(true);
                }
            }

            if (_foodMount != null)
            {
                var foodMountInfo      = _inventory.GetFood(0);
                InventoryItemFood food = null;
                if (foodMountInfo != null)
                {
                    food = foodMountInfo.Item;
                }

                if (food != null)
                {
                    if (_foodMountImage != null)
                    {
                        _foodMountImage.sprite = food.Image;
                    }
                    if (_foodMountName != null)
                    {
                        _foodMountName.text = food.Name;
                    }
                    if (_foodMountWeight != null)
                    {
                        _foodMountWeight.text = food.Weight.ToString() + " kg";
                    }
                    if (_foodMountID != null)
                    {
                        _foodMountID.text = food.Identifier;
                    }

                    _foodMount.SetActive(true);
                }
            }

            if (_ammoMount != null)
            {
                var ammoMountInfo      = _inventory.GetAmmo(0);
                InventoryItemAmmo ammo = null;
                if (ammoMountInfo != null)
                {
                    ammo = ammoMountInfo.Ammo;
                }

                if (ammo != null)
                {
                    if (_ammoMountImage != null)
                    {
                        _ammoMountImage.sprite = ammo.Image;
                    }
                    if (_ammoMountName != null)
                    {
                        _ammoMountName.text = ammo.Name;
                    }
                    if (_ammoMountWeight != null)
                    {
                        _ammoMountWeight.text = ammo.Weight.ToString() + " kg";
                    }
                    if (_ammoMountID != null)
                    {
                        _ammoMountID.text = ammo.Identifier;
                    }

                    _ammoMount.SetActive(true);
                }
            }
        }
    }