Exemplo n.º 1
0
 public void setControlPointVisibility(bool vis, ObjectControlPoint ocp)
 {
     ocp.Sprite.Visible = vis;
     ocp.Sprite.Depth   = Sprite.Depth + .01f;
     ocp.Sprite.Color   = Sprite.Color;//Gob.CurrentLevel.BackgroundColor.invert().lerp(Microsoft.Xna.Framework.Color.Black, .5f);
     ocp.Sprite.Scale   = Vector.One * Math.Min(35, Math.Max(6, 20 / (CurrentLevel.Camera.Zoom * 1.2f)));
 }
Exemplo n.º 2
0
        public ObjectController(ObjectManager manager) : base(manager)
        {
            Sprite   = new Sprite();
            Unselect = false;
            convex   = new Convex(Vector.Zero, 0, VectorSet.Dodecahedren);

            ControlPointLightRadius = new ObjectControlPoint(manager);

            ControlPointRight    = new ObjectControlPoint(manager);
            ControlPointRightTop = new ObjectControlPoint(manager);
            ControlPointTop      = new ObjectControlPoint(manager);
            ControlPointLeftTop  = new ObjectControlPoint(manager);
            ControlPointLeft     = new ObjectControlPoint(manager);
            ControlPointLeftBot  = new ObjectControlPoint(manager);
            ControlPointBot      = new ObjectControlPoint(manager);
            ControlPointRightBot = new ObjectControlPoint(manager);
            ControlPoints        = new ObjectControlPoint[] { ControlPointRight, ControlPointRightTop, ControlPointTop, ControlPointLeftTop, ControlPointLeft, ControlPointLeftBot, ControlPointBot, ControlPointRightBot };
        }
Exemplo n.º 3
0
        public override void onUpdate()
        {
            if (Gob.Selected != null)
            {
                Vector mousePos = WhiskeyControl.InputManager.MousePosition;
                mousePos = WhiskeyControl.ActiveCamera.getGameCoordinate(mousePos);

                ObjectControlPoint cp = Gob.ControlPointLightRadius;

                Gob.setControlPointVisibility(Gob.Selected.Light.Visible, cp);


                cp.Position = Gob.Position + (Gob.Selected.Light.Radius / 2) * Vector.UnitX;
                cp.X        = cp.Position.X;
                cp.Y        = cp.Position.Y;


                if (WhiskeyControl.InputManager.isNewMouseDown(Whiskey2D.Core.Inputs.MouseButtons.Left) && Gob.Selected.Light.Visible)
                {
                    if (Gob.ControlPointLightRadius.Bounds.vectorWithin(mousePos))
                    {
                        dragging  = true;
                        startDrag = Gob.Selected.Position;
                    }
                }

                if (dragging && Gob.Selected.Light.Visible)
                {
                    Vector diff = mousePos - startDrag;
                    Gob.Selected.Light.Radius = diff.Length * 2;


                    if (!WhiskeyControl.InputManager.isMouseDown(Whiskey2D.Core.Inputs.MouseButtons.Left))
                    {
                        dragging = false;
                    }
                }
            }
        }
Exemplo n.º 4
0
        public override void onUpdate()
        {
            Vector mousePos = WhiskeyControl.InputManager.MousePosition;

            mousePos = WhiskeyControl.ActiveCamera.getGameCoordinate(mousePos);

            if (!WhiskeyControl.InputManager.isMouseDown(MouseButtons.Left))
            {
                //if (draggedOCP != null)
                //{
                //    process(mousePos);
                //}
                draggedOCP = null;
            }

            if (Gob.Selected != null)
            {
                showControlPoints();



                Matrix m = Matrix.Identity;
                m *= Matrix.CreateRotationZ(Gob.Sprite.Rotation);

                Gob.ControlPointRight.Position    = Gob.Position + (Vector)Vector2.Transform(new Vector(Gob.Bounds.Size.X / 2, 0), m);
                Gob.ControlPointRightTop.Position = Gob.Position + (Vector)Vector2.Transform(new Vector(Gob.Bounds.Size.X / 2, -Gob.Bounds.Size.Y / 2), m);
                Gob.ControlPointTop.Position      = Gob.Position + (Vector)Vector2.Transform(new Vector(0, -Gob.Bounds.Size.Y / 2), m);
                Gob.ControlPointLeftTop.Position  = Gob.Position + (Vector)Vector2.Transform(new Vector(-Gob.Bounds.Size.X / 2, -Gob.Bounds.Size.Y / 2), m);
                Gob.ControlPointLeft.Position     = Gob.Position + (Vector)Vector2.Transform(new Vector(-Gob.Bounds.Size.X / 2, 0), m);
                Gob.ControlPointLeftBot.Position  = Gob.Position + (Vector)Vector2.Transform(new Vector(-Gob.Bounds.Size.X / 2, Gob.Bounds.Size.Y / 2), m);
                Gob.ControlPointBot.Position      = Gob.Position + (Vector)Vector2.Transform(new Vector(0, Gob.Bounds.Size.Y / 2), m);
                Gob.ControlPointRightBot.Position = Gob.Position + (Vector)Vector2.Transform(new Vector(Gob.Bounds.Size.X / 2, Gob.Bounds.Size.Y / 2), m);



                if (draggedOCP == null && WhiskeyControl.InputManager.isNewMouseDown(MouseButtons.Left))
                {
                    foreach (ObjectControlPoint ocp in Gob.ControlPoints)
                    {
                        if (ocp.Bounds.vectorWithin(mousePos))
                        {
                            startDrag    = mousePos;
                            startDragMod = startDrag;
                            if (ocp == Gob.ControlPointRight || ocp == Gob.ControlPointRightTop || ocp == Gob.ControlPointRightBot)
                            {
                                startDragMod.X = Gob.Selected.Bounds.Right;
                            }
                            if (ocp == Gob.ControlPointLeft || ocp == Gob.ControlPointLeftTop || ocp == Gob.ControlPointLeftBot)
                            {
                                startDragMod.X = Gob.Selected.Bounds.Left;
                            }
                            if (ocp == Gob.ControlPointTop || ocp == Gob.ControlPointRightTop || ocp == Gob.ControlPointLeftTop)
                            {
                                startDragMod.Y = Gob.Selected.Bounds.Top;
                            }
                            if (ocp == Gob.ControlPointBot || ocp == Gob.ControlPointRightBot || ocp == Gob.ControlPointRightBot)
                            {
                                startDragMod.Y = Gob.Selected.Bounds.Bottom;
                            }

                            startScale = Gob.Selected.Sprite.Scale;
                            startPos   = Gob.Selected.Position;


                            //if (WhiskeyEditor.MonoHelp.WhiskeyControl.InputManager.isKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift))
                            //{
                            //    mousePos = GridManager.Instance.snap(mousePos);
                            //    //mousePos = GridManager.Instance.snapRound(mousePos);
                            //}

                            draggedOCP = ocp;

                            break;
                        }
                    }
                }

                if (draggedOCP != null && WhiskeyControl.InputManager.isMouseDown(MouseButtons.Left))
                {
                    process(mousePos);

                    //if (draggedOCP != null && !WhiskeyControl.InputManager.isMouseDown(MouseButtons.Left))
                    //{
                    //    draggedOCP = null;
                    //}
                }
            }
            else
            {
                //draggedOCP = null;
                hideControlPoints();
            }
        }