Example #1
0
        protected override void BeginRun()
        {
            level = new LevelCreator(@"Level\Sprint4MainLevel.bmp", gameGrid);
            level.Create();

            AbstractGameObject.DrawHitbox = false;

            player1Controller.AddInputCommand((int)Keys.Y, new BecomeNormalMarioCommand(Player1));
            player1Controller.AddInputCommand((int)Keys.U, new BecomeSuperMarioCommand(Player1));
            player1Controller.AddInputCommand((int)Keys.I, new BecomeFireMarioCommand(Player1));
            player1Controller.AddInputCommand((int)Keys.O, new BecomeDeadMarioCommand(Player1));

            player1Controller.AddInputCommand((int)Keys.B, new FireBallCommand(Player1));
            player1Controller.AddInputChord((int)Modifier.LeftShift, (int)Keys.B, new FireBallCommand(Player1));

            //player1Controller.AddInputCommand((int)Keys.W, new JumpCommand(Player1));
            player1Controller.AddHeldInputCommand((int)Keys.W, new JumpCommand(Player1));
            player1Controller.AddInputChord((int)Modifier.LeftShift, (int)Keys.W, new JumpCommand(Player1));
            //player1Controller.AddInputCommand((int)Keys.A, new MoveLeftCommand(Player1));
            player1Controller.AddHeldInputCommand((int)Keys.A, new MoveLeftCommand(Player1));
            player1Controller.AddInputChord((int)Modifier.LeftShift, (int)Keys.A, new MoveLeftCommand(Player1));
            player1Controller.AddInputCommand((int)Keys.S, new CrouchCommand(Player1));
            player1Controller.AddInputChord((int)Modifier.LeftShift, (int)Keys.S, new CrouchCommand(Player1));
            //player1Controller.AddInputCommand((int)Keys.D, new MoveRightCommand(Player1));
            player1Controller.AddHeldInputCommand((int)Keys.D, new MoveRightCommand(Player1));
            player1Controller.AddInputChord((int)Modifier.LeftShift, (int)Keys.D, new MoveRightCommand(Player1));

            player1Controller.AddInputCommand((int)Keys.Space, new DashCommand(Player1));

            player1Controller.AddReleasedInputCommand((int)Keys.S, new ReleaseCrouchCommand(Player1));
            player1Controller.AddReleasedInputCommand((int)Keys.A, new ReleaseMoveLeftCommand(Player1));
            player1Controller.AddReleasedInputCommand((int)Keys.D, new ReleaseMoveRightCommand(Player1));

            MapPlayer2Controller();

            generalController.AddInputCommand((int)Keys.M, new MuteCommand(SoundPool.Instance));
            generalController.AddInputChord((int)Modifier.LeftShift, (int)Keys.M, new MuteCommand(SoundPool.Instance));
            generalController.AddInputCommand((int)Keys.Escape, new ExitCommand(this));
            generalController.AddInputChord((int)Modifier.LeftShift, (int)Keys.Q, new ExitCommand(this));
            generalController.AddInputCommand((int)Keys.C, new DisplayHitboxCommand());
            generalController.AddInputChord((int)Modifier.LeftShift, (int)Keys.C, new DisplayHitboxCommand());
            generalController.AddInputCommand((int)Keys.P, new PauseCommand(this));
            generalController.AddInputChord((int)Modifier.LeftShift, (int)Keys.P, new PauseCommand(this));

            EventManager.Instance.RaisePlayerWarpingEvent      += PauseForWarp;
            EventManager.Instance.RaisePlayerDiedEvent         += HandlePlayerDeath;
            EventManager.Instance.RaiseTimeRanOutEvent         += HandleTimeIsOut;
            EventManager.Instance.RaisePlayerKilledBowserEvent += HandleBowserDefeated;
            EventManager.Instance.RaisePlayerHitPoleEvent      += HandleFlagPoleHit;

            Player1Camera.Limits = level.LevelAreas[0];
            if (Mode == GameMode.MultiPlayer)
            {
                Player2Camera.Limits = level.LevelAreas[0];
            }

            if (Mode == GameMode.SinglePlayer)
            {
                Player2       = Player1;
                Player2Camera = Player1Camera;
            }

            player1CompletedMenu = new PlayerDoneScoreMenu(Player1);
            player2CompletedMenu = new PlayerDoneScoreMenu(Player2);
        }