public override void HandleInput(KeyboardState newKeyboardState, MouseState new_mouseState, Game1 parent)
        {
            if (_windowSize != parent.Window.ClientBounds)
            {
                _windowSize = parent.Window.ClientBounds;
                WindowResized(parent.Window.ClientBounds);
            }

            if (new_mouseState != _mouseState)
                _mouse.Position = new Rectangle(new_mouseState.X, new_mouseState.Y, _mouse.Position.Width, _mouse.Position.Height);

            if (newKeyboardState.IsKeyDown(Keys.Escape) && !_keyboardState.IsKeyDown(Keys.Escape))
                parent.SwitchScene(Scene.MainMenu);

            if (new_mouseState.LeftButton == ButtonState.Pressed)
            {
                Rectangle click = new Rectangle(new_mouseState.X, new_mouseState.Y, 1, 1);

                if (_soundEffect.Position.Intersects(click))
                    _volumeEffect = (float)(click.X - _soundEffect.Position.X) / (float)_soundEffect.Position.Width;
                if (_soundMusic.Position.Intersects(click))
                    _volumeMusic = (float)(click.X - _soundMusic.Position.X) / (float)_soundMusic.Position.Width;

                parent.son.MusiquesVolume = _volumeMusic;
                parent.son.SonsVolume = _volumeEffect;

                EugLib.FileStream.writeFile(SOUND_FILENAME, _volumeMusic + " " + _volumeEffect);
            }

            _keyboardState = newKeyboardState;
            _mouseState = new_mouseState;
        }
 public override void HandleInput(KeyboardState newKeyboardState, MouseState newMouseState, Game1 parent)
 {
     if (this._timer < 0 && (newKeyboardState.IsKeyDown(Keys.Space) || this._player.State != MediaState.Playing))
     {
         this._player.Stop();
         parent.SwitchScene(this._next);
     }
     this._windowSize = new Rectangle(0, 0, parent.Window.ClientBounds.Width, parent.Window.ClientBounds.Height);
 }
        public override void HandleInput(KeyboardState newKeyboardState, MouseState newMouseState, Game1 parent)
        {
            if (parent.Window.ClientBounds != _windowSize)
            {
                _windowSize = parent.Window.ClientBounds;
                WindowResized(_windowSize);
            }
            if (!_keyboardstate.IsKeyDown(Keys.Space) && newKeyboardState.IsKeyDown(Keys.Space))
                parent.SwitchScene(Scene.MainMenu);
            if (!_keyboardstate.IsKeyDown(Keys.Escape) && newKeyboardState.IsKeyDown(Keys.Escape))
                parent.Exit();
            if (!_keyboardstate.IsKeyDown(Keys.H) && newKeyboardState.IsKeyDown(Keys.H))
                parent.SwitchScene(Scene.IntroHistoire);
            if (!_keyboardstate.IsKeyDown(Keys.V) && newKeyboardState.IsKeyDown(Keys.V))
                parent.SwitchScene(Scene.IntroVid);

            _keyboardstate = newKeyboardState;
            _mouseState = newMouseState;
        }
 public override void HandleInput(KeyboardState newKeyboardState, MouseState newMouseState, Game1 parent)
 {
     if (_timer < 0)
         if (newKeyboardState.GetPressedKeys().Length > 0 || _player.State != MediaState.Playing)
         {
             _player.Stop();
             parent.SwitchScene(_next);
         }
     _windowSize = new Rectangle(0, 0, parent.Window.ClientBounds.Width, parent.Window.ClientBounds.Height);
 }
        public override void HandleInput(KeyboardState newKeyboardState, MouseState newMouseState, Game1 parent)
        {
            if (parent.Window.ClientBounds != _windowSize)
            {
                _windowSize = parent.Window.ClientBounds;
                windowResized(_windowSize);
            }
            if (newKeyboardState.IsKeyDown(Keys.Escape) && !_keyboardState.IsKeyDown(Keys.Escape))
                parent.SwitchScene(Scene.MainMenu);

            _keyboardState = newKeyboardState;
        }
