public StarlingGameSpriteWithPedControlTimetravel()
        {
            var textures = new StarlingGameSpriteWithPedTextures(new_tex_crop, new_texsprite_crop);



            this.onbeforefirstframe += (stage, s) =>
            {
                // 1000 / 15
                // this means 15 samples per second
                var ilag = 7;

                #region man_with_lag
                var man_with_lag = new PhysicalPed(textures, this);

                //karmaman.body.SetActive(false);

                for (int i = 0; i < ilag; i++)
                {
                    man_with_lag.KarmaInput4.Enqueue(
                        new KeySample()
                        );
                }

                man_with_lag.body.SetPosition(
                    new b2Vec2(-8, 8)
                    );

                man_with_lag.karmabody.SetPosition(
                    new b2Vec2(-8, 8)
                    );
                #endregion


                #region man_with_karma
                var man_with_karma = new PhysicalPed(textures, this);

                man_with_karma.SetPositionAndAngle(-8, -8);



                #endregion



                var physical0 = new PhysicalPed(textures, this);
                current = physical0;

                // 32x32 = 15FPS?
                // 24x24 35?

                #region the others
                for (int ix = 1; ix < 4; ix++)
                {
                    for (int iy = 1; iy < 4; iy++)
                    {
                        var p = new PhysicalPed(textures, this);

                        p.SetPositionAndAngle(
                            8 * ix, 8 * iy
                            );
                    }
                }
                #endregion


                #region __keyDown
                var __keyDown = new KeySample();

                stage.keyDown +=
                    e =>
                {
                    // http://circlecube.com/2008/08/actionscript-key-listener-tutorial/
                    if (e.altKey)
                    {
                        __keyDown[Keys.Alt] = true;
                    }

                    __keyDown[(Keys)e.keyCode] = true;
                };

                stage.keyUp +=
                    e =>
                {
                    if (!e.altKey)
                    {
                        __keyDown[Keys.Alt] = false;
                    }

                    __keyDown[(Keys)e.keyCode] = false;
                };

                #endregion

                bool mode_changepending = false;

                var man_with_karma_karmavisuals = new Queue <VisualPed>();
                var physical0_karmavisuals      = new Queue <VisualPed>();
                var karmasw = new Stopwatch();
                karmasw.Start();



                //var inputfilter = new Stopwatch();
                //inputfilter.Start();

                onsyncframe += delegate
                {
                    physical0.SetVelocityFromInput(__keyDown);

                    man_with_karma.SetVelocityFromInput(__keyDown);

                    man_with_lag.KarmaInput4.Enqueue(new KeySample {
                        value = __keyDown.value
                    });
                    var physical2_karmastream_keydown = man_with_lag.KarmaInput4.Dequeue();

                    // this one lives in the past?
                    man_with_lag.SetVelocityFromInput(physical2_karmastream_keydown);


                    #region karmavisuals
                    if (karmasw.ElapsedMilliseconds > (1000 / 15))
                    {
                        karmasw.Restart();

                        {
                            physical0_karmavisuals.Enqueue(physical0.visual);

                            if (physical0_karmavisuals.Count > ilag)
                            {
                                physical0_karmavisuals.Dequeue().Orphanize();
                            }

                            physical0.visual.shadow.visible      = false;
                            physical0.visual.currentvisual.alpha = 0.2;

                            physical0.visual = new VisualPed(textures, this, physical0.visual.AnimateSeed)
                            {
                                LayOnTheGround = physical0.visual.LayOnTheGround
                            };

                            physical0.ShowPositionAndAngle();
                        }


                        {
                            man_with_karma_karmavisuals.Enqueue(man_with_karma.visual);

                            if (man_with_karma_karmavisuals.Count > 4)
                            {
                                man_with_karma_karmavisuals.Dequeue().Orphanize();
                            }

                            man_with_karma.visual.shadow.visible      = false;
                            man_with_karma.visual.currentvisual.alpha = 0.2;

                            man_with_karma.visual = new VisualPed(textures, this, man_with_karma.visual.AnimateSeed)
                            {
                                LayOnTheGround = man_with_karma.visual.LayOnTheGround
                            };

                            man_with_karma.ShowPositionAndAngle();
                        }
                    }
                    #endregion
                };

                onframe += delegate
                {
                    this.Text = new
                    {
                        da = (man_with_lag.body.GetAngle() - physical0.body.GetAngle()).RadiansToDegrees(),
                        dx = man_with_lag.body.GetPosition().x - physical0.body.GetPosition().x,
                        dy = man_with_lag.body.GetPosition().y - physical0.body.GetPosition().y
                    }.ToString();



                    #region simulate a weapone!
                    if (__keyDown[Keys.ControlKey])
                    {
                        if (frameid % 20 == 0)
                        {
                            var bodyDef = new b2BodyDef();

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

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

                            var body = ground_b2world.CreateBody(bodyDef);
                            body.SetPosition(
                                new b2Vec2(
                                    current.body.GetPosition().x + 2,
                                    current.body.GetPosition().y + 2
                                    )
                                );

                            body.SetLinearVelocity(
                                new b2Vec2(
                                    100,
                                    100
                                    )
                                );

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


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


                            var fix = body.CreateFixture(fixDef);

                            //body.SetPosition(
                            //    new b2Vec2(0, -100 * 16)
                            //);
                        }
                    }
                    #endregion


                    #region mode
                    if (__keyDown[Keys.Space])
                    {
                        // space is not down.
                        mode_changepending = true;
                    }
                    else
                    {
                        if (mode_changepending)
                        {
                            if (physical0.visual.LayOnTheGround)
                            {
                                physical0.visual.LayOnTheGround = false;
                            }
                            else
                            {
                                physical0.visual.LayOnTheGround = true;
                            }

                            mode_changepending = false;
                        }
                    }
                    #endregion
                };
            };
        }
        public StarlingGameSpriteWithPedSync()
        {
            var textures_ped = new StarlingGameSpriteWithPedTextures(new_tex_crop, new_texsprite_crop);


            this.onbeforefirstframe += (stage, s) =>
            {
                #region :ego
                var ego = new PhysicalPed(textures_ped, this)
                {
                    Identity = sessionid + ":ego"
                };

                ego.SetPositionAndAngle(
                    random.NextDouble() * -8,
                    random.NextDouble() * -8,
                    random.NextDouble() * Math.PI
                    );

                current = ego;
                #endregion

                // 32x32 = 15FPS?
                // 24x24 35?

                #region others
                for (int ix = 2; ix < 4; ix++)
                {
                    for (int iy = 2; iy < 4; iy++)
                    {
                        var p = new PhysicalPed(textures_ped, this);

                        p.SetPositionAndAngle(
                            8 * ix, 8 * iy
                            );
                    }
                }
                #endregion


                #region KeySample
                var __keyDown = new KeySample();

                stage.keyDown +=
                    e =>
                {
                    // http://circlecube.com/2008/08/actionscript-key-listener-tutorial/
                    if (e.altKey)
                    {
                        __keyDown[Keys.Alt] = true;
                    }

                    __keyDown[(Keys)e.keyCode] = true;
                };

                stage.keyUp +=
                    e =>
                {
                    if (!e.altKey)
                    {
                        __keyDown[Keys.Alt] = false;
                    }

                    __keyDown[(Keys)e.keyCode] = false;
                };

                #endregion

                #region other
                Func <string, RemoteGame> other = __egoid =>
                {
                    // that other game has sent us a sync frame!

                    var already_known_other = others.FirstOrDefault(k => k.__egoid == __egoid);

                    if (already_known_other == null)
                    {
                        already_known_other = new RemoteGame
                        {
                            __egoid = __egoid,

                            // this
                            __syncframeid = this.syncframeid
                        };

                        others.Add(already_known_other);
                    }


                    return(already_known_other);
                };
                #endregion


                #region __at_sync
                __at_sync += __egoid =>
                {
                    // that other game has sent us a sync frame!

                    var o = other(__egoid);

                    o.__syncframeid++;
                    // move on!
                };
                #endregion


                #region __at_SetVelocityFromInput
                __at_SetVelocityFromInput +=
                    (
                        string __egoid,
                        string __identity,
                        string __KeySample,
                        string __fixup_x,
                        string __fixup_y,
                        string __fixup_angle

                    ) =>
                {
                    var o = other(__egoid);



                    if (o.ego == null)
                    {
                        o.ego = new PhysicalPed(textures_ped, this)
                        {
                            Identity            = __identity,
                            RemoteGameReference = o
                        };

                        o.ego.SetPositionAndAngle(
                            double.Parse(__fixup_x),
                            double.Parse(__fixup_y),
                            double.Parse(__fixup_angle)
                            );
                    }


                    // set the input!


                    o.ego.SetVelocityFromInput(
                        new KeySample
                    {
                        value = int.Parse(__KeySample),

                        fixup = true,

                        x     = double.Parse(__fixup_x),
                        y     = double.Parse(__fixup_y),
                        angle = double.Parse(__fixup_angle)
                    }
                        );
                };
                #endregion


                bool mode_changepending = false;
                onsyncframe += delegate
                {
                    // sync me!

                    // tell others in the session about our game
                    // a beacon


                    #region simulate a weapone!
                    if (__keyDown[Keys.ControlKey])
                    {
                        if (frameid % 20 == 0)
                        {
                            var bodyDef = new b2BodyDef();

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

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

                            var body = ground_b2world.CreateBody(bodyDef);
                            body.SetPosition(
                                new b2Vec2(
                                    current.body.GetPosition().x + 2,
                                    current.body.GetPosition().y + 2
                                    )
                                );

                            body.SetLinearVelocity(
                                new b2Vec2(
                                    100,
                                    100
                                    )
                                );

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


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


                            var fix = body.CreateFixture(fixDef);

                            //body.SetPosition(
                            //    new b2Vec2(0, -100 * 16)
                            //);
                        }
                    }
                    #endregion


                    #region mode
                    if (!__keyDown[Keys.Space])
                    {
                        // space is not down.
                        mode_changepending = true;
                    }
                    else
                    {
                        if (mode_changepending)
                        {
                            if (ego.visual.LayOnTheGround)
                            {
                                ego.visual.LayOnTheGround = false;
                            }
                            else
                            {
                                ego.visual.LayOnTheGround = true;
                            }

                            mode_changepending = false;
                        }
                    }
                    #endregion



                    ego.SetVelocityFromInput(__keyDown);

                    __raise_SetVelocityFromInput(
                        "" + sessionid,
                        ego.Identity,
                        "" + ego.CurrentInput.value,
                        "" + ego.body.GetPosition().x,
                        "" + ego.body.GetPosition().y,
                        "" + ego.body.GetAngle()

                        );


                    // tell others this sync frame ended for us
                    __raise_sync("" + sessionid);
                };
            };
        }
