Пример #1
0
        public override bool RayCast(GameTime gameTime)
        {
            if (MouseManager.MouseClicked && !EditorSelected)
            {
                if (Logic.Rect(Position.get(), Size.get(), Parent2DScene.DrawCamera.ViewMatrix).Contains(WorldViewer.self.RelativeMousePoint))
                {
                    if (!KeyboardManager.ControlPressed())
                    {
                        if (!KeyboardManager.ShiftPressed())
                        {
                            ParentScene.ClearSelected();
                        }
                        ParentScene.AddSelected(this);
                    }
                    else
                    {
                        if (EditorSelected)
                        {
                            ParentScene.RemoveSelected(this);
                        }
                        else
                        {
                            ParentScene.AddSelected(this);
                        }
                    }
                    ParentLevel.ModifyWindows();
                    return(true);
                }
            }
            else if (MouseManager.RMouseClicked)
            {
                if (Logic.Rect(Position.get(), Size.get(), Parent2DScene.DrawCamera.ViewMatrix).Contains(WorldViewer.self.RelativeMousePoint))
                {
                    if (!KeyboardManager.AltPressed())
                    {
                        ParentScene.ClearSelected();
                        ParentScene.AddSelected(this);
                        RightClick(gameTime);
                        ParentLevel.ModifyWindows();
                    }
                    else
                    {
                        Destroy();
                    }

                    return(true);
                }
            }
            return(false);
        }
        public override void Update(GameTime gameTime, Window Updater)
        {
            RelativeMouse = Updater.RelativeMousePoint;
            base.Update(gameTime, Updater);
            if (ContainsMouse)
            {
                GameObject MouseObject = ReturnMouseOver(Updater);
                HighlightedObject = MouseObject;

                if (MouseManager.MouseClicked)
                {
                    if (MouseObject != null)
                    {
                        bool ShouldSelect = !MouseObject.HierarchyDragRectangle.Contains(Updater.RelativeMousePoint);

                        if (KeyboardManager.ControlPressed())
                        {
                            if (MouseObject.EditorSelected)
                            {
                                ParentScene.RemoveSelected(MouseObject);
                            }
                            else
                            {
                                ParentScene.AddSelected(MouseObject);
                                MouseObject.LeftClick(gameTime);
                            }
                        }
                        else if (KeyboardManager.ShiftPressed())
                        {
                            ShiftSelect(MouseObject);
                            MouseObject.LeftClick(gameTime);
                        }
                        else
                        {
                            if (ShouldSelect)
                            {
                                ParentScene.ClearSelected();
                                ParentScene.AddSelected(MouseObject);
                                MouseObject.LeftClick(gameTime);
                            }
                            MouseManager.SetDraggedObject(MouseObject);
                        }

                        WorldViewer.self.NeedsToRedraw      = true;
                        ObjectProperties.self.NeedsToRedraw = true;
                    }
                }

                if (MouseManager.DraggedObject == null && MouseManager.PreviousDraggedObject != null && MouseManager.PreviousDraggedObject.GetType().IsSubclassOf(typeof(GameObject)))
                {
                    if (MouseObject != null && Updater.RelativeMousePoint.X < MouseObject.HierarchyBox.X + MouseObject.HierarchyBoxOutline.Width + 2)
                    {
                        MouseObject.HierarchyExpanded = !MouseObject.HierarchyExpanded;
                        MouseObject.ModifyCollection();
                    }
                    else if (MouseObject != null && MouseManager.PreviousDraggedObject != MouseObject)
                    {
                        GameObject g = MouseManager.PreviousDraggedObject as GameObject;
                        if (!g.HierarchyObjectIschild(MouseObject))
                        {
                            MouseObject.HierarchyExpanded = true;
                            MouseObject.AddHierarchyObject(g);
                        }
                    }
                }

                if (MouseManager.mouseState.RightButton == ButtonState.Pressed && MouseManager.mouseStatePrevious.RightButton == ButtonState.Released)
                {
                    if (MouseObject != null)
                    {
                        ParentScene.ClearSelected();
                        ParentScene.AddSelected(MouseObject);
                        MouseObject.RightClick(gameTime);

                        WorldViewer.self.NeedsToRedraw      = true;
                        ObjectProperties.self.NeedsToRedraw = true;
                        HierarchyViewer.self.NeedsToRedraw  = true;
                    }
                }
            }
            else
            {
                HighlightedObject = null;
            }
        }