public TKButtons CurrentState(PlayerIndex index)
        {
            //switch(
            TKButtons    state   = TKButtons.None;
            GamePadState gpState = GamepadExtended.Current(index).CurrentState;

            if (gpState.IsButtonDown(Buttons.A))
            {
                state = state | TKButtons.Green;
            }
            if (gpState.IsButtonDown(Buttons.Y))
            {
                state = state | TKButtons.Yellow;
            }
            if (gpState.IsButtonDown(Buttons.B))
            {
                state = state | TKButtons.Red;
            }
            if (gpState.IsButtonDown(Buttons.X))
            {
                state = state | TKButtons.Blue;
            }

            return(state);
        }
示例#2
0
 public static bool ButtonClickedOnAnyController(Buttons button)
 {
     return
         (GamepadExtended.Current(PlayerIndex.One).WasSingleClick(button) |
          GamepadExtended.Current(PlayerIndex.Two).WasSingleClick(button) |
          GamepadExtended.Current(PlayerIndex.Three).WasSingleClick(button) |
          GamepadExtended.Current(PlayerIndex.Four).WasSingleClick(button));
 }
示例#3
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            switch (m_currentPlayState)
            {
            case GameStates.GetReady:
                if ((DateTime.Now - playStateChangedTime) > TimeSpan.FromSeconds(3))
                {
                    SetGameState(GameStates.Playing);
                }
                break;

            case GameStates.Playing:

                foreach (var player in GameEnvironment.CurrentPlayers)
                {
                    foreach (var buttonValue in (Buttons[])Enum.GetValues(typeof(Buttons)))
                    {
                        if (GamepadExtended.Current(player.PlayerIndex).IsNewDown(buttonValue))
                        {
                            player.Club.Slå();
                            if (m_Barrel.CheckHit(ColorUtils.ButtonToColor(buttonValue)))
                            {
                                player.Points += PointsForHit;
                                player.HitFeedback();
                                Sound.Sounds.PlayPoint(player.PlayerIndex);
                                if (m_Barrel.StavesLeft == 0)
                                {
                                    SetGameState(GameStates.GameOver);
                                }
                            }
                            else
                            {
                                player.Points += PointsForMiss;
                                Sound.Sounds.PlayBarn();
                            }
                        }
                    }
                }
                break;

            case GameStates.GameOver:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            for (int i = 0; i < GameEnvironment.CurrentPlayers.Count; i++)
            {
                PointDisplays[i].Text = GameEnvironment.CurrentPlayers[i].Points.ToString();
            }
        }
 public void GetState(PlayerIndex index, GameTime gametime)
 {
     GamepadExtended.Current(index).GetState(gametime);
 }