Example #3
0
        public StarlingGameSpriteWithTestDrivers()
        {
            var textures_ped = new StarlingGameSpriteWithPedTextures(this.new_tex_crop, this.new_texsprite_crop);
            // ??
            //<Reference Include="FlashHeatZeeker.UnitHindControl">
            //  <HintPath>..\packages\FlashHeatZeeker.UnitHindControl.1.0.0.0\lib\FlashHeatZeeker.UnitHindControl.dll</HintPath>
            //</Reference>
            // "X:\jsc.svn\examples\actionscript\svg\FlashHeatZeeker\packages\FlashHeatZeeker.UnitHindControl.1.0.0.0\lib\FlashHeatZeeker.UnitHindControl.dll"
            // "X:\jsc.svn\examples\actionscript\svg\FlashHeatZeeker\packages\FlashHeatZeeker.UnitHind.1.0.0.0\lib\FlashHeatZeeker.UnitHind.dll"
            var textures_hind   = new StarlingGameSpriteWithHindTextures(this.new_tex_crop);
            var textures_jeep   = new StarlingGameSpriteWithJeepTextures(this.new_tex_crop);
            var textures_tank   = new StarlingGameSpriteWithTankTextures(this.new_texsprite_crop);
            var textures_cannon = new StarlingGameSpriteWithCannonTextures(this.new_tex_crop);
            var textures_bunker = new StarlingGameSpriteWithBunkerTextures(this.new_tex_crop);
            var textures_map    = new StarlingGameSpriteWithMapTextures(new_tex_crop);
            var textures_rocket = new StarlingGameSpriteWithRocketTextures(this.new_tex_crop);

            this.disablephysicsdiagnostics = true;

            this.onbeforefirstframe += (stage, s) =>
            {
                var hud = new Image(textures_ped.hud_look()).AttachTo(this);


                for (int i = 0; i < 32; i++)
                {
                    new Image(textures_map.hill1()).AttachTo(Content).With(
                        hill =>
                    {
                        hill.x = 2048.Random();
                        hill.y = 2048.Random();
                    }
                        );

                    new Image(textures_map.hole1()).AttachTo(Content).With(
                        hill =>
                    {
                        hill.x = 2048.Random();
                        hill.y = 2048.Random();
                    }
                        );

                    new Image(textures_map.grass1()).AttachTo(Content).With(
                        hill =>
                    {
                        hill.x = 2048.Random();

                        var y  = -2048.Random() - 512 - 256;
                        hill.y = y;
                    }
                        );
                }

                for (int i = 0; i < 128; i++)
                {
                    var x = 2048.Random();
                    var y = -2048.Random() - 512 - 256;

                    new Image(textures_map.tree0_shadow()).AttachTo(Content).MoveTo(x + 16, y + 16);
                    new Image(textures_map.tree0()).AttachTo(Content).MoveTo(x, y);
                }
                for (int i = -12; i < 12; i++)
                {
                    new Image(textures_map.road0()).AttachTo(Content).x = 256 * i;
                }

                new Image(textures_map.touchdown()).AttachTo(Content).MoveTo(256, -256);
                new Image(textures_map.touchdown()).AttachTo(Content).y = 256;

                new PhysicalHindWeaponized(textures_hind, textures_rocket, this)
                {
                    AutomaticTakeoff = true
                }.SetPositionAndAngle((128 + 256) / 16, -128 * 1.5 / 16);
                new PhysicalTank(textures_tank, this).SetPositionAndAngle(128 / 16, 128 * 3 / 16);

                new Image(textures_map.tree0_shadow()).AttachTo(Content).y = 128 + 16;
                new Image(textures_map.tree0()).AttachTo(Content).y        = 128;

                // can I have
                // new ped, hind, jeep, tank
                current = new PhysicalPed(textures_ped, this);


                // 12 = 34FPS
                #region other units
                for (int i = 3; i < 9; i++)
                {
                    var cannon2 = new PhysicalCannon(textures_cannon, this);

                    cannon2.SetPositionAndAngle(
                        i * 16, -32, random.NextDouble()
                        );



                    if (i % 3 == 0)
                    {
                        new PhysicalBunker(textures_bunker, this).SetPositionAndAngle(
                            i * 16, -16, random.NextDouble()
                            );
                    }
                    else if (i % 3 == 1)
                    {
                        new PhysicalWatertower(textures_bunker, this).SetPositionAndAngle(
                            i * 16, -16, random.NextDouble()
                            );
                    }
                    else
                    {
                        new PhysicalSilo(textures_bunker, this).SetPositionAndAngle(
                            i * 16, -16, random.NextDouble()
                            );
                    }

                    var hind2 = new PhysicalHindWeaponized(textures_hind, textures_rocket, this)
                    {
                        AutomaticTakeoff = true
                    };

                    hind2.SetPositionAndAngle(
                        i * 16, 8, random.NextDouble()
                        );


                    var jeep2 = new PhysicalJeep(textures_jeep, this);


                    jeep2.SetPositionAndAngle(
                        i * 16, 16, random.NextDouble()
                        );



                    var tank2 = new PhysicalTank(textures_tank, this);

                    tank2.SetPositionAndAngle(
                        i * 16, 24, random.NextDouble()
                        );


                    var ped2 = new PhysicalPed(textures_ped, this);

                    ped2.SetPositionAndAngle(
                        i * 16, 32, random.NextDouble()
                        );
                }
                #endregion



                #region __keyDown

                stage.keyDown +=
                    e =>
                {
                    // http://circlecube.com/2008/08/actionscript-key-listener-tutorial/
                    if (e.altKey)
                    {
                        __keyDown[System.Windows.Forms.Keys.Alt] = true;
                    }

                    __keyDown[(System.Windows.Forms.Keys)e.keyCode] = true;
                };

                stage.keyUp +=
                    e =>
                {
                    if (!e.altKey)
                    {
                        __keyDown[System.Windows.Forms.Keys.Alt] = false;
                    }

                    __keyDown[(System.Windows.Forms.Keys)e.keyCode] = false;
                };

                #endregion

                bool entermode_changepending = false;
                bool mode_changepending      = false;

                onframe +=
                    delegate
                {
                    #region hud
                    {
                        var cm = new Matrix();

                        cm.scale(0.5, 0.5);
                        cm.translate(16, stage.stageHeight - 64 - 24);

                        hud.transformationMatrix = cm;
                    }
                    #endregion
                };

                onsyncframe +=
                    delegate
                {
                    #region entermode_changepending
                    if (!__keyDown[System.Windows.Forms.Keys.Enter])
                    {
                        // space is not down.
                        entermode_changepending = true;
                    }
                    else
                    {
                        if (entermode_changepending)
                        {
                            entermode_changepending = false;

                            // enter another vehicle?

                            var candidatedriver = current as PhysicalPed;
                            if (candidatedriver != null)
                            {
                                var target =
                                    from candidatevehicle in units
                                    where candidatevehicle.driverseat != null

                                    // can enter if the seat is full.
                                    // unless we kick them out before ofcourse
                                    where candidatevehicle.driverseat.driver == null

                                    let distance = new __vec2(
                                        (float)(candidatedriver.body.GetPosition().x - candidatevehicle.body.GetPosition().x),
                                        (float)(candidatedriver.body.GetPosition().y - candidatevehicle.body.GetPosition().y)
                                        ).GetLength()

                                                   where distance < 6

                                                   orderby distance ascending
                                                   select new { candidatevehicle, distance };

                                target.FirstOrDefault().With(
                                    x =>
                                {
                                    Console.WriteLine(new { x.distance });

                                    //current.loc.visible = false;
                                    current.body.SetActive(false);


                                    x.candidatevehicle.driverseat.driver = candidatedriver;
                                    candidatedriver.seatedvehicle        = x.candidatevehicle;

                                    current = x.candidatevehicle;

                                    if (current.body.GetType() == Box2D.Dynamics.b2Body.b2_dynamicBody)
                                    {
                                        hud.texture = textures_ped.hud_look_goggles();
                                    }
                                    else
                                    {
                                        hud.texture = textures_ped.hud_look_building();
                                    }

                                    //switchto(x.x);
                                }
                                    );
                            }
                            else
                            {
                                (current.driverseat.driver as PhysicalPed).With(
                                    driver =>
                                {
                                    current.driverseat.driver = null;
                                    driver.seatedvehicle      = null;
                                    current.SetVelocityFromInput(new KeySample());

                                    // crashland?
                                    (current as PhysicalHind).With(
                                        hind => hind.VerticalVelocity = -1
                                        );


                                    current = driver;
                                    current.body.SetActive(true);
                                    hud.texture = textures_ped.hud_look();
                                }
                                    );
                            }
                        }
                    }
                    #endregion



                    #region mode
                    if (!__keyDown[System.Windows.Forms.Keys.Space])
                    {
                        // space is not down.
                        mode_changepending = true;
                    }
                    else
                    {
                        if (mode_changepending)
                        {
                            (current as PhysicalHind).With(
                                hind1 =>
                            {
                                if (hind1.visual.Altitude == 0)
                                {
                                    hind1.VerticalVelocity = 1.0;
                                }
                                else
                                {
                                    hind1.VerticalVelocity = -0.4;
                                }
                            }
                                );

                            (current as PhysicalPed).With(
                                physical0 =>
                            {
                                if (physical0.visual.LayOnTheGround)
                                {
                                    physical0.visual.LayOnTheGround = false;
                                }
                                else
                                {
                                    physical0.visual.LayOnTheGround = true;
                                }
                            }
                                );



                            mode_changepending = false;
                        }
                    }
                    #endregion


                    current.SetVelocityFromInput(__keyDown);



                    #region simulate a weapone!
                    if (__keyDown[System.Windows.Forms.Keys.ControlKey])
                    {
                        if (syncframeid % 3 == 0)
                        {
                            (this.current as PhysicalHindWeaponized).With(
                                h =>
                            {
                                //sb.snd_missleLaunch.play();

                                h.FireRocket();
                            }
                                );
                        }
                    }
                    #endregion
                };
            };
        }
