Example #1
0
 public override void HandleInput(InputState inputState)
 {
     if (_currentSymbol == Symbol.Wait && timer < waitTime)
     {
         timer += screenManager.currentGameTime.ElapsedGameTime.Milliseconds;
     }
     else if (_currentSymbol == Symbol.Wait && timer >= waitTime)
     {
         timer          = 0;
         waitTime       = 0;
         _currentSymbol = Symbol.None;
     }
     else if (_currentSymbol == Symbol.Switch)
     {
         if (inputState.IsKeyNewPressed(Keys.X))
         {
             _currentSymbol = Symbol.None;
         }
     }
     if (_currentSymbol == Symbol.Click && inputState.IsKeyNewPressed(Keys.X))
     {
         _currentSymbol = Symbol.None;
         _clickDots     = "";
         if (_currentString.Length == 0)
         {
             if (_messages.Count() > 1)
             {
                 Console.WriteLine(_messages.Count());
                 _messages.Remove(_messages[0]);
                 _currentString = _messages[0];
                 _drawString    = "";
             }
             else
             {
                 //Event handling was made here before - Removed because it did not work as intented
             }
         }
     }
     else if (_currentSymbol == Symbol.Char)
     {
         _currentSymbol = Symbol.None;
     }
     if (!_parsing && timer >= waitTime && _currentSymbol == Symbol.None)
     {
         if (_currentString.Length > 0)
         {
             ParseNextSymbol();
         }
         else
         {
             _currentSymbol = Symbol.Click;
         }
     }
 }
Example #2
0
        public override void HandleInput(InputState inputState)
        {
            base.HandleInput(inputState);
            if (inputState.IsKeyNewPressed(Keys.Up))
            {
                _mainMenu.GoUp();
            }
            else if (inputState.IsKeyNewPressed(Keys.Down))
            {
                _mainMenu.GoDown();
            }
            else if (inputState.IsKeyNewPressed(Keys.Enter))
            {
                _mainMenu.PressItem();
            }

            for (int i = 0; i < 4; i++)
            {
                inputState.ActivePlayerIndex = (PlayerIndex)i;
                if (inputState.GetLeftStickPosition().Y == 1)
                {
                    _mainMenu.GoUp();
                }
                else if (inputState.GetLeftStickPosition().Y < -0.5f)
                {
                    _mainMenu.GoDown();
                }
                else if (inputState.IsButtonNewPressed(Buttons.Start))
                {
                    _mainMenu.PressItem();
                }

            }

            if (_mainMenu.PressedItem.text == "Play Local Multiplayer")
            {
                screenManager.AddScreen(new PlayerSelectScreen());
            }
            else if (_mainMenu.PressedItem.text == "Quit Game")
            {
                screenManager.Game.Exit();
            }
        }
Example #3
0
        public void HandleInput(InputState inputState)
        {
            if (!showingDescription)
            {
                if (currentlySelected && childSelected == null && children.Count >= 0)
                {

                    if (inputState.IsKeyNewPressed(Keys.Up) && index > 0)
                    {
                        children[index].currentlyMarked = false;
                        index--;
                        children[index].currentlyMarked = true;
                        childMarked = children[index];
                        if (scrollable && !firstIndexSeen && index == 1)
                        {
                            scrollIndex--;
                        }
                    }
                    else if (inputState.IsKeyNewPressed(Keys.Down) && index + 1 < children.Count)
                    {
                        children[index].currentlyMarked = false;
                        index++;
                        children[index].currentlyMarked = true;
                        childMarked = children[index];
                        if (scrollable && !lastIndexSeen && lastDrawnIndex == index)
                        {
                            scrollIndex++;
                        }
                    }
                    else if (inputState.IsKeyNewPressed(Keys.Z))
                    {
                        if (level > 0)
                        {
                            currentlySelected = false;
                            currentlyMarked = true;
                            if (children.Count() > 0)
                            {
                                childMarked.currentlyMarked = false;
                                childSelected = null;
                            }
                            if (parent != null)
                            {
                                parent.childSelected = null;
                                parent.childMarked = parent.children[parent.index];
                            }

                        }
                    }
                    else if (inputState.IsKeyNewPressed(Keys.X) && children.Count() > 0 && !children[index].locked)
                    {
                        currentlySelected = true;
                        currentlyMarked = false;
                        children[index].currentlySelected = true;
                        childSelected = children[index];
                        if (parent != null)
                        {
                            parent.childMarked = null;
                        }
                        childMarked.currentlyMarked = false;
                        childMarked = null;
                        currentLevel++;
                    }
                    else if (inputState.IsKeyNewPressed(Keys.H) && childMarked != null)
                    {
                        showingDescription = true;
                    }
                }
                else if (childSelected != null)
                {
                    childSelected.HandleInput(inputState);
                }
            }
            else
            {
                showingDescription = false;
            }
        }
