Example #1
0
 public Image(ControlHandler parent, string name, Texture2D texture)
     : base(parent, name)
 {
     ImageRender = new ImageRender(this, "ImageRender", texture);
     ImageRender.LinkDependency(ImageRender.DEPENDENCY_BODY, Body);
     Selectable = false;
 }
        public override void Initialize()
        {
            base.Initialize();

            ControlHandler ch = new ControlHandler(this);
            Page page = new Page(this, "Page");
            page.Show();
            //Add our labels to the top
            _drawingtoolsTitle = new Label(page, "drawingtoolsTitle", new Point(0, 0));
            _drawingtoolsTitle.Text = "DrawingTools.Primitives";
            _drawingtoolsTitle.Body.Position = new Vector2(EntityGame.Viewport.Width / 4 - _drawingtoolsTitle.Render.DrawRect.Width / 2, 15);

            _renderTitle = new Label(page, "renderTitle", new Point(1, 0));
            _renderTitle.Text = "Rendering.Primitives";
            _renderTitle.Body.Position = new Vector2(EntityGame.Viewport.Width - (EntityGame.Viewport.Width / 4) - _renderTitle.Render.DrawRect.Width / 2, 15);

            _middleLine = new DrawingTools.Line(new Vector2(EntityGame.Viewport.Width / 2f, 10), new Vector2(EntityGame.Viewport.Width / 2f, EntityGame.Viewport.Height - 10));

            //Setup our prmitives
            _r1 = new DrawingTools.Rectangle(20, 40, 260, 60);
            _r1.Color = Color.Salmon;
            _r1.Fill = true;

            //Horizontal Lines
            _lx1 = new DrawingTools.Line(new Vector2(20, 105), new Vector2(270, 105), Color.Red);
            _lx1.Thickness = 1;

            _lx2 = new DrawingTools.Line(new Vector2(20, 110), new Vector2(270, 110), Color.Orange);
            _lx2.Thickness = 2;

            _lx3 = new DrawingTools.Line(new Vector2(20, 115), new Vector2(270, 115), Color.Yellow);
            _lx3.Thickness = 3;

            _ly1 = new DrawingTools.Line(new Vector2(270, 120), new Vector2(270, 290), Color.MediumPurple);
            _ly1.Thickness = 1;

            _ly2 = new DrawingTools.Line(new Vector2(275, 120), new Vector2(275, 290), Color.DodgerBlue);
            _ly2.Thickness = 2;

            _ly3 = new DrawingTools.Line(new Vector2(280, 120), new Vector2(280, 290), Color.LawnGreen);
            _ly3.Thickness = 3;

            //Add component based classes
            new SpinningRect(this, "Spinning", EntityGame.Viewport.Width / 2f + 75, 200, 30, 30, false, 3);
            new SpinningRect(this, "Spinning", EntityGame.Viewport.Width / 2f + 75, 200, 30, 30, false, 2);
            new SpinningRect(this, "Spinning", EntityGame.Viewport.Width / 2f + 75, 200, 30, 30, false, 1);
            new SpinningRect(this, "Spinning", EntityGame.Viewport.Width / 2f + 150 + 75, 200, 30, 30, true);

            new SpinningRect(this, "Spinning", EntityGame.Viewport.Width / 2f + 75, 300, 70, 30, false, 3);
            new SpinningRect(this, "Spinning", EntityGame.Viewport.Width / 2f + 75, 300, 70, 30, false, 2);
            new SpinningRect(this, "Spinning", EntityGame.Viewport.Width / 2f + 75, 300, 70, 30, false, 1);
            new SpinningRect(this, "Spinning", EntityGame.Viewport.Width / 2f + 150 + 75, 300, 30, 70, true);
        }
        public override void Initialize()
        {
            base.Initialize();

            ControlHandler ch = new ControlHandler(this);

            _collided = new SortedSet<string>();

            Page p = new Page(this, "Page");
            p.Show();

            _collidedLabel = new Label(p, "CollidedLabel", new Point(0, 0));
            _collidedLabel.Body.Position = new Vector2(10, 500);

            Random rand = new Random();

            for (int x = 0; x < 3; x++)
            {
                AabbNode c = new AabbNode(this, "A" + x);
                c.Collision.Group.AddMask(0);
                c.Collision.Pair.AddMask(0);
                c.Collision.CollideEvent += manifold => _collided.Add(manifold.A != c.Collision ? manifold.A.Parent.Name : manifold.B.Parent.Name);
                c.Collision.Debug = true;
                c.Body.Position = new Vector2(0, 100 * x + 20);
                c.Shape.Debug = true;
            }
            for (int x = 0; x < 3; x++)
            {
                AabbNode c = new AabbNode(this, "B" + x);
                c.Collision.Group.AddMask(1);
                c.Collision.Pair.AddMask(0);
                c.Collision.CollideEvent += manifold => _collided.Add(manifold.A != c.Collision ? manifold.A.Parent.Name : manifold.B.Parent.Name);
                c.Body.Position = new Vector2(510, 80 * x + 20);
                c.Color = Color.Orange;
                c.HoverColor = Color.Black;
                c.Collision.Debug = true;
            }

            for (int x = 0; x < 3; x++)
            {
                CircleNode c = new CircleNode(this, "C" + x);
                c.Collision.Group.AddMask(2);
                c.Collision.Pair.AddMask(2);
                c.Collision.CollideEvent += manifold => _collided.Add(manifold.A != c.Collision ? manifold.A.Parent.Name : manifold.B.Parent.Name); ;
                c.Body.Position = new Vector2(80 * x + 20, 300);
                c.Color = Color.LightBlue;
                c.HoverColor = Color.DarkRed;
                c.Shape.Debug = true;
            }
        }
        public override void Initialize()
        {
            base.Initialize();

            _cte = new CameraTestNode(this, "CTE");

            new CameraNode(this, "CE");

            //add a label to track screen space
            var ch = new ControlHandler(this);

            //TODO: Add labels to find camera screen space and values
            //var label = new Label(ch, "CamLabel");
        }
        public override void Initialize()
        {
            base.Initialize();
            //Add our services
            var controlHandler = new ControlHandler(this);
            _testControlManager = new TestControlManager(this);

            for (int x = 0; x < 4; x++)
                for (int y = 0; y < 4; y++)
                {
                    var testControl = new LinkLabel(_testControlManager, "TC-X" + x + "Y" + y, new Point(x, y))
                        {
                            Body = { Position = new Vector2(x * 135 + 40, y * 30 + 50) },
                        };
                    testControl.OnReleased += OnSelected;
                    //Set the default control.
                    if (x == 0 && y == 0)
                        testControl.OnFocusGain();
                }

            _actionLabel = new Label(_testControlManager, "TestContolLabel", new Point(5, 2));
            _actionLabel.Text = "TestControlLabel";
            _actionLabel.Body.Position = new Vector2(50, 400);
        }
        public override void Initialize()
        {
            base.Initialize();

            ControlHandler ch = new ControlHandler(this);

            _ptm = new ParticleTestManager(this);

            var page = new Page(this, "Page");
            page.Show();

            _screeninfo = new Label(page, "ScreenInfo", new Point(0, 0));
            _screeninfo.Body.Position = Vector2.One * 20;

            _strengthText = new Label(page, "StrengthText", new Point(0, 1));
            _strengthText.Text = "Strength:";
            _strengthText.Body.Position = new Vector2(20, 50);

            _strengthDown = new LinkLabel(page, "StrengthDown", new Point(1, 1));
            _strengthDown.Text = "<-";
            _strengthDown.Body.Position = new Vector2(_strengthText.Body.BoundingRect.Right + 5, 50);
            _strengthDown.OnDown += control => _ptm.Spawner.Strength -= STRENGTHSTEP;

            _strengthValue = new Label(page, "StrengthValue", new Point(2, 1));
            _strengthValue.Text = _ptm.Spawner.Strength.ToString();
            _strengthValue.Body.Position = new Vector2(_strengthDown.Body.BoundingRect.Right + 5, 50);

            _strengthUp = new LinkLabel(page, "StrengthUp", new Point(3, 1));
            _strengthUp.Text = "->";
            _strengthUp.Body.Position = new Vector2(_strengthValue.Body.BoundingRect.Right + 5, 50);
            _strengthUp.OnDown += control => _ptm.Spawner.Strength += STRENGTHSTEP;

            _gravityText = new Label(page, "GravityText", new Point(0, 2));
            _gravityText.Text = "Gravity:";
            _gravityText.Body.Position = new Vector2(20, 80);

            _gravityXDown = new LinkLabel(page, "GravityXDown", new Point(1, 2));
            _gravityXDown.Text = "<-";
            _gravityXDown.Body.Position = new Vector2(_gravityText.Body.BoundingRect.Right + 5, 80);
            _gravityXDown.OnDown += control => _ptm.Spawner.Acceleration.X -= GRAVITYSTEP;

            _gravityXValue = new Label(page, "GravityXValue", new Point(2, 2));
            _gravityXValue.Text = "X:" + _ptm.Spawner.Acceleration.X.ToString();
            _gravityXValue.Body.Position = new Vector2(_gravityXDown.Body.BoundingRect.Right + 5, 80);

            _gravityXUp = new LinkLabel(page, "GravityXUp", new Point(3, 2));
            _gravityXUp.Text = "->";
            _gravityXUp.Body.Position = new Vector2(_gravityXValue.Body.BoundingRect.Right + 5, 80);
            _gravityXUp.OnDown += control => _ptm.Spawner.Acceleration.X += GRAVITYSTEP;

            _gravityYDown = new LinkLabel(page, "GravityYDown", new Point(1, 3));
            _gravityYDown.Text = "<-";
            _gravityYDown.Body.Position = new Vector2(_gravityText.Body.BoundingRect.Right + 5, 110);
            _gravityYDown.OnDown += control => _ptm.Spawner.Acceleration.Y -= GRAVITYSTEP;

            _gravityYValue = new Label(page, "GravityYValue", new Point(2, 3));
            _gravityYValue.Text = "Y:" + _ptm.Spawner.Acceleration.Y.ToString();
            _gravityYValue.Body.Position = new Vector2(_gravityYDown.Body.BoundingRect.Right + 5, 110);

            _gravityYUp = new LinkLabel(page, "GravityYUp", new Point(3, 3));
            _gravityYUp.Text = "->";
            _gravityYUp.Body.Position = new Vector2(_gravityYValue.Body.BoundingRect.Right + 5, 110);
            _gravityYUp.OnDown += control => _ptm.Spawner.Acceleration.Y += GRAVITYSTEP;
        }
            public ParticleTestManager(State stateref)
                : base(stateref, "ParticleTestManager")
            {
                _controlHandler = stateref.GetService<ControlHandler>();
                _body = new Body(this, "EmitterBody");
                Spawner = new TestSpawner(this, "Spawner");

                _moveCursor = new GamePadAnalog(this, "MoveCursor", Sticks.Left, PlayerIndex.One);
                _emitButton = new GamepadInput(this, "EmitButton", Buttons.B, PlayerIndex.One);
            }