Esempio n. 1
0
        public void Update(UpdateState state)
        {
            //when a button is pressed, load the game..
            //Note the player index selected in the startup screen is used here...
            Xen.Input.State.InputState input = state.PlayerInput[this.stateManager.PlayerIndex].InputState;

            if (input.Buttons.A.OnReleased ||
                input.Buttons.B.OnReleased ||
                input.Buttons.X.OnReleased ||
                input.Buttons.Y.OnReleased)
            {
                //we want to start playing the game!

                //create a new game to play.
                IProgressGameState gameState = new PlayingState(this.stateManager.Application);

                //load the game, through a LoadingState
                IGameState loadingState = new LoadingState(gameState);

                //go to the loading state.
                this.stateManager.SetState(loadingState);
                return;
            }

            if (input.Buttons.Back.OnPressed)
            {
                //quit when back is pressed in the menu
                this.stateManager.Application.Shutdown();
                return;
            }
        }
Esempio n. 2
0
        //read the user input position, which is used to control the sprites.
        public void Update(UpdateState state)
        {
            Xen.Input.State.InputState input = state.PlayerInput[this.stateManager.PlayerIndex].InputState;

            //compute the new input position (thumbstick location of the magnet)
            //note, this isn't used for the calculations directly, inputPositionBuffer is...
            this.inputPosition   = input.ThumbSticks.RightStick + input.ThumbSticks.LeftStick;
            this.inputPosition.X = this.inputPosition.X * 0.25f + 0.5f;
            this.inputPosition.Y = this.inputPosition.Y * 0.25f + 0.5f;
            this.inputPosition  *= this.windowSize;

            //if A is held down, the sprites are processed without the thread task
            runSingleThreaded = input.Buttons.A;

            //quit back to the menu?
            if (input.Buttons.Back.OnPressed)
            {
                //wait for the sprite processing to finish (if it's still running)
                updateTask.WaitForCompletion();

                //go back to the main menu when back is pressed
                this.stateManager.SetState(new MenuState());
                return;
            }
        }
Esempio n. 3
0
        public void Update(UpdateState state)
        {
            bool controllerSelected = false;

            //wait for a controller to press a button
            for (PlayerIndex index = PlayerIndex.One; index <= PlayerIndex.Four; index++)
            {
                //test each controller...
                Xen.Input.State.InputState input = state.PlayerInput[index].InputState;

                //has a button been pressed?
                if (input.Buttons.A.OnReleased ||
                    input.Buttons.Start.OnReleased)
                {
                    //Controller selected!
                    //this controller will be used from now on...
                    this.stateManager.PlayerIndex = index;
                    controllerSelected            = true;
                }
            }

            if (controllerSelected)
            {
                //go to the menu state.
                this.stateManager.SetState(new MenuState());
            }
        }