コード例 #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);
            }
        }
コード例 #2
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;

            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);
            }
        }