Ejemplo n.º 6
0
        public override void HandleInput(KeyboardState newKeyboardState, MouseState newMouseState, Game1 parent)
        {
            if (parent.Window.ClientBounds != _windowSize)
            {
                _windowSize = parent.Window.ClientBounds;
                windowResized(parent.Window.ClientBounds);
            }
            if (!newKeyboardState.IsKeyDown(Keys.Escape) && _keyboardState.IsKeyDown(Keys.Escape))
                _menu.Visible = !_menu.Visible;
            bool isClick = false;
            if (_mouseState != newMouseState)
            {
                mouse.Position = new Rectangle(newMouseState.X, newMouseState.Y, mouse.Position.Width, mouse.Position.Height);
                isClick = newMouseState.LeftButton == ButtonState.Pressed && _mouseState.LeftButton == ButtonState.Released;
            }

            _menu.HandleInput(newKeyboardState, newMouseState, parent);
            if (_menu.Choise == 0)
                parent.SwitchScene(Scene.MainMenu);

            if (newKeyboardState.IsKeyDown(Keys.Right))
                map.Moving(new Vector2(5, 0), true);
            if (newKeyboardState.IsKeyDown(Keys.Left))
                map.Moving(new Vector2(-5, 0), true);
            if (newKeyboardState.IsKeyDown(Keys.Up))
                map.Moving(new Vector2(0, -5), true);
            if (newKeyboardState.IsKeyDown(Keys.Down))
                map.Moving(new Vector2(0, 5), true);

            _keyboardState = newKeyboardState;
            _mouseState = newMouseState;
        }
 /// <summary>
 /// Gestion de l'evenement de selection
 /// </summary>
 /// <param name="parent">Reference de la classe Game1 parent</param>
 private void selectionEvent(Game1 parent)
 {
     parent.son.Play(Sons.MenuSelection);
     switch (selection)
     {
         case Selection.Exit:
             parent.Exit();
             break;
         case Selection.Play:
             parent.SwitchScene(Scene.InGame);
             break;
         case Selection.Extra:
             parent.SwitchScene(Scene.Extra);
             break;
         case Selection.Credit:
             parent.SwitchScene(Scene.Credit);
             break;
         case Selection.Options:
             parent.SwitchScene(Scene.Options);
             break;
     }
 }
        public override void HandleInput(KeyboardState newKeyboardState, MouseState newMouseState, Game1 parent)
        {
            Rectangle newWindowSize = parent.Window.ClientBounds;
            if (newWindowSize.Width != windowWidth || newWindowSize.Height != windowHeight)
                windowResized(newWindowSize);
            if (parent.IsActive)
            {
                if (newKeyboardState.IsKeyDown(Keys.Escape) && !keyboardState.IsKeyDown(Keys.Escape))
                {
                    if (selection == Selection.Exit)
                        parent.SwitchScene(Scene.Titre);
                    else
                    {
                        selection = Selection.Exit;
                        parent.son.Play(Sons.MenuSelection);
                    }
                }
                if (newKeyboardState.IsKeyDown(Keys.Right) && !keyboardState.IsKeyDown(Keys.Right))
                {
                    selection++;
                    parent.son.Play(Sons.MenuSelection);
                }
                if (newKeyboardState.IsKeyDown(Keys.Left) && !keyboardState.IsKeyDown(Keys.Left))
                {
                    selection--;
                    parent.son.Play(Sons.MenuSelection);
                }
                if (newKeyboardState.IsKeyDown(Keys.Up) && !keyboardState.IsKeyDown(Keys.Up))
                {
                    selection--;
                    parent.son.Play(Sons.MenuSelection);
                }
                if (newKeyboardState.IsKeyDown(Keys.Down) && !keyboardState.IsKeyDown(Keys.Down))
                {
                    selection++;
                    parent.son.Play(Sons.MenuSelection);
                }
                if ((int)selection >= menuItems.Count)
                    selection = (Selection)0;
                else if ((int)selection < 0)
                    selection = (Selection)(menuItems.Count - 1);

                if (newKeyboardState.IsKeyDown(Keys.Enter) && !keyboardState.IsKeyDown(Keys.Enter))
                {
                    selectionEvent(parent);
                }

                if (mousestate != newMouseState)
                {
                    bool isClicked = newMouseState.LeftButton == ButtonState.Pressed && mousestate.LeftButton == ButtonState.Released;
                    mouse.EmitterLocation = new DecimalRectangle(newMouseState.X, newMouseState.Y,0,0);
                    int i = 0;
                    foreach (Sprite st in menuItems.Values)
                    {
                        if (st.Position.Intersects(new Rectangle((int)mouse.EmitterLocation.X, (int)mouse.EmitterLocation.Y, 1, 1)))
                        {
                            if ((int)selection != i)
                                parent.son.Play(Sons.MenuSelection);
                            selection = (Selection)i;
                            if (isClicked)
                                selectionEvent(parent);
                        }
                        i++;
                    }
                    if (isClicked)
                    {
                        sprites.Add(new AnimatedSprite(new Rectangle(newMouseState.X - windowWidth / 3 / 2, newMouseState.Y - windowHeight / 3 / 2, windowWidth / 3, windowHeight / 3), newWindowSize, 8, 5, 35));
                        sprites.Last<AnimatedSprite>().LoadContent(cursorClic);
                    }
                }

                keyboardState = newKeyboardState;
                mousestate = newMouseState;
            }
        }
