コード例 #1
0
        public GameObject UpdateItemObject()
        {
            if (!ItemNameIsValid || IsNotional || Amount == 0 || ItemUpdateRequired || (MountPointTransform != null && m_ItemObject != null && m_ItemObject.transform.IsChildOf(MountPointTransform) == false))
            {
                if (m_ItemObject != null)
                {
                    CreatureRegister.Remove(m_ItemObject);
                }

                m_ItemObject = null;
            }

            if (ItemNameIsValid && !IsNotional && Amount > 0 && m_ItemObject == null)
            {
                m_ItemObject = FindItemObject();
                if (m_ItemObject == null)
                {
                    m_ItemObject = SpawnItemObject(MountPointTransform.position, MountPointTransform.rotation);
                    AttachToSlot(m_ItemObject);
                }
                else
                {
                    m_ItemObject.transform.position = MountPointTransform.position;
                    m_ItemObject.transform.rotation = MountPointTransform.rotation;
                    m_ItemObject.SetActive(true);
                }
            }

            return(m_ItemObject);
        }
コード例 #2
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);
        }