Example #4
0
        public override void HandleInput(InputState inputState)
        {
            base.HandleInput(inputState);

            bool reset = false;
            for (int i = 0; i < numberOfPlayers; i++)
            {
                _players[i].HandleInput(inputState, screenManager.currentGameTime);
                if (_playersRemaining.Count < 2)
                {
                    switch (usedControls[i])
                    {
                        case Tank.ControlScheme.Keyboard:
                            reset = inputState.IsKeyNewPressed(Keys.S);
                            break;
                        default:
                            inputState.ActivePlayerIndex = _players[i].GamePadIndex;
                            reset = inputState.IsButtonNewPressed(Buttons.Start);
                            break;
                    }
                    if (reset) StartNextRound(); break;
                }
            }
        }
        public override void HandleInput(InputState inputState)
        {
            if (_currentSymbol == Symbol.Wait && timer < waitTime)
            {
                timer += screenManager.currentGameTime.ElapsedGameTime.Milliseconds;

            }
            else if (_currentSymbol == Symbol.Wait && timer >= waitTime)
            {
                timer = 0;
                waitTime = 0;
                _currentSymbol = Symbol.None;
            }
            else if (_currentSymbol == Symbol.Switch)
            {
                if (inputState.IsKeyNewPressed(Keys.X))
                {
                    _currentSymbol = Symbol.None;
                }
            }
            if (_currentSymbol == Symbol.Click && inputState.IsKeyNewPressed(Keys.X))
            {
                _currentSymbol = Symbol.None;
                _clickDots = "";
                if (_currentString.Length == 0)
                {
                    if (_messages.Count() > 1)
                    {
                        Console.WriteLine(_messages.Count());
                        _messages.Remove(_messages[0]);
                        _currentString = _messages[0];
                        _drawString = "";
                    }
                    else
                    {
                        //Event handling was made here before - Removed because it did not work as intented
                    }
                }
            }
            else if (_currentSymbol == Symbol.Char)
            {
                _currentSymbol = Symbol.None;
            }
            if (!_parsing && timer>= waitTime && _currentSymbol == Symbol.None)
            {
                if (_currentString.Length > 0)
                {
                    ParseNextSymbol();
                }
                else
                {
                    _currentSymbol = Symbol.Click;
                }
            }
        }
Example #6
0
        public void HandleInput(InputState inputState, GameTime gameTime)
        {
            if (canAct)
            {
                if (_health > 0)
                {
                    if (IsXboxControllerScheme(_usedControlScheme))
                    {
                        inputState.ActivePlayerIndex = _gamePadIndex;
                    }
                    HandleMovement(inputState, gameTime);
                    HandleOrientation(inputState);
                    HandleShooting(inputState, gameTime);

                    //Powerup
                    if (powerUpInSlot != null &&
                        (inputState.IsButtonNewPressed(Buttons.Y) ||
                        inputState.IsKeyNewPressed(Keys.LeftShift)))
                    {
                        ActivatePowerup();
                    }
                }

            }
        }
Example #7
0
 public void HandleInput(InputState inputState)
 {
     if (!showingDescription)
     {
         if (currentlySelected && childSelected == null && children.Count >= 0)
         {
             if (inputState.IsKeyNewPressed(Keys.Up) && index > 0)
             {
                 children[index].currentlyMarked = false;
                 index--;
                 children[index].currentlyMarked = true;
                 childMarked = children[index];
                 if (scrollable && !firstIndexSeen && index == 1)
                 {
                     scrollIndex--;
                 }
             }
             else if (inputState.IsKeyNewPressed(Keys.Down) && index + 1 < children.Count)
             {
                 children[index].currentlyMarked = false;
                 index++;
                 children[index].currentlyMarked = true;
                 childMarked = children[index];
                 if (scrollable && !lastIndexSeen && lastDrawnIndex == index)
                 {
                     scrollIndex++;
                 }
             }
             else if (inputState.IsKeyNewPressed(Keys.Z))
             {
                 if (level > 0)
                 {
                     currentlySelected = false;
                     currentlyMarked   = true;
                     if (children.Count() > 0)
                     {
                         childMarked.currentlyMarked = false;
                         childSelected = null;
                     }
                     if (parent != null)
                     {
                         parent.childSelected = null;
                         parent.childMarked   = parent.children[parent.index];
                     }
                 }
             }
             else if (inputState.IsKeyNewPressed(Keys.X) && children.Count() > 0 && !children[index].locked)
             {
                 currentlySelected = true;
                 currentlyMarked   = false;
                 children[index].currentlySelected = true;
                 childSelected = children[index];
                 if (parent != null)
                 {
                     parent.childMarked = null;
                 }
                 childMarked.currentlyMarked = false;
                 childMarked = null;
                 currentLevel++;
             }
             else if (inputState.IsKeyNewPressed(Keys.H) && childMarked != null)
             {
                 showingDescription = true;
             }
         }
         else if (childSelected != null)
         {
             childSelected.HandleInput(inputState);
         }
     }
     else
     {
         showingDescription = false;
     }
 }