Ejemplo n.º 9
0
 public override void HandleInput(KeyboardState newKeyboardState, MouseState newMouseState, Game1 parent)
 {
     if (parent.Window.ClientBounds != this._windowSize)
         this.windowResized(parent.Window.ClientBounds);
     if (!newKeyboardState.IsKeyDown(Keys.Escape) && this._keyboardState.IsKeyDown(Keys.Escape))
         this._menu.Visible = !this._menu.Visible;
     bool flag = false;
     if (this._mouseState != newMouseState)
     {
         this.mouse.Position = new Rectangle(newMouseState.X, newMouseState.Y, this.mouse.Position.Width, this.mouse.Position.Height);
         flag = newMouseState.LeftButton == ButtonState.Pressed && this._mouseState.LeftButton == ButtonState.Released;
     }
     this._menu.HandleInput(newKeyboardState, newMouseState, parent);
     if (this._menu.Choise == 0)
         parent.SwitchScene(Scene.MainMenu);
     else if (this._menu.Choise == 1)
         StartServer();
     else if (this._menu.Choise == 2)
         Connection();
     else if (this._menu.Choise == 3)
         StopAllConnections();
     _menu.Choise = ContextMenu.NONE;
     int num;
     if ((num = this._hud.SelectedWeapon(this._mouseState)) >= 0)
         this.personnage.Weapon = num;
     float move = (float)_windowSize.Width * 0.005555556f;
     if (newKeyboardState.IsKeyDown(Keys.Right) && this.personnage._canMove && this._maps[this._currentMap].Moving(new Vector2(move * (_dashing ? DashSpeed : 1f), 0.0f), true))
     {
         foreach (Mob mob in this._mobs[this._currentMap])
             mob.Move((int)((float)move * (_dashing ? DashSpeed : 1f)), 0);
         foreach (Attack attack in this.personnage.Attacks.Values)
             attack.Move((int)((float)move * (_dashing ? DashSpeed : 1f)), 0);
     }
     if (newKeyboardState.IsKeyDown(Keys.Left) && this.personnage._canMove && this._maps[this._currentMap].Moving(new Vector2(-move * (_dashing ? DashSpeed : 1f), 0.0f), true))
     {
         foreach (Mob mob in this._mobs[this._currentMap])
             mob.Move(-(int)((float)move * (_dashing ? DashSpeed : 1f)), 0);
         foreach (Attack attack in this.personnage.Attacks.Values)
             attack.Move(-(int)((float)move * (_dashing ? DashSpeed : 1f)), 0);
     }
     // DASH
     if (newKeyboardState.IsKeyDown(Keys.Right) && _keyboardState.IsKeyUp(Keys.Right) || newKeyboardState.IsKeyDown(Keys.Left) && _keyboardState.IsKeyUp(Keys.Left))
     {
         if (_waitingDash && _dashTimer < DashKeyDelay)
         {
             _dashing = true;
         }
         else if (!_waitingDash)
         {
             _waitingDash = true;
         }
         else
             _waitingDash = false;
         _dashTimer = 0;
     }
     if (newKeyboardState.IsKeyDown(Keys.Up) && this.personnage._canMove && this._maps[this._currentMap].Moving(new Vector2(0.0f, -move), true))
     {
         foreach (Mob mob in this._mobs[this._currentMap])
             mob.Move(0, -(int)move);
         foreach (Attack attack in this.personnage.Attacks.Values)
             attack.Move(0, -(int)(0.4f * move));
     }
     if (newKeyboardState.IsKeyDown(Keys.Down) && this.personnage._canMove && this._maps[this._currentMap].Moving(new Vector2(0.0f, move), true))
     {
         foreach (Mob mob in this._mobs[this._currentMap])
             mob.Move(0, (int)move);
         foreach (Attack attack in this.personnage.Attacks.Values)
             attack.Move(0, (int)(0.4f * move));
     }
     this.personnage.HandleInput(newKeyboardState, newMouseState, parent);
     this._hud.HandleInput(newKeyboardState, newMouseState, parent);
     if ((double)this.personnage.Life <= 0.0)
     {
         parent.SwitchScene(Scene.GameOver);
         _animDone = false;
     }
     if (newKeyboardState.IsKeyDown(Keys.E) && this._keyboardState.IsKeyUp(Keys.E))
     {
         int map = _currentMap;
         if (_mobs[_currentMap].Count <= 0)
             this._currentMap += this._maps[this._currentMap].GetTravelState(this.personnage.DrawingRectangle);
         if (this._currentMap < 0)
             this._currentMap = 0;
         if (map != _currentMap)
         {
             _animDone = false;
             parent.SwitchScene(Scene.InGame);
         }
     }
     this._keyboardState = newKeyboardState;
     this._mouseState = newMouseState;
 }
