public override bool RayCast(GameTime gameTime)
        {
            foreach (GameObject o in Children)
            {
                if (o.RayCast(gameTime))
                {
                    return(true);
                }
            }

            if (!KeyboardManager.AltPressed())
            {
                return(objectControls.RayCast(gameTime));
            }
            else
            {
                if (MouseManager.MouseClicked && CreatorBasic.LastCreator != null)
                {
                    GameObject o = CreatorBasic.LastCreator.ReturnObject();
                    ParentLevel.AddObject(o);
                    if (o.GetType().IsSubclassOf(typeof(Basic2DObject)))
                    {
                        Basic2DObject b = (Basic2DObject)o;
                        b.Position.set(Vector2.Transform(WorldViewer.self.RelativeMousePosition, Matrix.Invert(DrawCamera.ViewMatrix)));
                        ClearSelected();
                        AddSelected(b);
                        if (UseGrid.get())
                        {
                            SnapSelected();
                        }
                    }
                }
                return(true);
            }
        }
Esempio n. 2
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);
        }