Esempio n. 1
0
        public bool Insert(GameObject _object)
        {
            if (_object == null || !_object.activeInHierarchy)
            {
                return(false);
            }

            InventorySlotObject _slot = ForceSlotByItem(_object, 1);

            if (_slot != null)
            {
                if (_slot.SetItemObject(_object))
                {
                    if (DebugLogIsEnabled)
                    {
                        PrintDebugLog(this, "Insert - '" + _object.name + "' inserted and attached to slot (new amount : " + _slot.Amount + "/" + _slot.MaxAmount + ")");
                    }
                }
                else if (_slot.FreeCapacity >= 1)
                {
                    if (_slot.IsEmpty)
                    {
                        _slot.ItemName = _object.name;
                    }

                    _slot.Amount++;
                    CreatureRegister.Remove(_object);

                    if (DebugLogIsEnabled)
                    {
                        PrintDebugLog(this, "Insert - '" + _object.name + "' amount increased of slot (new amount : " + _slot.Amount + "/" + _slot.MaxAmount + ") and original object removed");
                    }
                }
                else
                {
                    //if( DebugLogIsEnabled ) PrintDebugLog( this, "Insert - '" + _object.name + "' amount increased of slot (new amount : " + _slot.Amount + "/" + _slot.MaxAmount + ") and original object removed" );
                    return(false);
                }

                return(true);
            }

            return(false);
        }