Inheritance: BaseSystem
Exemplo n.º 1
0
        public RenderData(Midgard midgard, Entity entity, ContentManager manager)
        {
            var text = manager.Load<Texture2D>("roguelikeChar_transparent");

            TextureRegion2D region = new TextureRegion2D(text, 0, 0, 16, 16);
            _sprite = new Sprite(region);
            _sprite.Scale = new Vector2(1, 1);

            CreatePhysics(midgard, entity);
        }
Exemplo n.º 2
0
        public void Setup(Midgard world,  long ballId = 0)
        {
            var manager = world.EntityManager;
            if (ballId > 0)
            {
                _entity = manager.GetEntityByUniqueId(ballId);
                if (_entity == null)
                    _entity = manager.Create(ballId);
            }
            else
            {
                _entity = manager.Create();
            }

            var phyComp = world.CreateComponent(_entity, BodyDef);
            var body = phyComp.Body;

            CircleShape shape = new CircleShape(1,1);
            var fix = body.CreateFixture(shape);
            fix.Restitution = 1;
        }
Exemplo n.º 3
0
        private void CreatePhysics(Midgard midgard, Entity entity, bool usePos = true)
        {
            var comp = midgard.CreateComponent(entity,
                            new BodyDefinition()
                            {
                                Position = usePos ? new Farseer.Framework.Vector2(18f + (float)rnd.Next(0, 4), 17f + (float)rnd.Next(0, 3)) :
                                new Farseer.Framework.Vector2(0, 0)
                            });

            Vertices rectangleVertices = PolygonTools.CreateRectangle(0.5f, 0.2f,
                new Farseer.Framework.Vector2(0f, 0.4f), 0f);
            PolygonShape shape = new PolygonShape(rectangleVertices, 10000f);
            var fix = comp.Body.CreateFixture(shape);
            comp.Body.FixedRotation = true;
            comp.Body.Mass = 1000f;
            comp.Body.Restitution = 1f;
            comp.Body.CollisionCategories = FarseerPhysics.Dynamics.Category.Cat2;
            comp.Body.CollidesWith = FarseerPhysics.Dynamics.Category.Cat1;
        }