Ejemplo n.º 1
0
        protected void SetupPlayerOnExit()
        {
            SceneExit += (sender, e) => {
                if (e.To is ISceneGameplay)
                {
                    _Game.AddUpdateEventHandler(this, (sender1, e1) => {
                        Scene scene_context = e.To;
                        double start_x      = 0, start_y = 0;
                        if (scene_context.DoorToPreviousScene != null)
                        {
                            start_x = scene_context.DoorToPreviousScene.CornerX;
                            start_y = scene_context.DoorToPreviousScene.CornerY;
                        }
                        //new Spidey(e.To.Stage, start_x, start_y);

                        //
                        // Setup Player 1
                        //

                        Player player_1 = _Game.Player1;
                        if (player_1 != null)
                        {
                            player_1.Derez();
                        }
                        player_1          = _Game.Player1 = new Player(scene_context.Stage, start_x, start_y, Texture.Get("sprite_player"));
                        player_1.CornerY += 32;
                        scene_context.Follow(player_1, true);
                        _Game.SetLastInputAccepters("Player1", new IInputAccepter[] { player_1 });
                        Follow(player_1);

                        var health_meter      = new HealthMeter(scene_context.HUD, 64, ViewHeight - 64, player_1);
                        health_meter.Preserve = true;

                        player_1.DerezEvent += (sender3, e3) => {
                            _Game.RemoveInputAccepters("Player1");
                            health_meter.Set.Remove(health_meter);
                        };
                        return(true);
                    });
                }
            };
        }
Ejemplo n.º 2
0
        protected void SetupPlayerOnExit()
        {
            SceneExit += (sender, e) => {
                if(e.To is ISceneGameplay)
                {
                    Program.MainGame.AddUpdateEventHandler(this, (sender2, e2) => {
                        double start_x = 0, start_y = 0;
                        if(e.To.DoorToPreviousScene != null)
                        {
                            start_x = e.To.DoorToPreviousScene.CornerX;
                            start_y = e.To.DoorToPreviousScene.CornerY;
                        }
                        //new Spidey(e.To.Stage, start_x, start_y);
                        Player player_1 = Program.MainGame.Player1;
                        if(player_1 != null)
                        {
                            player_1.Derez();
                            Program.MainGame.RemoveInputAccepters("Player1");
                        }
                        player_1 = Program.MainGame.Player1 = new Player(e.To.Stage, start_x, start_y, Texture.Get("sprite_player"));
                        player_1.CornerY += 32;
                        //e.To.Follow(player_1, true);
                        Program.MainGame.SetLastInputAccepters("Player1", new IInputAccepter[] { player_1 });
                        Follow(player_1);

                        var health_meter = new HealthMeter(e.To.HUD, 64, ViewHeight - 64, player_1);
                        health_meter.Preserve = true;

                        player_1.DerezEvent += (sender3, e3) => { health_meter.Dispose(); };

                        return true;
                    });
                }
            };
        }
Ejemplo n.º 3
0
        protected void SetupPlayerOnExit()
        {
            SceneExit += (sender, e) => {
                if(e.To is ISceneGameplay)
                {
                    _Game.AddUpdateEventHandler(this, (sender1, e1) => {
                        Scene scene_context = e.To;
                        double start_x = 0, start_y = 0;
                        if(scene_context.DoorToPreviousScene != null)
                        {
                            start_x = scene_context.DoorToPreviousScene.CornerX;
                            start_y = scene_context.DoorToPreviousScene.CornerY;
                        }
                        //new Spidey(e.To.Stage, start_x, start_y);

                        //
                        // Setup Player 1
                        //

                        Player player_1 = _Game.Player1;
                        if(player_1 != null)
                        {
                            player_1.Derez();
                        }
                        player_1 = _Game.Player1 = new Player(scene_context.Stage, start_x, start_y, Texture.Get("sprite_player"));
                        player_1.CornerY += 32;
                        scene_context.Follow(player_1, true);
                        _Game.SetLastInputAccepters("Player1", new IInputAccepter[] { player_1 });
                        Follow(player_1);

                        var health_meter = new HealthMeter(scene_context.HUD, 64, ViewHeight - 64, player_1);
                        health_meter.Preserve = true;

                        player_1.DerezEvent += (sender3, e3) => {
                            _Game.RemoveInputAccepters("Player1");
                            health_meter.Set.Remove(health_meter);
                        };
                        return true;
                    });
                }
            };
        }