Exemplo n.º 1
0
        public override void Mouse(MouseState state, MouseState oldState)
        {
            var     pos      = CCDrawManager.ScreenToWorld(state.X, state.Y);
            Vector2 position = new Vector2(pos.X, pos.Y);

            if (state.RightButton == ButtonState.Pressed)
            {
                DrawCircleOnMap(position, -1);
                _terrain.RegenerateTerrain();

                DebugView.BeginCustomDraw();
                DebugView.DrawSolidCircle(position, _circleRadius, Vector2.UnitY, Color.Blue * 0.5f);
                DebugView.EndCustomDraw();
            }

            if (state.LeftButton == ButtonState.Pressed)
            {
                DrawCircleOnMap(position, 1);
                _terrain.RegenerateTerrain();

                DebugView.BeginCustomDraw();
                DebugView.DrawSolidCircle(position, _circleRadius, Vector2.UnitY, Color.Red * 0.5f);
                DebugView.EndCustomDraw();
            }

            if (state.MiddleButton == ButtonState.Pressed)
            {
                Body circle = BodyFactory.CreateCircle(World, 1, 1);
                circle.BodyType = BodyType.Dynamic;
                circle.Position = position;
            }
        }
Exemplo n.º 2
0
        private void DrawFixture(Fixture fixture)
        {
            Color     color = new Color(0.95f, 0.95f, 0.6f);
            Transform xf    = fixture.Body.GetTransform();

            switch (fixture.Shape.ShapeType)
            {
            case ShapeType.Circle:
            {
                CircleShape circle = (CircleShape)fixture.Shape;

                Vector2 center = Transform.Multiply(circle.Position, ref xf);
                float   radius = circle.Radius;

                DebugDraw.DrawSolidCircle(center, radius, Vector2.Zero, color);
            }
            break;

            case ShapeType.Polygon:
            {
                PolygonShape poly        = (PolygonShape)fixture.Shape;
                int          vertexCount = poly.Vertices.Count;
                Debug.Assert(vertexCount <= Settings.MaxPolygonVertices);
                Vector2[] vertices = new Vector2[Settings.MaxPolygonVertices];

                for (int i = 0; i < vertexCount; ++i)
                {
                    vertices[i] = Transform.Multiply(poly.Vertices[i], ref xf);
                }

                DebugDraw.DrawSolidPolygon(vertices, vertexCount, color);
            }
            break;
            }
        }
Exemplo n.º 3
0
        public override void MouseDown(MouseEventArgs e, Vector2 p)
        {
            Vector2 position = p;

            if (e.Button == MouseButtons.Right)
            {
                DrawCircleOnMap(position, -1);
                _terrain.RegenerateTerrain();


                DebugView.DrawSolidCircle(position, _circleRadius, Vector2.UnitY, Color.Blue * 0.5f);
            }
            else if (e.Button == MouseButtons.Left)
            {
                DrawCircleOnMap(position, 1);
                _terrain.RegenerateTerrain();


                DebugView.DrawSolidCircle(position, _circleRadius, Vector2.UnitY, Color.Red * 0.5f);
            }
            else if (e.Button == MouseButtons.Middle)
            {
                Body circle = BodyFactory.CreateCircle(World, 1, 1);
                circle.BodyType = BodyType.Dynamic;
                circle.Position = position;
            }
        }
Exemplo n.º 4
0
        public override void Mouse(MouseState state, MouseState oldState)
        {
            Vector2 position = GameInstance.ConvertScreenToWorld(state.X, state.Y);

            if (state.RightButton == ButtonState.Pressed)
            {
                DrawCircleOnMap(position, -1);
                _terrain.RegenerateTerrain();

                DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View);
                DebugView.DrawSolidCircle(position, _circleRadius, Vector2.UnitY, Color.Blue * 0.5f);
                DebugView.EndCustomDraw();
            }
            else if (state.LeftButton == ButtonState.Pressed)
            {
                DrawCircleOnMap(position, 1);
                _terrain.RegenerateTerrain();

                DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View);
                DebugView.DrawSolidCircle(position, _circleRadius, Vector2.UnitY, Color.Red * 0.5f);
                DebugView.EndCustomDraw();
            }
            else if (state.MiddleButton == ButtonState.Pressed)
            {
                Body circle = World.CreateCircle(1, 1);
                circle.BodyType = BodyType.Dynamic;
                circle.Position = position;
            }
        }
Exemplo n.º 5
0
        public override void Mouse(MouseManager mouse)
        {
            Vector2 position = GameInstance.ConvertScreenToWorld(mouse.NewPosition);

            if (mouse.IsButtonDown(MouseButton.Left))
            {
                DrawCircleOnMap(position, (sbyte)(_create ? -1 : 1));
                _terrain.RegenerateTerrain();

                DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View);
                DebugView.DrawSolidCircle(position, _circleRadius, Vector2.UnitY, Color.Red * 0.5f);
                DebugView.EndCustomDraw();
            }
            else if (mouse.IsButtonDown(MouseButton.Middle))
            {
                Body circle = BodyFactory.CreateCircle(World, 1, 1);
                circle.BodyType = BodyType.Dynamic;
                circle.Position = position;
            }
        }