コード例 #1
0
        public override JabActor CreateBox(Vector2 dim, Vector2 pos, JabActor.BodyType bodytype)
        {
            try
            {
                dim /= 100;
                FarActor actor = new FarActor();
                actor.body          = new Body(world);// world.CreateBody();
                actor.body.UserData = actor;
                Vector2  center = new Vector2(-dim.X, -dim.Y) / 2.0f;
                Vertices box    = PolygonTools.CreateRectangle(dim.X / 2.0f, dim.Y / 2.0f, center, 0);
                for (int i = 0; i < box.Count(); i++)
                {
                    Vector2 vert = box[i];
                    vert.X += dim.X / 2.0f;
                    vert.Y += dim.Y / 2.0f;
                    box[i]  = vert;
                    vert    = box[i];
                }
                PolygonShape shape = new PolygonShape(box, 1.0f);
                actor.BodyState = bodytype;
                actor.body.CreateFixture(shape, 1.0f);
                actor.Position = pos;
                actor.Width    = dim.X * 100;
                actor.Height   = dim.Y * 100;

                actors.Add(actor);
                return(actor);
            }
            catch (Exception e)
            {
                return(null);
            }
        }
コード例 #2
0
ファイル: FarWorld.cs プロジェクト: meds/ChicksnVixens
        public override JabActor CreateBox(Vector2 dim, Vector2 pos, JabActor.BodyType bodytype)
        {
            try
            {
                dim /= 100;
                FarActor actor = new FarActor();
                actor.body = new Body(world);// world.CreateBody();
                actor.body.UserData = actor;
                Vector2 center = new Vector2(-dim.X, -dim.Y) / 2.0f;
                Vertices box = PolygonTools.CreateRectangle(dim.X / 2.0f, dim.Y / 2.0f, center, 0);
                for (int i = 0; i < box.Count(); i++)
                {
                    Vector2 vert = box[i];
                    vert.X += dim.X / 2.0f;
                    vert.Y += dim.Y / 2.0f;
                    box[i] = vert;
                    vert = box[i];
                }
                PolygonShape shape = new PolygonShape(box, 1.0f);
                actor.BodyState = bodytype;
                actor.body.CreateFixture(shape, 1.0f);
                actor.Position = pos;
                actor.Width = dim.X * 100;
                actor.Height = dim.Y * 100;

                actors.Add(actor);
                return actor;
            }
            catch (Exception e)
            {
                return null;
            }
        }
コード例 #3
0
        public override JabActor CreateSphere(float radius, Vector2 pos, JabActor.BodyType bodytype)
        {
            try
            {
                radius /= 100;
                FarActor actor = new FarActor();
                actor.body          = new Body(world);// world.CreateBody();
                actor.body.UserData = actor;

                Vector2 center = new Vector2(-radius, -radius) / 2.0f;
                //  FarseerPhysics.Settings.MaxPolygonVertices = 33;
                Vertices sphere = PolygonTools.CreateCircle(radius, 32);

                PolygonShape shape = new PolygonShape(sphere, 1.0f);
                actor.BodyState = bodytype;
                actor.body.CreateFixture(shape, 1.0f);
                actor.Position = pos;
                actor.Width    = radius;
                actor.Height   = radius;

                actors.Add(actor);
                return(actor);
            }
            catch (Exception e)
            {
                return(null);
            }
        }
コード例 #4
0
        public override bool DestroyActor(JabActor actor)
        {
            FarActor act = (FarActor)(actor);

            world.RemoveBody(act.body);
            act.body = null;
            actors.Remove(act);
            return(true);
        }
コード例 #5
0
        public override JabActor CreateFromTriangles(List <Vector2> triangles, Vector2 pos, JabActor.BodyType bodytype)
        {
            try
            {
                FarActor actor = new FarActor();
                actor.body          = new Body(world);// world.CreateBody();
                actor.body.UserData = actor;

                //FarseerPhysics.Settings.MaxPolygonVertices = 33;

                for (int i = 0; i < triangles.Count; i++)
                {
                    Vector2[] tri = new Vector2[3];
                    tri[0] = triangles[i] / 100.0f;
                    ++i;
                    tri[1] = triangles[i] / 100.0f;
                    ++i;
                    tri[2] = triangles[i] / 100.0f;

                    Vertices     vertices = new Vertices(tri);
                    PolygonShape shape    = new PolygonShape(vertices, 1.0f);
                    actor.body.CreateFixture(shape, 1.0f);
                }

                actor.BodyState = bodytype;
                actor.Position  = pos;

                actors.Add(actor);
                return(actor);
            }
            catch (Exception e)
            {
                //System.Windows.MessageBox.Show(e.ToString());
            }

            return(null);
        }
コード例 #6
0
ファイル: FarWorld.cs プロジェクト: meds/ChicksnVixens
        public override JabActor CreateSphere(float radius, Vector2 pos, JabActor.BodyType bodytype)
        {
            try
            {
                radius /= 100;
                FarActor actor = new FarActor();
                actor.body = new Body(world);// world.CreateBody();
                actor.body.UserData = actor;

                Vector2 center = new Vector2(-radius, -radius) / 2.0f;
              //  FarseerPhysics.Settings.MaxPolygonVertices = 33;
                Vertices sphere = PolygonTools.CreateCircle(radius, 32);

                PolygonShape shape = new PolygonShape(sphere, 1.0f);
                actor.BodyState = bodytype;
                actor.body.CreateFixture(shape, 1.0f);
                actor.Position = pos;
                actor.Width = radius;
                actor.Height = radius;

                actors.Add(actor);
                return actor;
            }
            catch (Exception e)
            {
                return null;
            }
        }
コード例 #7
0
ファイル: FarWorld.cs プロジェクト: meds/ChicksnVixens
        public override JabActor CreateFromTriangles(List<Vector2> triangles, Vector2 pos, JabActor.BodyType bodytype)
        {
            try
            {
                FarActor actor = new FarActor();
                actor.body = new Body(world);// world.CreateBody();
                actor.body.UserData = actor;

                //FarseerPhysics.Settings.MaxPolygonVertices = 33;

                for (int i = 0; i < triangles.Count; i++)
                {
                    Vector2[] tri = new Vector2[3];
                    tri[0] = triangles[i] / 100.0f;
                    ++i;
                    tri[1] = triangles[i] / 100.0f;
                    ++i;
                    tri[2] = triangles[i] / 100.0f;

                    Vertices vertices = new Vertices(tri);
                    PolygonShape shape = new PolygonShape(vertices, 1.0f);
                    actor.body.CreateFixture(shape, 1.0f);
                }

                actor.BodyState = bodytype;
                actor.Position = pos;

                actors.Add(actor);
                return actor;

            }
            catch (Exception e)
            {
                //System.Windows.MessageBox.Show(e.ToString());
            }

            return null;
        }