当前位置: 首页>>代码示例>>C#>>正文


C# InputHandler.GetMouseXY方法代码示例

本文整理汇总了C#中InputHandler.GetMouseXY方法的典型用法代码示例。如果您正苦于以下问题:C# InputHandler.GetMouseXY方法的具体用法?C# InputHandler.GetMouseXY怎么用?C# InputHandler.GetMouseXY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在InputHandler的用法示例。


在下文中一共展示了InputHandler.GetMouseXY方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateElements

        private void UpdateElements(InputHandler handler)
        {
            if (draggedElement == null)
            {
                #region If Mouse Pressed
                if (handler.CheckLeftMouseJustPressed())
                {
                    #region Check if an Element was Clicked
                    for (int i = 0;i < elements.Count; i++)
                    {
                        var element = elements[elements.Count - i - 1];
                        if (handler.CheckMouseIn(element))
                        {
                            #region Set as Dragged Object
                            draggedElement = element;
                            originalPoint = element.GetPoint();
                            elements.Remove(element);
                            elements.Add(element);
                            #endregion
                            break;
                        }
                    }
                    #endregion

                }
                #endregion
            }
            else
            {
                if (dragging)
                {

                    if (handler.CheckLeftMouseJustReleased())
                    {
                        //Just in case stuff needs to be done.
                        #region Release Dragged Object
                        UpdateInteraction(handler);
                        if (draggedElement != null && draggedElement.GetX() < widthOfMenu)
                        {
                            RemoveElement(draggedElement);
                        }
                        draggedElement = null;
                        dragging = false;

                        #endregion
                    }
                    else
                    {
                        #region Set the X and Y of the Dragged Object
                        draggedElement.SetX(originalPoint.X + handler.LeftMouseDraggedBy().X);
                        draggedElement.SetY(originalPoint.Y + handler.LeftMouseDraggedBy().Y);
                        #endregion
                    }
                }
                else
                {
                    #region Detect if Dragged Piece was actually moved.
                    if (!(handler.LeftMouseDraggedBy().X == 0 && handler.LeftMouseDraggedBy().Y == 0))
                    {
                        dragging = true;
                        #region Removes the element from a slot.
                        if (draggedElement.GetElement() is DragDropVariablePlaceholder)
                        {
                            if (((DragDropVariablePlaceholder)draggedElement.GetElement()).HasVariable())
                            {
                                elements.Add(((DragDropVariablePlaceholder)draggedElement.GetElement()).PopVariable());
                                draggedElement = elements[elements.Count - 1];
                                originalPoint = handler.GetMouseXY();
                            }
                        }
                        #endregion
                        else
                        #region Removes the element from a slot that is contained in another piece
                        if (draggedElement.GetElement().GetTopInteracting(handler) is DragDropVariablePlaceholder)
                        {
                            DragDropVariablePlaceholder slot = (DragDropVariablePlaceholder)((DragDropVariablePlaceholder)draggedElement.GetElement().GetTopInteracting(handler)).GetInnerMostDragDrop(handler);

                            if ((slot).HasVariable())
                            {
                                elements.Add((slot).PopVariable());
                                draggedElement = elements[elements.Count - 1];

                                originalPoint = handler.GetMouseXY();
                            }
                        }
                        #endregion
                    }
                    #endregion
                    else
                    #region If the piece is released, select it.
                        if (handler.CheckLeftMouseJustReleased())
                        {
                            if (selectedElement != null && selectedElement != draggedElement) selectedElement.GetElement().TellSelected(false);
                            draggedElement.GetElement().GetInteracting(handler).TellSelected(true);
                            selectedElement = draggedElement;
                            draggedElement = null;
                        }
                    #endregion
                }

//.........这里部分代码省略.........
开发者ID:TheCreatorJames,项目名称:TajTetrisGame,代码行数:101,代码来源:DragDropInterface.cs

示例2: UpdateSuggestions

        private void UpdateSuggestions(InputHandler handler)
        {
            if (draggedElement != null) return;

            if(handler.CheckLeftMouseJustPressed())
            foreach(LooseDragDropLink link in suggestions)
            {
                if(handler.CheckMouseIn(link))
                {
                    suggestedElement = link;
                    break;
                }
            }

            if (handler.CheckLeftMouseJustReleased())
            {
                suggestedElement = null;
            }

            if(suggestedElement != null)
            if (!(handler.LeftMouseDraggedBy().X == 0 && handler.LeftMouseDraggedBy().Y == 0))
            {
                elements.Add(new LooseDragDropLink(suggestedElement.GetElement().Clone()));
                draggedElement = elements[elements.Count - 1];
                Point XY = handler.GetMouseXY();
                originalPoint = XY;
                elements[elements.Count - 1].SetPoint(ref XY);
            }
        }
开发者ID:TheCreatorJames,项目名称:TajTetrisGame,代码行数:29,代码来源:DragDropInterface.cs

示例3: Update


//.........这里部分代码省略.........
                                    dragged = couldDrag;

                                    if (bringToFront)
                                    {
                                        objects.Remove(dragged);
                                        objects.Add(dragged);
                                    }
                                    dragged.SetEditing(!hideEditing);
                                }
                }

                if (handler.CheckRightMouseJustPressed())
                    if (!modifyingOne && couldDrag != null && !dragging)
                    {
                        objects.Remove(couldDrag);
                        couldDrag = null;
                    }

                if (handler.CheckLeftMouseJustReleased())
                {
                    draggingColor = 0;
                    if (dragged != null)
                    {
                        dragged.SetEditing(!hideEditing);
                        dragging = false;
                        dragged = null;
                        couldDrag = null;
                        original = Point.Zero;
                    }
                }

                if (draggingColor != 0 && colorize != null)
                {
                    Point n = handler.GetMouseXY();

                    original = new Point(originX, originY);

                    n -= original;
                    if (n.X >= 130)
                    {
                        n.X = 130;
                    }

                    if (n.Y >= 130)
                    {
                        n.Y = 130;
                    }

                    if (n.Y <= -130)
                    {
                        n.Y = -130;
                    }

                    if (n.X <= -130)
                    {
                        n.X = -130;
                    }

                    if (draggingColor == 1)
                    {
                        //r

                        r.SetPoint(original + n);

                    }
                    else
开发者ID:TheCreatorJames,项目名称:TajTetrisGame,代码行数:67,代码来源:WorldEditor.cs


注:本文中的InputHandler.GetMouseXY方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。