// Override meant to remove item from slot on grab protected override void OnGrab() { if (this.IsFull()) { DragAndDropController.Instance().Grab(Pop(), this); } }
private void AttemptGrab() { if (isMovable && !DragAndDropController.Instance().IsHolding()) { this.OnGrab(); } }
public override void OnDrop() { if (DragAndDropController.IsOccupied()) { var dropped = DragAndDropController.Instance().Drop(); BehaviorLabController.GetShared().RemoveBlock(dropped); Destroy(dropped.gameObject); } }
// Display indicator of where a dragged item would go if it can protected override void OnOver() { if (DragAndDropController.IsOccupied()) { indicator.SetActive(true); indicator.transform.position = FindBlockPosition(DragAndDropController.Instance().OffsetMousePosition()); } }
// Override meant to remove grabbed item from list protected override void OnGrab() { if (blocks.Count > 0) { int index = FindHoverIndex(DragAndDropController.Instance().MousePosition()); DragAndDropController.Instance().Grab(RemoveAt(index), this); // TODO: update position of all elements after index } }
// TODO: this should be fixed to only give Blocks to drag and drop // Default implementation is to select the top level object protected virtual void OnGrab() { if (this.IsTopLevel()) { DragAndDropController.Instance().Grab(this); } else { this.container.OnGrab(); } }
protected override void OnGrab() { if (IsActive() && DragAndDropController.IsAvailable()) { var block = Block.FromType(type); block.info.ID = BehaviorLabController.GetShared().NextBlockID(); block.transform.SetPositionAndRotation(gameObject.transform.position, gameObject.transform.rotation); DragAndDropController.Instance().Grab(block); BehaviorLabController.GetShared().AddBlock(block); } }
// Override meant to add drop to this slot if there is space available public override void OnDrop() { if (this.IsFull()) { // TODO: drop should also reset if dropped doesn't match type. DragAndDropController.Instance().ResetDrop(); } else { Push(DragAndDropController.Instance().Drop()); } }
// Override meant to place item into index corresponding to it's position (upon dropping) public override void OnDrop() { if (DragAndDropController.IsOccupied()) { if (MatchesOutputType(DragAndDropController.Instance().GetHeld())) { Block block = DragAndDropController.Instance().Drop(); int index = FindHoverIndex(block.transform.position); Insert(index + 1, block); // TODO: update position of all elements after index (including newly added element) } else { DragAndDropController.Instance().ResetDrop(); } } }
protected void OnMouseExit() { DragAndDropController.Instance().HoverOff(this); this.OnExit(); }
protected void OnMouseOver() { DragAndDropController.Instance()?.HoverOn(this); this.OnOver(); }
// Default implementation is to reset position when dropped on top of another interface object public virtual void OnDrop() { DragAndDropController.Instance().ResetDrop(); }