Exemple #1
0
        //#################################
        // Handle input
        //#################################
        public override void HandleInput(InputState input)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            // Look up inputs for the player.
            KeyboardState keyboardState = input.CurrentKeyboardState;

            // key for the ship etc.
            if (input.IsNewKeyPress(Keys.B))
            {
                if ((Vector3.Distance(_station.Position, _droneFleet.GetActiveDrone().Position) - _stationHeight) < 150)
                {
                    //playing the sound
                    _soundEngine.Play2D("openShop", Global.SpeakerVolume / 10, false);
                    if (shop == null)
                    {
                        shop = new ShopScreen(_droneFleet, _station);
                    }
                    ScreenManager.AddScreen(shop);
                }
            }

            //player hits ESC it pauses the game
            if (input.IsPauseGame())
            {
                //playing the sound
                _soundEngine.Play2D("openShop", Global.SpeakerVolume / 10, false);
                if (pause == null)
                {
                    pause = new PauseMenuScreen();
                }
                ScreenManager.AddScreen(pause);
            }
        }
        //#################################
        // Handle input
        //#################################
        public override void HandleInput(InputState input)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            // Look up inputs for the player.
            KeyboardState keyboardState = input.CurrentKeyboardState;

            TutorialText.TryGetValue(nextIndex, out tutorialMessage);
            if (nextIndex == 0)
            {
                if (input.IsNewKeyPress(Keys.Y))
                {
                    Global.MusicEngine.StopAllSounds();
                    ScreenManager.AddScreen(new GameplayScreen());
                    ScreenManager.RemoveScreen(this);
                }
                else if (input.IsNewKeyPress(Keys.N))
                {
                    //playing the sound
                    _engine.SetListenerPosition(new Vector3D(0, 0, 0), new Vector3D(0, 0, 1));
                    ISound Open;
                    Open        = _engine.Play2D(_openShop, false, true, false);
                    Open.Volume = Global.SpeakerVolume / 10;
                    Open.Paused = false;

                    nextIndex++;
                    TutorialText.TryGetValue(nextIndex, out tutorialMessage);
                }
            }
            else
            {
                // key for the ship etc.
                if (input.IsNewKeyPress(Keys.B))
                {
                    if ((Vector3.Distance(_station.Position, _droneFleet.GetActiveDrone().Position) - _stationHeight) < 150)
                    {
                        //playing the sound
                        _engine.SetListenerPosition(new Vector3D(0, 0, 0), new Vector3D(0, 0, 1));
                        ISound Open;
                        Open        = _engine.Play2D(_openShop, false, true, false);
                        Open.Volume = Global.SpeakerVolume / 10;
                        Open.Paused = false;
                        if (shop == null)
                        {
                            shop = new ShopScreen(_droneFleet, _station);
                        }
                        ScreenManager.AddScreen(shop);
                    }
                }
                if (input.IsNewKeyPress(Keys.Space) && (nextIndex + 1) < TutorialText.Count && (nextIndex + 1) > 0)
                {
                    //playing the sound
                    _engine.SetListenerPosition(new Vector3D(0, 0, 0), new Vector3D(0, 0, 1));
                    ISound Open;
                    Open        = _engine.Play2D(_openShop, false, true, false);
                    Open.Volume = Global.SpeakerVolume / 10;
                    Open.Paused = false;

                    nextIndex++;
                    TutorialText.TryGetValue(nextIndex, out tutorialMessage);
                    if (nextIndex == TutorialText.Count - 1)
                    {
                        movementAllowed = true;
                    }
                }
            }

            if (input.IsNewKeyPress(Keys.Back) && nextIndex < TutorialText.Count && (nextIndex - 1) >= 0)
            {
                //playing the sound
                _engine.SetListenerPosition(new Vector3D(0, 0, 0), new Vector3D(0, 0, 1));
                ISound Open;
                Open        = _engine.Play2D(_openShop, false, true, false);
                Open.Volume = Global.SpeakerVolume / 10;
                Open.Paused = false;

                nextIndex--;
                TutorialText.TryGetValue(nextIndex, out tutorialMessage);
            }
            if (movementAllowed)
            {
                if (input.IsNewKeyPress(Keys.X))
                {
                    Global.MusicEngine.StopAllSounds();
                    ScreenManager.AddScreen(new GameplayScreen());
                    ScreenManager.RemoveScreen(this);
                }
            }
            //player hits ESC it pauses the game
            if (input.IsPauseGame())
            {
                if (pause == null)
                {
                    pause = new PauseMenuScreen();
                }
                ScreenManager.AddScreen(pause);
            }
        }
