Пример #1
0
        public DragPreview Create(Transform parent, InventoryObject obj)//, Vector3 position)
        {
            DragPreview dp = Instantiate(gameObject, parent).GetComponent <DragPreview>();

            dp._image.sprite = obj.Icon;
            //dp._image.SetNativeSize();
            return(dp);
        }
        public void OnObjectBeginDrag(Slot slot, InventoryObject obj)
        {
            if (_context.DraggedObject == null)
            {
                return;
            }

            _context.DraggedObject.gameObject.SetActive(false);
        }
Пример #3
0
 public virtual bool Store(InventoryObject obj)
 {
     Color   = obj.Color;
     _object = obj;
     _object.OnMovedHandler += OnObjectMoved;
     _object.transform.SetParent(transform);
     _object.transform.localPosition = Vector3.zero;
     _object.transform.localScale    = new Vector3(1, 1, 1);
     return(true);
 }
Пример #4
0
        public bool TrySwap(Slot otherSlot)
        {
            if (IsEmpty && !otherSlot.IsEmpty)
            {
                Store(otherSlot._object);
                return(true);
            }
            else if (otherSlot.IsEmpty && !IsEmpty)
            {
                otherSlot.Store(_object);
                return(true);
            }
            else if (!otherSlot.IsEmpty && !otherSlot.IsEmpty)
            {
                InventoryObject tmp = _object;
                Store(otherSlot._object);
                otherSlot.Store(tmp);
                return(true);
            }

            return(false);
        }
Пример #5
0
 public override bool Store(InventoryObject obj)
 {
     obj.Reference.gameObject.SetActive(true);
     base.Store(obj.Reference);
     return(true);
 }
Пример #6
0
 public void OnInventoryObjectDragEnd(Slot slot)
 {
     _draggedObject = null;
     _draggedSlot   = null;
 }
Пример #7
0
 public void OnObjectBeginDrag(Slot slot, InventoryObject obj)
 {
     _draggedSlot   = slot;
     _draggedObject = obj;
 }
Пример #8
0
 public override void OnObjectMoved(InventoryObject obj)
 {
     //_object.OnMovedHandler -= OnObjectMoved;
     //_object = null;
 }
 private void OnObjectUsed(Slot slot, InventoryObject obj)
 {
     obj.TryUse(_context.Character); // If empty remove object
 }
Пример #10
0
 public void OnObjectBeginDrag(Slot slot, InventoryObject obj)
 {
     //_context.DraggedObject.gameObject.SetActive(false);
 }
Пример #11
0
 public virtual void OnObjectMoved(InventoryObject obj)
 {
     Color = _defaultColor;
     _object.OnMovedHandler -= OnObjectMoved;
     _object = null;
 }