Esempio n. 1
0
 public void SignedInGamer_SignedIn(Object sender, SignedInEventArgs e)
 {
     player = new Player(e.Gamer);
 }
Esempio n. 2
0
        protected void UpdateInput()
        {
            var currentState = GamePad.GetState(PlayerIndex.One);

            if (currentState.IsConnected && player.CurrentGameState == GameState.GameStarted)
            {
                player.Ship.Update(currentState);
                PlayEngineSound(currentState);

                if (currentState.Buttons.B == ButtonState.Pressed && player.NumberOfLives > 0)
                {
                    player.WrapToCenter();
                    soundHyperspaceActivation.Play();
                }

                if (player.Ship.IsActive && currentState.Buttons.A == ButtonState.Pressed && lastState.Buttons.A == ButtonState.Released)
                {
                    player.ShootBullet();
                    soundWeaponsFire.Play();
                }

                if (player.HasBomb && currentState.Buttons.Y == ButtonState.Pressed && lastState.Buttons.Y == ButtonState.Released)
                    player.DeployBomb();
            }

            if (TitleScreenIsDisplayed(currentState))
                StartGame();

            if (player.CurrentGameState == GameState.GameEnded && currentState.Buttons.A == ButtonState.Pressed && lastState.Buttons.A == ButtonState.Released)
            {
                player = new Player(Gamer.SignedInGamers[PlayerIndex.One]);
                StartGame();
            }

            if (player.Ship.IsActive && currentState.Triggers.Left > 0)
                player.Ship.Velocity *= 1.05f;

            lastState = currentState;
        }