예제 #1
0
 void SaveMapMenuAccepted(object sender, PlayerIndexEventArgs e)
 {
     EditorSavePop editorSavePop = new EditorSavePop(nomSauvegarde, 1);
     editorSavePop.Accepted += SaveMapAccepted;
     ScreenManager.AddScreen(editorSavePop, ControllingPlayer);
 }
예제 #2
0
        public override void HandleInput(InputState input)
        {
            if (input == null)
                throw new ArgumentNullException("input");

            int playerIndex = (int)ControllingPlayer.Value;

            GamePadState gamePadState = input.CurrentGamePadStates[playerIndex];

            bool gamePadDisconnected = !gamePadState.IsConnected && input.GamePadWasConnected[playerIndex];

            if (input.IsPauseGame(ControllingPlayer) || gamePadDisconnected)
            {
                ScreenManager.AddScreen(new Pausebckground(), ControllingPlayer, true);
                PauseMenuScreen pauseMenuScreen = new PauseMenuScreen(0, 2, game);
                pauseMenuScreen.SaveMapMenuEntrySelected += SaveMapMenuAccepted;
                pauseMenuScreen.F1 += F1Selected;
                pauseMenuScreen.F2 += F2Selected;
                pauseMenuScreen.F3 += F3Selected;
                pauseMenuScreen.F4 += F4Selected;
                pauseMenuScreen.F5 += F5Selected;
                pauseMenuScreen.F6 += F6Selected;
                pauseMenuScreen.F7 += F7Selected;
                pauseMenuScreen.F8 += F8Selected;
                ScreenManager.AddScreen(pauseMenuScreen, ControllingPlayer, true);
            }

            if (camera.X > 0 && ServiceHelper.Get<IKeyboardService>().TouchePressee(Keys.Left))
                camera.X--;

            else if (camera.X < Taille_Map.LARGEUR_MAP - camera.Width && ServiceHelper.Get<IKeyboardService>().TouchePressee(Keys.Right))
                camera.X++;

            else if (camera.Y > 0 && ServiceHelper.Get<IKeyboardService>().TouchePressee(Keys.Up))
                camera.Y--;

            else if (camera.Y < Taille_Map.HAUTEUR_MAP - camera.Height && ServiceHelper.Get<IKeyboardService>().TouchePressee(Keys.Down))
                camera.Y++;

            if (curseur.Type == TypeCase.Gomme && ServiceHelper.Get<IMouseService>().ClicBoutonGauche())
                Supprimer_Ennemi_Ou_Bonus();

            if (ServiceHelper.Get<IMouseService>().ClicBoutonGauche() && ServiceHelper.Get<IMouseService>().DansLaCarte() && CasePossible)
                Placer_Personnage_Ou_Bonus();

            if (ServiceHelper.Get<IMouseService>().ClicBoutonDroit() && ServiceHelper.Get<IMouseService>().DansLaCarte() && CasePossible)
            {
                if (curseur.Type == TypeCase.Patrouilleur && _originesPatrouilleurs.Count > 0)
                    _originesPatrouilleurs[_originesPatrouilleurs.Count - 1].Add(new Vector2(curseur.Position.X + camera.X, curseur.Position.Y + camera.Y));
                else if (curseur.Type == TypeCase.Patrouilleur_a_cheval && _originesPatrouilleursAChevaux.Count > 0)
                    _originesPatrouilleursAChevaux[_originesPatrouilleursAChevaux.Count - 1].Add(new Vector2(curseur.Position.X + camera.X, curseur.Position.Y + camera.Y));
                else if (_originesStatues.Count > 0 && curseur.Type == TypeCase.Statues && _originesStatues.Count > 0)
                    rotationsDesStatues[rotationsDesStatues.Count - 1] = (byte)((rotationsDesStatues[rotationsDesStatues.Count - 1] + 1) % 4);
                else if (curseur.Type == TypeCase.Interrupteur && interrupteurs.Count > 0)
                    interrupteurs[interrupteurs.Count - 1].ChangerPosition(carte, new Vector2(curseur.Position.X + camera.X, curseur.Position.Y + camera.Y));
            }

            if (ServiceHelper.Get<IMouseService>().ClicBoutonMilieu() && ServiceHelper.Get<IMouseService>().DansLaCarte() && curseur.Type == TypeCase.Interrupteur)
                interrupteurs[interrupteurs.Count - 1].Rotationner(carte);

            if (ServiceHelper.Get<IMouseService>().BoutonGauchePresse() && ServiceHelper.Get<IMouseService>().DansLaCarte())
                Placer_Case();

            if (ServiceHelper.Get<IKeyboardService>().TouchePressee(Keys.LeftControl) && ServiceHelper.Get<IKeyboardService>().ToucheAEtePressee(Keys.S))
            {
                if (enableOrigine1 && enableOrigine2 || _originesBoss.Count == 0)
                    afficherMessageErreur = true;
                else
                {
                    EditorSavePop editorSavePop = new EditorSavePop(nomSauvegarde, 0);
                    editorSavePop.Accepted += SaveMapAccepted;
                    ScreenManager.AddScreen(editorSavePop, ControllingPlayer);
                }
            }

            if (ServiceHelper.Get<IKeyboardService>().ToucheAEtePressee(Keys.F1))
                ChangerStyle(TypeCase.herbe);

            if (ServiceHelper.Get<IKeyboardService>().ToucheAEtePressee(Keys.F2))
                ChangerStyle(TypeCase.herbeFoncee);

            if (ServiceHelper.Get<IKeyboardService>().ToucheAEtePressee(Keys.F3))
                ChangerStyle(TypeCase.terre);

            if (ServiceHelper.Get<IKeyboardService>().ToucheAEtePressee(Keys.F4))
                ChangerStyle(TypeCase.parquet);

            if (ServiceHelper.Get<IKeyboardService>().ToucheAEtePressee(Keys.F5))
                Labyrinthe.CreerLabyrintheSimple(carte);

            if (ServiceHelper.Get<IKeyboardService>().ToucheAEtePressee(Keys.F6))
                Labyrinthe.CreerLabyrintheDouble(carte);

            if (ServiceHelper.Get<IKeyboardService>().ToucheAEtePressee(Keys.F7))
                Labyrinthe.CreerLabyrintheTriple(carte);

            if (ServiceHelper.Get<IKeyboardService>().ToucheAEtePressee(Keys.F8))
                Labyrinthe.CreerLabyrintheQuadruple(carte);

            infos.Update();

            ScreenManager.Game.IsMouseVisible = !ServiceHelper.Get<IMouseService>().DansLaCarte();
        }