public StarlingGameSpriteWithHind()
        {
            this.autorotate = true;

            var textures = new StarlingGameSpriteWithHindTextures(this.new_tex_crop);

            var airzoom = 1.5;

            this.onbeforefirstframe += delegate
              {

                  for (int i = 0; i < 12; i++)
                      for (int yi = 0; yi < 12; yi++)
                      {
                          var rot = random.NextDouble() * Math.PI;

                          var visual1 = new VisualHind(textures, Content, airzoom);


                          visual1.SetPositionAndAngle(
                             i * 400, yi * 400,
                             rot
                         );

                          onframe +=
                              delegate
                              {
                                  visual1.Animate(gametime);

                              };
                      }
              };
        }
Esempio n. 2
0
        public PhysicalHind(StarlingGameSpriteWithHindTextures textures, StarlingGameSpriteWithPhysics Context)
        {
            this.CurrentInput = new KeySample();
            this.driverseat   = new DriverSeat();

            this.Context = Context;

            visual = new VisualHind(textures, Context.Content, Context.airzoom);

            for (int i = 0; i < 7; i++)
            {
                this.KarmaInput0.Enqueue(
                    new KeySample()
                    );
            }



            #region ground_b2world ground_current


            {
                var ground_bodyDef = new b2BodyDef();

                ground_bodyDef.type = Box2D.Dynamics.b2Body.b2_dynamicBody;

                // stop moving if legs stop walking!
                ground_bodyDef.linearDamping  = 10.0;
                ground_bodyDef.angularDamping = 4;
                //bodyDef.angle = 1.57079633;
                //ground_bodyDef.fixedRotation = true;

                ground_body = Context.ground_b2world.CreateBody(ground_bodyDef);


                var ground_fixDef = new Box2D.Dynamics.b2FixtureDef();
                ground_fixDef.density     = 0.1;
                ground_fixDef.friction    = 0.01;
                ground_fixDef.restitution = 0;

                var ground_fixdef_shape = new b2PolygonShape();

                ground_fixDef.shape = ground_fixdef_shape;

                // physics unit is looking to right
                ground_fixdef_shape.SetAsBox(2, 0.5);



                var ground_fix = ground_body.CreateFixture(ground_fixDef);
            }



            #endregion


            #region groundkarma_body


            {
                var ground_bodyDef = new b2BodyDef();

                ground_bodyDef.type = Box2D.Dynamics.b2Body.b2_dynamicBody;

                // stop moving if legs stop walking!
                ground_bodyDef.linearDamping  = 10.0;
                ground_bodyDef.angularDamping = 4;
                //bodyDef.angle = 1.57079633;
                //ground_bodyDef.fixedRotation = true;

                groundkarma_body = Context.groundkarma_b2world.CreateBody(ground_bodyDef);


                var ground_fixDef = new Box2D.Dynamics.b2FixtureDef();
                ground_fixDef.density     = 0.1;
                ground_fixDef.friction    = 0.01;
                ground_fixDef.restitution = 0;

                var ground_fixdef_shape = new b2PolygonShape();

                ground_fixDef.shape = ground_fixdef_shape;

                // physics unit is looking to right
                ground_fixdef_shape.SetAsBox(2, 0.5);



                var ground_fix = groundkarma_body.CreateFixture(ground_fixDef);
            }



            #endregion


            #region air_b2world air_current



            {
                var air_bodyDef = new b2BodyDef();

                air_bodyDef.type = Box2D.Dynamics.b2Body.b2_dynamicBody;

                // stop moving if legs stop walking!
                air_bodyDef.linearDamping  = 10.0;
                air_bodyDef.angularDamping = 4;
                //bodyDef.angle = 1.57079633;
                //air_bodyDef.fixedRotation = true;
                air_bodyDef.active = false;

                air_body = Context.air_b2world.CreateBody(air_bodyDef);


                var air_fixDef = new Box2D.Dynamics.b2FixtureDef();
                air_fixDef.density     = 0.1;
                air_fixDef.friction    = 0.01;
                air_fixDef.restitution = 0;

                var air_fixdef_shape = new b2PolygonShape();

                air_fixDef.shape = air_fixdef_shape;

                // physics unit is looking to right
                air_fixdef_shape.SetAsBox(2, 0.5);



                var air_fix = air_body.CreateFixture(air_fixDef);
            }


            #endregion

            #region smoke_b2world



            {
                var bodyDef = new b2BodyDef();

                bodyDef.type = Box2D.Dynamics.b2Body.b2_dynamicBody;

                // stop moving if legs stop walking!
                bodyDef.linearDamping  = 0;
                bodyDef.angularDamping = 6;
                //bodyDef.angle = 1.57079633;
                //bodyDef.fixedRotation = true;

                damage_body = Context.damage_b2world.CreateBody(bodyDef);
                //body = Context.ground_b2world.CreateBody(bodyDef);


                var fixDef = new Box2D.Dynamics.b2FixtureDef();
                fixDef.density     = 0.1;
                fixDef.friction    = 0.0;
                fixDef.restitution = 0;


                fixDef.shape = new Box2D.Collision.Shapes.b2CircleShape(2);

                //
                var fix = damage_body.CreateFixture(fixDef);

                //var fix_data = new Action<double>(
                //    jeep_forceA =>
                //    {
                //        if (jeep_forceA < 1)
                //            return;

                //        if (Context.oncollision != null)
                //            Context.oncollision(this, jeep_forceA);
                //    }
                //);
                //fix.SetUserData(fix_data);
            }


            #endregion



            ApplyVelocityElapsed = Context.gametime.ElapsedMilliseconds;


            Context.internalunits.Add(this);
        }
        public PhysicalHind(StarlingGameSpriteWithHindTextures textures, StarlingGameSpriteWithPhysics Context)
        {
            this.CurrentInput = new KeySample();
            this.driverseat = new DriverSeat();

            this.Context = Context;

            visual = new VisualHind(textures, Context.Content, Context.airzoom);

            for (int i = 0; i < 7; i++)
            {
                this.KarmaInput0.Enqueue(
                    new KeySample()
                );
            }




            #region ground_b2world ground_current


            {
                var ground_bodyDef = new b2BodyDef();

                ground_bodyDef.type = Box2D.Dynamics.b2Body.b2_dynamicBody;

                // stop moving if legs stop walking!
                ground_bodyDef.linearDamping = 10.0;
                ground_bodyDef.angularDamping = 4;
                //bodyDef.angle = 1.57079633;
                //ground_bodyDef.fixedRotation = true;

                ground_body = Context.ground_b2world.CreateBody(ground_bodyDef);


                var ground_fixDef = new Box2D.Dynamics.b2FixtureDef();
                ground_fixDef.density = 0.1;
                ground_fixDef.friction = 0.01;
                ground_fixDef.restitution = 0;

                var ground_fixdef_shape = new b2PolygonShape();

                ground_fixDef.shape = ground_fixdef_shape;

                // physics unit is looking to right
                ground_fixdef_shape.SetAsBox(2, 0.5);



                var ground_fix = ground_body.CreateFixture(ground_fixDef);
            }



            #endregion


            #region groundkarma_body


            {
                var ground_bodyDef = new b2BodyDef();

                ground_bodyDef.type = Box2D.Dynamics.b2Body.b2_dynamicBody;

                // stop moving if legs stop walking!
                ground_bodyDef.linearDamping = 10.0;
                ground_bodyDef.angularDamping = 4;
                //bodyDef.angle = 1.57079633;
                //ground_bodyDef.fixedRotation = true;

                groundkarma_body = Context.groundkarma_b2world.CreateBody(ground_bodyDef);


                var ground_fixDef = new Box2D.Dynamics.b2FixtureDef();
                ground_fixDef.density = 0.1;
                ground_fixDef.friction = 0.01;
                ground_fixDef.restitution = 0;

                var ground_fixdef_shape = new b2PolygonShape();

                ground_fixDef.shape = ground_fixdef_shape;

                // physics unit is looking to right
                ground_fixdef_shape.SetAsBox(2, 0.5);



                var ground_fix = groundkarma_body.CreateFixture(ground_fixDef);
            }



            #endregion


            #region air_b2world air_current




            {
                var air_bodyDef = new b2BodyDef();

                air_bodyDef.type = Box2D.Dynamics.b2Body.b2_dynamicBody;

                // stop moving if legs stop walking!
                air_bodyDef.linearDamping = 10.0;
                air_bodyDef.angularDamping = 4;
                //bodyDef.angle = 1.57079633;
                //air_bodyDef.fixedRotation = true;
                air_bodyDef.active = false;

                air_body = Context.air_b2world.CreateBody(air_bodyDef);


                var air_fixDef = new Box2D.Dynamics.b2FixtureDef();
                air_fixDef.density = 0.1;
                air_fixDef.friction = 0.01;
                air_fixDef.restitution = 0;

                var air_fixdef_shape = new b2PolygonShape();

                air_fixDef.shape = air_fixdef_shape;

                // physics unit is looking to right
                air_fixdef_shape.SetAsBox(2, 0.5);



                var air_fix = air_body.CreateFixture(air_fixDef);
            }


            #endregion

            #region smoke_b2world




            {
                var bodyDef = new b2BodyDef();

                bodyDef.type = Box2D.Dynamics.b2Body.b2_dynamicBody;

                // stop moving if legs stop walking!
                bodyDef.linearDamping = 0;
                bodyDef.angularDamping = 6;
                //bodyDef.angle = 1.57079633;
                //bodyDef.fixedRotation = true;

                damage_body = Context.damage_b2world.CreateBody(bodyDef);
                //body = Context.ground_b2world.CreateBody(bodyDef);


                var fixDef = new Box2D.Dynamics.b2FixtureDef();
                fixDef.density = 0.1;
                fixDef.friction = 0.0;
                fixDef.restitution = 0;


                fixDef.shape = new Box2D.Collision.Shapes.b2CircleShape(2);

                // 
                var fix = damage_body.CreateFixture(fixDef);

                //var fix_data = new Action<double>(
                //    jeep_forceA =>
                //    {
                //        if (jeep_forceA < 1)
                //            return;

                //        if (Context.oncollision != null)
                //            Context.oncollision(this, jeep_forceA);
                //    }
                //);
                //fix.SetUserData(fix_data);
            }


            #endregion



            ApplyVelocityElapsed = Context.gametime.ElapsedMilliseconds;


            Context.internalunits.Add(this);
        }