Exemplo n.º 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);
        }
Exemplo n.º 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);
 }
Exemplo n.º 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);
        }
Exemplo n.º 5
0
 public override bool Store(InventoryObject obj)
 {
     obj.Reference.gameObject.SetActive(true);
     base.Store(obj.Reference);
     return(true);
 }
Exemplo n.º 6
0
 public void OnInventoryObjectDragEnd(Slot slot)
 {
     _draggedObject = null;
     _draggedSlot   = null;
 }
Exemplo n.º 7
0
 public void OnObjectBeginDrag(Slot slot, InventoryObject obj)
 {
     _draggedSlot   = slot;
     _draggedObject = obj;
 }
Exemplo n.º 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
 }
Exemplo n.º 10
0
 public void OnObjectBeginDrag(Slot slot, InventoryObject obj)
 {
     //_context.DraggedObject.gameObject.SetActive(false);
 }
Exemplo n.º 11
0
 public virtual void OnObjectMoved(InventoryObject obj)
 {
     Color = _defaultColor;
     _object.OnMovedHandler -= OnObjectMoved;
     _object = null;
 }