protected void XboxCharacterSelection(InputHelper inputHelper)
    {
        //handle xbox input/interact button for each joined player, independant of in which playerborder it fits.
        //iterates for controllers 2-5 (xbox controllers)
        for (int i = 2; i < 6; i++)
        {
            if (ControllerJoined(i))
            {
                //gives the correct number for input controllers (1-4)
                int controllernr = i - 1;

                //if the player is not locked in, handle left and right input to change character
                if (!lockInSprite[playerborder[i]])
                {
                    //right
                    if (inputHelper.MenuDirection(controllernr, true, false) == new Vector2(1, 0))
                    {
                        ChangeSpriteRight(characterSprites[playerborder[i]], characterSelectIndex[playerborder[i]], playerborder[i]);
                    }
                    //left
                    else if (inputHelper.MenuDirection(controllernr, true, false) == new Vector2(-1, 0))
                    {
                        ChangeSpriteLeft(characterSprites[playerborder[i]], characterSelectIndex[playerborder[i]], playerborder[i]);
                    }
                }
                //lock in character selection
                if (inputHelper.ButtonPressed(controllernr, Buttons.Y))
                {
                    LockinPlayer(playerborder[i]);
                }
            }
        }
    }
Пример #2
0
 public void HandleInput(InputHelper inputHelper)
 {
     if (inputHelper.KeyPressed(Keys.Enter) || inputHelper.ButtonPressed(1, Buttons.Back)) //To skip the cutscene, press Enter or Back for player 1 on Xbox
     {
         GameEnvironment.GameStateManager.SwitchTo("playingState");
     }
 }
Пример #3
0
 /// <summary>
 /// Handles the XBOX movement for the player
 /// </summary>
 private void HandleXboxMovement(InputHelper inputHelper)
 {
     if (inputHelper.ControllerConnected(controllerNumber)) //Check if the controller is connected
     {
         if (inputHelper.ButtonPressed(controllerNumber, Buttons.A))
         {
             weapon.IsAttacking = true;
             this.weapon.Attack(GameWorld.Find("monsterLIST") as GameObjectList, GameWorld.Find("TileField") as GameObjectGrid);
             if (weapon.PreviousAttackHit)
             {
                 PlaySFX("attack_hit");
             }
             else
             {
                 PlaySFX("attack_miss");
             }
         }
         if (inputHelper.ButtonPressed(controllerNumber, Buttons.B))
         {
             if (!weapon.AbilityMain.IsOnCooldown)
             {
                 weapon.IsAttacking = true;
                 this.weapon.UseMainAbility(GameWorld.Find("monsterLIST") as GameObjectList, GameWorld.Find("TileField") as GameObjectGrid);
                 PlaySFX("basic_ability");
             }
             else
             {
                 PlaySFX("ability_not_ready");
             }
         }
         //Interact button
         if (inputHelper.IsButtonDown(controllerNumber, Buttons.Y))
         {
             InteractCollisionChecker();
         }
         if (inputHelper.ButtonPressed(controllerNumber, Buttons.X))
         {
             SwitchtoAIChecker();
             return;
         }
         //Movement
         walkingdirection   = inputHelper.WalkingDirection(controllerNumber) * this.movementSpeed;
         walkingdirection.Y = -walkingdirection.Y;
     }
 }
    public override void HandleInput(InputHelper inputHelper)
    {
        base.HandleInput(inputHelper);


        //Join the player that presses the button
        if (playersjoined < 4)
        {
            //Join keyboard players if input is detected
            if (inputHelper.KeyPressed(Keys.S))
            {
                if (keyboardjoined[0] == false)
                {
                    keyboardjoined[0] = true;
                    JoinPlayer(0);
                }
            }

            if (inputHelper.KeyPressed(Keys.Down))
            {
                if (keyboardjoined[1] == false)
                {
                    keyboardjoined[1] = true;
                    JoinPlayer(1);
                }
            }

            //Join xbox players if input is detected
            for (int controller = 1; controller <= 4; controller++)
            {
                if (inputHelper.ButtonPressed(controller, Buttons.A) && xboxjoined[controller - 1] == false)
                {
                    xboxjoined[controller - 1] = true;
                    JoinPlayer(controller + 1); //to yield 2-5 in the dictionary
                }
            }
        }


        //the methods below handle the characterselection left right input and lock in
        XboxCharacterSelection(inputHelper);
        KeyboardCharacterSelection(inputHelper);
    }
    /// <summary>
    /// Handles the input for the conversation box
    /// </summary>
    /// <param name="inputHelper">input helper</param>
    public override void HandleInput(InputHelper inputHelper)
    {
        base.HandleInput(inputHelper);
        // Moves the conversation index forward appropiately
        if (inputHelper.KeyPressed(Keys.Space) || inputHelper.ButtonPressed(1, Buttons.A))
        {
            if (convIndex < textLines.Count - 1)
            {
                if (PreviousLineWasChoice)
                {
                    if (marker.Position.Y == upperChoicePos.Y)
                    {
                        convIndex++;
                        compensation = 2;
                    }
                    else if (marker.Position.Y == upperChoicePos.Y + choiceSeperation && convIndex < textLines.Count - 2)
                    {
                        convIndex   += 2;
                        compensation = 1;
                    }
                    else if (marker.Position.Y == bottomChoiceHeight && convIndex < textLines.Count - 3)
                    {
                        convIndex += 3;
                    }
                }
                else if (!PreviousLineWasChoice)
                {
                    convIndex++;
                }
                displayedText.Clear();
                PreviousLineWasChoice = false;



                if (textLines[convIndex].StartsWith("#")) //a # signifies that there is a choice in the text file
                {
                    marker.Visible        = true;
                    PreviousLineWasChoice = true;
                    for (int i = 0; i < 3; i++)
                    {
                        TextGameObject currentText = new TextGameObject("Assets/Fonts/ConversationFont", 0, "currentlydisplayedtext")
                        {
                            Position = new Vector2(100, i * choiceSeperation + 80),
                            Text     = textLines[convIndex]
                        };
                        displayedText.Add(currentText);

                        if (convIndex < textLines.Count - 1 && i < 2)
                        {
                            convIndex += 1;
                        }
                    }
                }
                else
                {
                    marker.Visible = false;
                    TextGameObject currentText = new TextGameObject("Assets/Fonts/ConversationFont", 0, "currentlydisplayedtext")
                    {
                        Text     = textLines[convIndex],
                        Position = new Vector2(100, 114)
                    };
                    displayedText.Add(currentText);
                }
                if (compensation > 0 && convIndex < textLines.Count - compensation)
                {
                    convIndex   += compensation;
                    compensation = 0;
                }
            }
            else
            {
                convIndex = 0;
                // stops the conversation box from displaying itself and switches back to the playing state
                (GameEnvironment.GameStateManager.CurrentGameState as ConversationState).GoToNextConversation();
            }
        }

        // Moves the marker up or down depending on the key that was pressed
        if (inputHelper.KeyPressed(Keys.Down) || inputHelper.ButtonPressed(1, Buttons.DPadDown))
        {
            if (marker.Position.Y < bottomChoiceHeight)
            {
                marker.Position += new Vector2(0, choiceSeperation);
            }
        }
        if (inputHelper.KeyPressed(Keys.Up) || inputHelper.ButtonPressed(1, Buttons.DPadUp))
        {
            if (marker.Position.Y > upperChoicePos.Y)
            {
                marker.Position -= new Vector2(0, choiceSeperation);
            }
        }
    }