Example #4
0
        public StarlingGameSpriteWithShop()
        {
            var textures_bunker = new StarlingGameSpriteWithBunkerTextures(this.new_tex_crop);
            var textures_ped    = new StarlingGameSpriteWithPedTextures(this.new_tex_crop, this.new_texsprite_crop);

            this.disablephysicsdiagnostics = true;

            this.onbeforefirstframe += (stage, s) =>
            {
                s.stage.color = 0xB27D51;
                current       = new PhysicalPed(textures_ped, this)
                {
                    AttractZombies = true
                };

                current.SetPositionAndAngle(
                    16.Random(),
                    16.Random(),
                    360.Random().DegreesToRadians()
                    );


                #region others
                for (int ix = 0; ix < 2; ix++)
                {
                    for (int iy = 0; iy < 2; iy++)
                    {
                        var p = new PhysicalPed(textures_ped, this);

                        p.SetPositionAndAngle(
                            8 * ix, 8 * iy, random.NextDouble()
                            );

                        p.BehaveLikeZombie();
                    }
                }
                #endregion

                var myshop = new PhysicalBunker(textures_bunker, this, IsShop: true);

                myshop.SetPositionAndAngle(
                    -8, -8
                    );



                #region __keyDown

                stage.keyDown +=
                    e =>
                {
                    __keyDown.forcex = 1.0;
                    __keyDown.forcey = 1.0;

                    // http://circlecube.com/2008/08/actionscript-key-listener-tutorial/
                    if (e.altKey)
                    {
                        __keyDown[System.Windows.Forms.Keys.Alt] = true;
                    }

                    __keyDown[(System.Windows.Forms.Keys)e.keyCode] = true;
                };

                stage.keyUp +=
                    e =>
                {
                    if (!e.altKey)
                    {
                        __keyDown[System.Windows.Forms.Keys.Alt] = false;
                    }

                    __keyDown[(System.Windows.Forms.Keys)e.keyCode] = false;
                };

                #endregion



                bool entermode_changepending = false;


                onsyncframe +=
                    delegate
                {
                    current.SetVelocityFromInput(__keyDown);

                    #region Enter
                    if (!__keyDown[System.Windows.Forms.Keys.Enter])
                    {
                        // space is not down.
                        entermode_changepending = true;
                    }
                    else
                    {
                        if (entermode_changepending)
                        {
                            entermode_changepending = false;

                            // enter another vehicle?

                            var candidatedriver = current as PhysicalPed;
                            if (candidatedriver != null)
                            {
                                var target =
                                    from candidatevehicle in units
                                    where candidatevehicle.driverseat != null

                                    // can enter if the seat is full.
                                    // unless we kick them out before ofcourse
                                    where candidatevehicle.driverseat.driver == null

                                    let distance = new __vec2(
                                        (float)(candidatedriver.body.GetPosition().x - candidatevehicle.body.GetPosition().x),
                                        (float)(candidatedriver.body.GetPosition().y - candidatevehicle.body.GetPosition().y)
                                        ).GetLength()

                                                   where distance < 6

                                                   orderby distance ascending
                                                   select new { candidatevehicle, distance };

                                target.FirstOrDefault().With(
                                    x =>
                                {
                                    Console.WriteLine(new { x.distance });

                                    //current.loc.visible = false;
                                    current.body.SetActive(false);


                                    x.candidatevehicle.driverseat.driver = candidatedriver;
                                    candidatedriver.seatedvehicle        = x.candidatevehicle;

                                    current = x.candidatevehicle;

                                    //if (current is PhysicalJeep)
                                    //{
                                    //    sb.snd_jeepengine_start.play();
                                    //}

                                    //else
                                    if (current is PhysicalBunker)
                                    {
                                        if ((current as PhysicalBunker).visual_shopoverlay.visible)
                                        {
                                            sb.snd_its_a_shop.play();
                                            if (ShopEnter != null)
                                            {
                                                ShopEnter(candidatedriver);
                                            }
                                        }
                                        else
                                        {
                                            if (random.NextDouble() > 0.5)
                                            {
                                                sb.snd_itsempty.play();
                                            }
                                            else
                                            {
                                                sb.snd_nothinghere.play();
                                            }
                                        }
                                    }
                                    else
                                    {
                                        sb.snd_dooropen.play(
                                            sndTransform: new SoundTransform(
                                                0.3
                                                )
                                            );
                                    }

                                    //if (current is PhysicalHind)
                                    //{
                                    //    nightvision_on();
                                    //}

                                    //hud_update();


                                    //switchto(x.x);
                                    move_zoom = 1;

                                    // fast start
                                    //(current as PhysicalHind).With(
                                    //    hind => hind.VerticalVelocity = 1
                                    //);
                                }
                                    );
                            }
                            else
                            {
                                (current.driverseat.driver as PhysicalPed).With(
                                    driver =>
                                {
                                    // get out of the lift..

                                    //nightvision_off();

                                    current.driverseat.driver = null;
                                    driver.seatedvehicle      = null;
                                    current.SetVelocityFromInput(new KeySample());

                                    if (current is PhysicalBunker)
                                    {
                                        if ((current as PhysicalBunker).visual_shopoverlay.visible)
                                        {
                                            if (ShopExit != null)
                                            {
                                                ShopExit();
                                            }
                                        }
                                    }
                                    // crashland?
                                    //(current as PhysicalHind).With(
                                    //    hind =>
                                    //    {
                                    //        if (hind.visual.Altitude > 0)
                                    //        {
                                    //            hind.VerticalVelocity = -1;
                                    //            sb.snd_touchdown.play();
                                    //        }
                                    //    }

                                    //);

                                    sb.snd_dooropen.play(
                                        sndTransform: new SoundTransform(
                                            0.3
                                            )
                                        );
                                    //if (current.body.GetType() != Box2D.Dynamics.b2Body.b2_dynamicBody)
                                    //{
                                    //    sb.snd_letsgo.play();
                                    //}

                                    current = driver;
                                    driver.body.SetActive(true);
                                    driver.body.SetAngularVelocity(-11);

                                    //hud_update();
                                    move_zoom = 1;
                                }
                                    );
                            }
                        }
                    }
                    #endregion
                };
            };
        }