示例#1
0
        /**
         * <summary>Performs the drag.</summary>
         * <param name = "_dragVector">The amount and direction to drag by</param>
         * <returns>True if the drag effect was successful</returns>
         */
        public bool DoDrag(Vector2 _dragVector)
        {
            if (dragType == DragElementType.EntireMenu)
            {
                if (menuToDrag == null)
                {
                    return(false);
                }

                if (!menuToDrag.IsEnabled() || menuToDrag.IsFading())
                {
                    return(false);
                }
            }

            if (elementToDrag == null && dragType == DragElementType.SingleElement)
            {
                return(false);
            }

            // Convert dragRect to screen co-ordinates
            Rect dragRectAbsolute = dragRect;

            if (sizeType != AC_SizeType.AbsolutePixels)
            {
                Vector2 sizeFactor = KickStarter.mainCamera.GetPlayableScreenArea(false).size;
                dragRectAbsolute = new Rect(dragRect.x * sizeFactor.x / 100f,
                                            dragRect.y * sizeFactor.y / 100f,
                                            dragRect.width * sizeFactor.x / 100f,
                                            dragRect.height * sizeFactor.y / 100f);
            }

            if (dragType == DragElementType.EntireMenu)
            {
                menuToDrag.SetDragOffset(_dragVector + dragStartPosition, dragRectAbsolute);
            }
            else if (dragType == AC.DragElementType.SingleElement)
            {
                elementToDrag.SetDragOffset(_dragVector + dragStartPosition, dragRectAbsolute);
            }

            return(true);
        }
示例#2
0
        /**
         * <summary>Performs the drag.</summary>
         * <param name = "_dragVector">The amount and direction to drag by</param>
         * <returns>True if the drag effect was successful</returns>
         */
        public bool DoDrag(Vector2 _dragVector)
        {
            if (dragType == DragElementType.EntireMenu)
            {
                if (menuToDrag == null)
                {
                    return(false);
                }

                if (!menuToDrag.IsEnabled() || menuToDrag.IsFading())
                {
                    return(false);
                }
            }

            if (elementToDrag == null && dragType == DragElementType.SingleElement)
            {
                return(false);
            }

            // Convert dragRect to screen co-ordinates
            Rect dragRectAbsolute = dragRect;

            if (sizeType != AC_SizeType.AbsolutePixels)
            {
                dragRectAbsolute = new Rect(dragRect.x * AdvGame.GetMainGameViewSize(true).x / 100f,
                                            dragRect.y * AdvGame.GetMainGameViewSize(true).y / 100f,
                                            dragRect.width * AdvGame.GetMainGameViewSize(true).x / 100f,
                                            dragRect.height * AdvGame.GetMainGameViewSize(true).y / 100f);
            }

            if (dragType == DragElementType.EntireMenu)
            {
                menuToDrag.SetDragOffset(_dragVector + dragStartPosition, dragRectAbsolute);
            }
            else if (dragType == AC.DragElementType.SingleElement)
            {
                elementToDrag.SetDragOffset(_dragVector + dragStartPosition, dragRectAbsolute);
            }

            return(true);
        }