Exemplo n.º 1
0
        private void OnHolderRemoved(DragHolder inHolder, DragObject inObject)
        {
            ExpressionPiece piece = inObject.GetComponent <ExpressionPiece>();

            if (Expression[PieceIndex] == piece)
            {
                Expression[PieceIndex] = null;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Attempts to finish a drag at the given drag space position.
        /// </summary>
        public void EndDrag(DragHolder inHolder)
        {
            if (DraggingObject != null)
            {
                DragEndState endState;
                DragObject   dragObject = DraggingObject;
                DraggingObject = null;

                if (inHolder == null)
                {
                    endState = DragEndState.Empty;
                }
                else
                {
                    if (inHolder.AllowAddObject(dragObject))
                    {
                        dragObject.SetOwner(inHolder);
                        endState = DragEndState.ValidZone;
                    }
                    else
                    {
                        LastValidSeat lastSeat      = dragObject.GetComponent <LastValidSeat>();
                        bool          bValidSwap    = lastSeat != null && lastSeat.LastValidHolder != null;
                        DragObject    swappedObject = null;
                        if (bValidSwap)
                        {
                            bValidSwap = inHolder.AllowSwapObject(dragObject, out swappedObject);
                        }
                        if (bValidSwap)
                        {
                            bValidSwap = lastSeat.LastValidHolder.AllowAddObject(swappedObject);
                        }

                        if (bValidSwap)
                        {
                            swappedObject.SetOwner(lastSeat.LastValidHolder);
                            dragObject.SetOwner(inHolder);
                            endState = DragEndState.ValidZone;
                        }
                        else
                        {
                            endState = DragEndState.InvalidZone;
                        }
                    }
                }

                dragObject.DraggingStops(endState);

                if (OnDragEnd != null)
                {
                    OnDragEnd(dragObject, endState);
                }
            }
        }
Exemplo n.º 3
0
        private void OnHolderAdded(DragHolder inHolder, DragObject inObject)
        {
            ExpressionPiece piece = inObject.GetComponent <ExpressionPiece>();

            Expression[PieceIndex] = piece;
        }