public void StartDragging(IDragAndDropNode startNode) { _currentDraggable = startNode.GetDraggable(); if (_currentDraggable != null) { _startNode = startNode; foreach (IDragAndDropNode node in _nodes) { if (!node.Equals(startNode)) node.OnDragStarted(_currentDraggable); } } }
public void OnDrop(IDragAndDropNode dropNode) { if (dropNode.OnDrop(_currentDraggable) && _startNode != dropNode) _startNode.OnDragFinished(); else _startNode.OnDragCancelled(); foreach (IDragAndDropNode node in _nodes) { if (!node.Equals(_startNode) && !node.Equals(dropNode)) node.OnDragCancelled(); } }
private static bool IsNodeInPosition(IDragAndDropNode node, Vector2 position) { var minX = node.GetDragableTopLeftCorner().x; var minY = node.GetDragableTopLeftCorner().y; var maxX = node.GetDragableBottomRightCorner().x; var maxY = node.GetDragableBottomRightCorner().y; return position.x > minX && position.y > minY && position.x < maxX && position.y < maxY; }
public void RemoveNode(IDragAndDropNode node) { _nodes.Remove(node); }
public void AddNode(IDragAndDropNode node) { _nodes.Add(node); }