Ejemplo n.º 10
0
 public override void Activation(Game1 parent)
 {
     Game1.son.Play(Musiques.Jeu);
     if (!_animDone)
     {
         _animDone = true;
         switch (_currentMap)
         {
             case 0:
                 parent.SwitchScene(Scene.IntroLateX);//Combat contre toutes les créatures de LateX(map verte)
                 break;
             case 1:
                 parent.SwitchScene(Scene.LateXEradicated);//combat contre l'armée du roi de LateX(map chateau)
                 break;
             case 2:
                 parent.SwitchScene(Scene.BeforeKingFight);//combat contre roi de LateX (armée éradiquée)(re map chateau)
                 break;
             case 3:
                 parent.SwitchScene(Scene.AfterKingFight);//retour sur OpenEdge + combat armée(map dark)
                 break;
             case 4:
                 parent.SwitchScene(Scene.LastFight);//combat contre Spark(re map dark sauf si on a le temps d'en faire une autre)
                 break;
             case 5:
                 _currentMap = 0;
                 parent.SwitchScene(Scene.Credit);
                 break;
         }
     }
     this._mouseState = Mouse.GetState();
     this._keyboardState = Keyboard.GetState();
     this._menu.Activation(parent);
     Load();
 }
        public override void HandleInput(KeyboardState newKeyboardState, MouseState newMouseState, Game1 parent)
        {
            if (parent.Window.ClientBounds != _windowSize)
            {
                windowResized(parent.Window.ClientBounds);
            }
            if (!newKeyboardState.IsKeyDown(Keys.Escape) && _keyboardState.IsKeyDown(Keys.Escape))
                _menu.Visible = !_menu.Visible;
            bool isClick = false;
            if (_mouseState != newMouseState)
            {
                mouse.Position = new Rectangle(newMouseState.X, newMouseState.Y, mouse.Position.Width, mouse.Position.Height);
                isClick = newMouseState.LeftButton == ButtonState.Pressed && _mouseState.LeftButton == ButtonState.Released;
            }

            _menu.HandleInput(newKeyboardState, newMouseState, parent);
            if (_menu.Choise == 0)
                parent.SwitchScene(Scene.MainMenu);

            //// MOUVEMENT ////
            if (newKeyboardState.IsKeyDown(Keys.Right) && personnage._canMove)
            {
                if (_maps[_currentMap].Moving(new Vector2(5, 0), true))
                    foreach (Mob m in _mobs[_currentMap])
                        m.Move(5, 0);
            }
            if (newKeyboardState.IsKeyDown(Keys.Left) && personnage._canMove)
            {
                if (_maps[_currentMap].Moving(new Vector2(-5, 0), true))
                    foreach (Mob m in _mobs[_currentMap])
                        m.Move(-5, 0);
            }
            if (newKeyboardState.IsKeyDown(Keys.Up) && personnage._canMove)
            {
                if (_maps[_currentMap].Moving(new Vector2(0, -5), true))
                    foreach (Mob m in _mobs[_currentMap])
                        m.Move(0, -5);
            }
            if (newKeyboardState.IsKeyDown(Keys.Down) && personnage._canMove)
            {
                if (_maps[_currentMap].Moving(new Vector2(0, 5), true))
                    foreach (Mob m in _mobs[_currentMap])
                        m.Move(0, 5);
            }
            if (newKeyboardState.IsKeyDown(Keys.E) && _keyboardState.IsKeyUp(Keys.E))
            {
                _currentMap += _maps[_currentMap].GetTravelState(personnage.DrawingRectangle);
                if (_currentMap < 0)
                    _currentMap = 0;
                else if (_currentMap >= _maps.Count)
                    _currentMap = _maps.Count - 1;
            }
            personnage.HandleInput(newKeyboardState, newMouseState, parent);
            _hud.HandleInput(newKeyboardState, newMouseState, parent);

            if (personnage.Life <= 0)
                parent.SwitchScene(Scene.MainMenu);

            _keyboardState = newKeyboardState;
            _mouseState = newMouseState;
        }
        public override void HandleInput(KeyboardState newKeyboardState, MouseState newMouseState, Game1 parent)
        {
            if (parent.Window.ClientBounds != _windowSize)
            {
                _windowSize = parent.Window.ClientBounds;
                windowResized(_windowSize);
            }
            if (!newKeyboardState.IsKeyDown(Keys.Escape) && _keyboardState.IsKeyDown(Keys.Escape))
                menu.Visible = !menu.Visible;
            if (_mouseState != newMouseState)
                mouse.Position = new Rectangle(newMouseState.X, newMouseState.Y, mouse.Position.Width, mouse.Position.Height);

            menu.HandleInput(newKeyboardState, newMouseState, parent);
            if (menu.Choise == menu.Elements.Count - 1)
                parent.SwitchScene(Scene.MainMenu);
            else if (menu.Choise >= 0 && menu.Choise < menu.Elements.Count)
                selectedSprite = menu.Choise;

            if (newMouseState.LeftButton == ButtonState.Pressed && _mouseState.LeftButton != ButtonState.Pressed)
            {
                Rectangle clic = new Rectangle(mouse.Position.X, mouse.Position.Y, 1, 1);
                bool startAnimation = true;
                if (clic.Intersects(tailleSelection.Position))
                {
                    startAnimation = false;
                    currentSize = clic.X - tailleSelection.Position.X;
                }
                if (clic.Intersects(menu.Position) && menu.Visible)
                    startAnimation = false;
                if (startAnimation)
                {
                    AnimatedSprite s = menu.Elements.ElementAt<AnimatedSprite>(selectedSprite);
                    animations.Add(new AnimatedSprite(
                        new Rectangle(clic.X - currentSize / 2, clic.Y - currentSize / 2, currentSize, currentSize),
                        _windowSize, s.AssetName, s.Colonnes, s.Lignes));
                    animations.Last<AnimatedSprite>().LoadContent(parent.Content);
                }
            }

            _keyboardState = newKeyboardState;
            _mouseState = newMouseState;
        }
        public override void HandleInput(KeyboardState newKeyboardState, MouseState newMouseState, Game1 parent)
        {
            if (parent.Window.ClientBounds != _windowSize)
            {
                _windowSize = parent.Window.ClientBounds;
                windowResized(_windowSize);
            }
            if (!newKeyboardState.IsKeyDown(Keys.Escape) && _keyboardState.IsKeyDown(Keys.Escape))
                parent.SwitchScene(Scene.MainMenu);
            if (_mouseState != newMouseState)
                mouse.Position = new Rectangle(newMouseState.X, newMouseState.Y, mouse.Position.Width, mouse.Position.Height);

            bool isClick = newMouseState.LeftButton == ButtonState.Pressed && _mouseState.LeftButton != ButtonState.Pressed;

            if (isClick)
            {
                Rectangle clic = new Rectangle(mouse.Position.X, mouse.Position.Y, 1, 1);
                bool startAnimation = true;
                if (clic.Intersects(tailleSelection.Position))
                {
                    startAnimation = false;
                    currentSize = clic.X - tailleSelection.Position.X;
                }
                foreach (AnimatedSprite s in textures)
                {
                    if (clic.Intersects(s.Position))
                    {
                        startAnimation = false;
                        selectedSprite = textures.IndexOf(s);
                    }
                }
                if (startAnimation)
                {
                    AnimatedSprite oc = textures.ElementAt<AnimatedSprite>(selectedSprite);
                    animations.Add(new AnimatedSprite(
                        new Rectangle(clic.X - currentSize / 2, clic.Y - currentSize / 2, currentSize, currentSize),
                        _windowSize, oc.AssetName,
                        oc.Colonnes, oc.Lignes));
                    animations.Last<AnimatedSprite>().LoadContent(parent.Content);
                }
            }

            //particle test
            Snow.EmitterLocation = new Rectangle(0, 0, _windowSize.Width, 0);
            Fire.EmitterLocation = new Rectangle(newMouseState.X, newMouseState.Y, 0, 0);
            //fin test

            _keyboardState = newKeyboardState;
            _mouseState = newMouseState;
        }
        public override void HandleInput(KeyboardState newKeyboardState, MouseState newMouseState, Game1 parent)
        {
            if (_windowSize != parent.Window.ClientBounds)
            {
                _windowSize = parent.Window.ClientBounds;
                WindowResized(parent.Window.ClientBounds);
            }

            if (newMouseState != _mouseState)
            {
                _mouse.Position = new Rectangle(newMouseState.X, newMouseState.Y, _mouse.Position.Width, _mouse.Position.Height);
                if (_checkUpdate.Position.Contains(newMouseState.X, newMouseState.Y) && !_checkUpdate.Position.Contains(_mouseState.X, _mouseState.Y))
                    Game1.son.Play(Sons.MenuSelection);
                if (_serverConfig.Position.Contains(newMouseState.X, newMouseState.Y) && !_serverConfig.Position.Contains(_mouseState.X, _mouseState.Y))
                    Game1.son.Play(Sons.MenuSelection);
                if (_fullScreen.Position.Contains(newMouseState.X, newMouseState.Y) && !_fullScreen.Position.Contains(_mouseState.X, _mouseState.Y))
                    Game1.son.Play(Sons.MenuSelection);
                if (_language.Position.Contains(newMouseState.X, newMouseState.Y) && !_language.Position.Contains(_mouseState.X, _mouseState.Y))
                    Game1.son.Play(Sons.MenuSelection);
            }

            if (newKeyboardState.IsKeyDown(Keys.Escape) && !_keyboardState.IsKeyDown(Keys.Escape))
                parent.SwitchScene(Scene.MainMenu);

            if (newMouseState.LeftButton == ButtonState.Pressed)
            {
                Rectangle click = new Rectangle(newMouseState.X, newMouseState.Y, 1, 1);

                if (_soundEffect.Position.Intersects(click))
                    _volumeEffect = (float)(click.X - _soundEffect.Position.X) / (float)_soundEffect.Position.Width;
                if (_soundMusic.Position.Intersects(click))
                    _volumeMusic = (float)(click.X - _soundMusic.Position.X) / (float)_soundMusic.Position.Width;
                if (_mouseState.LeftButton == ButtonState.Released)
                {
                    if (_checkUpdate.Position.Intersects(click) && _mouseState.LeftButton != ButtonState.Pressed)
                        CheckUpdate();
                    if (_serverConfig.Position.Intersects(click) && _mouseState.LeftButton != ButtonState.Pressed)
                    {
                        try
                        {
                            System.Diagnostics.Process.Start("ServerConfig.exe");
                        }
                        catch (Exception)
                        {
                            System.Windows.Forms.MessageBox.Show(INFO.ENG?"File \"ServerConfig.exe\" not found.":"Fichier \"ServerConfig.exe\" introuvable");
                        }
                    }
                    if (_fullScreen.Position.Intersects(click) && _mouseState.LeftButton != ButtonState.Pressed)
                    {
                        parent.Graphics.IsFullScreen = !parent.Graphics.IsFullScreen;
                        parent.Graphics.ApplyChanges();
                    }
                    if (_language.Position.Intersects(click) && _mouseState.LeftButton != ButtonState.Pressed)
                    {
                        EugLib.IO.FileStream.writeFile("files/language", INFO.ENG?"f": "e");
                        System.Windows.Forms.MessageBox.Show(INFO.ENG?"Vous devez relancer le jeu pour que les modifications prennent effet.":"You must restart the game to apply changes.");
                    }
                }

                Game1.son.MusiquesVolume = _volumeMusic;
                Game1.son.SonsVolume = _volumeEffect;

                EugLib.IO.FileStream.writeFile(SOUND_FILENAME, _volumeMusic + " " + _volumeEffect);
            }

            _keyboardState = newKeyboardState;
            _mouseState = newMouseState;
        }
 public override void HandleInput(KeyboardState newKeyboardState, MouseState newMouseState, Game1 parent)
 {
     if (newKeyboardState.IsKeyDown(Keys.Space) && _keyboardState.IsKeyUp(Keys.Space) || Over())
         parent.SwitchScene(_nextScene);
     _keyboardState = newKeyboardState;
     if (parent.Window.ClientBounds != _windowSize)
         WindowResized(parent.Window.ClientBounds);
     foreach (AnimPictures ap in animation)
         ap.Image.HandleInput(newKeyboardState, newMouseState, parent);
 }