Exemple #3
0
        //#################################
        // Handle Input
        //#################################
        public override void HandleInput(InputState input)
        {
            // mouse click on menu?
            if (input.IsLeftMouseButtonNewPressed())
            {
                Vector2 cornerA;
                Vector2 cornerD;
                for (int i = 0; i < menuEntries.Count; i++)
                {
                    //calculating 2 diagonal corners of current menuEntry (upper left, bottom right)
                    cornerA    = menuEntries[i].Position;
                    cornerA.Y -= menuEntries[i].GetHeight() / 2f;

                    cornerD    = menuEntries[i].Position;
                    cornerD.Y += menuEntries[i].GetHeight() / 2f;
                    cornerD.X += menuEntries[i].GetWidth();

                    if (cornerA.X < input.MousePosition.X && cornerA.Y < input.MousePosition.Z)
                    {
                        if (cornerD.X > input.MousePosition.X && cornerD.Y > input.MousePosition.Z)
                        {
                            selectedEntry = i;
                            OnSelectEntry(selectedEntry);
                        }
                    }
                    else
                    {
                        continue;
                    }
                }
            }

            // Move to the previous menu entry?
            if (input.IsMenuUp())
            {
                //playing the sound
                SoundEngine.Play2D("MenuAcceptSound", Global.SpeakerVolume / 10, false);
                selectedEntry--;

                if (selectedEntry < 0)
                {
                    selectedEntry = menuEntries.Count - 1;
                }
            }

            // Move to the next menu entry?
            if (input.IsMenuDown())
            {
                //playing the sound
                SoundEngine.Play2D("MenuAcceptSound", Global.SpeakerVolume / 10, false);
                selectedEntry++;

                if (selectedEntry >= menuEntries.Count)
                {
                    selectedEntry = 0;
                }
            }

            // Accept or cancel the menu.
            if (input.IsMenuSelect())
            {
                OnSelectEntry(selectedEntry);
            }
            else if (input.IsMenuCancel())
            {
                OnCancel();
            }
        }
        //#################################
        // Handle input
        //#################################
        public override void HandleInput(InputState input)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            // Look up inputs for the player.
            KeyboardState keyboardState = input.CurrentKeyboardState;

            // key for the ship etc.
            if (input.IsNewKeyPress(Keys.B))
            {
                if ((Vector3.Distance(_station.Position, _droneFleet.GetActiveDrone().Position) - _stationHeight) < 150 && Global.DemoMode == "Gameplay")
                {
                    //playing the sound
                    _soundEngine.Play2D("openShop", Global.SpeakerVolume / 10, false);
                    if (shop == null)
                    {
                        shop = new ShopScreen(_droneFleet, _station);
                    }
                    ScreenManager.AddScreen(shop);
                }
                if (Global.DemoMode == "Models")
                {
                    _boidsActivate = true;
                }
            }

            if (Global.DemoMode == "Effects")
            {
                if (_input.IsNewKeyPress(Keys.C))
                {
                    _effect++;
                    if (_effect > 2)
                    {
                        _effect = 0;
                    }
                }
                if (_input.IsNewKeyPress(Keys.E))
                {
                    explosionList.Add(new ExplosionSystem(new ShipExplosionSettings(), _input.getMouseInWorldPos(), 0.4));
                    switch (_effect)
                    {
                    case 0:
                        explosionList.Add(new ExplosionSystem(new ShipExplosionSettings(), _input.getMouseInWorldPos(), 0.4));
                        break;

                    case 1:
                        explosionList.Add(new ExplosionSystem(new ShipExplosionSettings(), new ShipRingExplosionSettings(), _input.getMouseInWorldPos(), 0.4, 30));
                        break;

                    case 2:
                        explosionList.Add(new ExplosionSystem(new BombExplosionSettings(), new BombRingExplosionSettings(), _input.getMouseInWorldPos(), 0.4, 50, true));
                        break;
                    }
                }
            }

            //player hits ESC it pauses the game
            if (input.IsPauseGame())
            {
                //playing the sound
                _soundEngine.Play2D("openShop", Global.SpeakerVolume / 10, false);
                if (pause == null)
                {
                    pause = new DemoPauseMenuScreen();
                }
                ScreenManager.AddScreen(pause);
            }
        }