Example #8
0
 private void HandleGameStarting(InputState inputState)
 {
     if (_playersPlaying > 1)
     {
         bool gamepadPressedStart = false;
         for (int i = 0; i < 4; i++)
         {
             inputState.ActivePlayerIndex = (PlayerIndex)i;
             if (_gamePadSlotsUsed[i] && inputState.IsButtonNewPressed(Buttons.Start))
             {
                 gamepadPressedStart = true;
                 break;
             }
         }
         if (gamepadPressedStart || inputState.IsKeyNewPressed(Keys.S))
         {
             screenManager.AddScreen(new PlayScreen(_playersPlaying, _selectedControls, _selectedTeams));
         }
     }
 }
Example #9
0
        private void HandleGameExiting(InputState inputState)
        {
            if (_playersPlaying > 0)
            {
                for (int i = 0; i < _playersPlaying; i++)
                {
                    if (_selectedControls[i] == Tank.ControlScheme.Keyboard)
                    {
                        if (inputState.IsKeyNewPressed(Keys.Q))
                        {
                            _selectedControls[i] = Tank.ControlScheme.Empty;
                            _selectedTeams[i] = -1;
                            _tankSprites[i].Hide();
                            _keyboardSlotsLeft++;
                            _playersPlaying--;

                        }
                    }
                    else if (_selectedControls[i] != Tank.ControlScheme.Empty)
                    {
                        inputState.ActivePlayerIndex = (PlayerIndex)(int)(_selectedControls[i] - 3);
                        if (inputState.IsButtonNewPressed(Buttons.B))
                        {
                            _gamePadSlotsUsed[(int)inputState.ActivePlayerIndex] = false;
                            _selectedControls[i] = Tank.ControlScheme.Empty;
                            _tankSprites[i].Hide();
                            _selectedTeams[i] = -1;
                            _playersPlaying--;
                        }
                    }
                }
            }
        }
Example #10
0
        private void HandleGameEntering(InputState inputState)
        {
            if (_playersPlaying < 4)
            {
                if (inputState.IsKeyNewPressed(Keys.Enter) && _keyboardSlotsLeft > 0)
                {
                    for (int i = 0; i < 4; i++)
                    {
                        if (_selectedControls[i] == Tank.ControlScheme.Empty)
                        {
                            _keyboardSlotsLeft--;
                            _selectedControls[i] = Tank.ControlScheme.Keyboard;
                            ChangeTeam(1, i);
                            _tankSprites[_selectedTeams[i]].Show();
                            _playersPlaying++;
                            break;
                        }
                    }

                }
                for (int i = 0; i < 4; i++)
                {
                    inputState.ActivePlayerIndex = (PlayerIndex)i;
                    if (!_gamePadSlotsUsed[i] && inputState.IsButtonNewPressed(Buttons.A))
                    {
                        for (int j = 0; j < 4; j++)
                        {
                            if (_selectedControls[j] == Tank.ControlScheme.Empty)
                            {
                                _gamePadSlotsUsed[i] = true;
                                _selectedControls[j] = (Tank.ControlScheme)(i + 3);
                                ChangeTeam(1, j);
                                _tankSprites[_selectedTeams[j]].Show();
                                _playersPlaying++;
                                break;
                            }
                        }
                    }
                }
            }
        }
Example #11
0
        private void HandleColorSelection(InputState inputState)
        {
            if (_playersPlaying > 0)
            {
                for (int i = 0; i < _playersPlaying; i++)
                {
                    switch (_selectedControls[i])
                    {
                        case Tank.ControlScheme.Empty: break;
                        case Tank.ControlScheme.Keyboard:
                            if (inputState.IsKeyNewPressed(Keys.Left))
                            {
                                _tankSprites[_selectedTeams[i]].Hide();
                                float rotation = _tankSprites[_selectedTeams[i]].rotation;
                                ChangeTeam(-1, i);
                                _tankSprites[_selectedTeams[i]].Show();
                                _tankSprites[_selectedTeams[i]].rotation = rotation;

                            }
                            else if (inputState.IsKeyNewPressed(Keys.Right))
                            {
                                _tankSprites[_selectedTeams[i]].Hide();
                                float rotation = _tankSprites[_selectedTeams[i]].rotation;
                                ChangeTeam(1, i);
                                _tankSprites[_selectedTeams[i]].Show();
                                _tankSprites[_selectedTeams[i]].rotation = rotation;
                            }
                            break;
                        default:
                            inputState.ActivePlayerIndex = (PlayerIndex)(int)(_selectedControls[i] - 3);
                            if (inputState.IsButtonNewPressed(Buttons.LeftThumbstickLeft))
                            {
                                _tankSprites[_selectedTeams[i]].Hide();
                                ChangeTeam(-1, i);
                                _tankSprites[_selectedTeams[i]].Show();
                            }
                            else if (inputState.IsButtonNewPressed(Buttons.LeftThumbstickRight))
                            {
                                _tankSprites[_selectedTeams[i]].Hide();
                                ChangeTeam(1, i);
                                _tankSprites[_selectedTeams[i]].Show();
                            }
                            break;

                    }
                }
            }
        }