Ejemplo n.º 16
0
        public override void HandleInput(KeyboardState newKeyboardState, MouseState newMouseState, Game1 parent)
        {
            if (parent.Window.ClientBounds != _windowSize)
            {
                _windowSize = parent.Window.ClientBounds;
                windowResized(parent.Window.ClientBounds);
            }
            if (!newKeyboardState.IsKeyDown(Keys.Escape) && _keyboardState.IsKeyDown(Keys.Escape))
                parent.SwitchScene(Scene.MainMenu);
            bool isClick = false;
            if (_mouseState != newMouseState)
            {
                mouse.Position = new Rectangle(newMouseState.X, newMouseState.Y, mouse.Position.Width, mouse.Position.Height);
                isClick = newMouseState.LeftButton == ButtonState.Pressed && _mouseState.LeftButton == ButtonState.Released;
            }

            if (newKeyboardState.IsKeyDown(Keys.Right))
                map.Moving(new Vector2(_speedPerso, 0), true);
            if (newKeyboardState.IsKeyDown(Keys.Left))
                map.Moving(new Vector2(-_speedPerso, 0), true);
            if (newKeyboardState.IsKeyDown(Keys.Up))
                map.Moving(new Vector2(0, -_speedPerso), true);
            if (newKeyboardState.IsKeyDown(Keys.Down))
                map.Moving(new Vector2(0, _speedPerso), true);

            //perso
            if (_keyboardState != newKeyboardState)
            {
                if (newKeyboardState.IsKeyDown(Keys.Space))
                    personnage.JumpR(18);
                if (newKeyboardState.IsKeyDown(Keys.Right) && !newKeyboardState.IsKeyDown(Keys.Space))
                    personnage.RunR(18);
                if (newKeyboardState.IsKeyDown(Keys.Left) && !newKeyboardState.IsKeyDown(Keys.Space))
                    personnage.RunL(18);
                if (!newKeyboardState.IsKeyDown(Keys.Space) && !newKeyboardState.IsKeyDown(Keys.Left) && !newKeyboardState.IsKeyDown(Keys.Right))
                    personnage.Stop(3);
            }

            _keyboardState = newKeyboardState;
            _mouseState = newMouseState;
        }