Exemple #1
0
    protected override void OnHandleInput(JoystickState[] joystickStates)
    {
        //Debug.Log("current Joystick:" + currentJoystick);
        //Debug.Log("num of joystickstates:" + joystickStates.Length);
        JoystickState _activeJoystick = joystickStates[currentJoystick];

        //Debug.Log("charSel: joyName= " + activeJoysticks[currentJoystick]);

        //
        if (activeJoysticks[currentJoystick] == false || _activeJoystick.buttonA_down)
        {
            //Debug.Log("Character selected: " + currentCharacter);
            gameManager.SetPlayerInfo(currentJoystick, new PlayerInfo(characters[currentCharacter], activeJoysticks[currentJoystick], currentJoystick, currentCharacter, currentCharacter));

            selectedCharacters[currentCharacter] = true;
            selectionController.HighlightCharacter(false, currentCharacter);
            selectionController.GoGrey(currentCharacter);
            currentJoystick += 1;
            selectionController.SetCurrentPlayerText("Player " + (currentJoystick + 1));

            if (currentJoystick >= 3)
            {
                gameManager.SwitchState(new GameState25d(gameManager));
                return;
            }

            for (int i = 0; i < 3; i++)
            {
                if (!selectedCharacters[i])
                {
                    currentCharacter = i;
                    selectionController.HighlightCharacter(true, currentCharacter);
                    break;
                }
            }
        }

        //######################################
        bool selectionChanged = false;

        if (canChangeSelection)
        {
            if (_activeJoystick.yAxisUp)
            {
                if (currentCharacter == 0)
                {
                    if (!selectedCharacters[1])
                    {
                        selectionController.HighlightCharacter(false, 0);
                        selectionController.HighlightCharacter(true, 1);
                        currentCharacter = 1;
                        selectionChanged = true;
                    }
                    else if (!selectedCharacters[2])
                    {
                        selectionController.HighlightCharacter(false, 0);
                        selectionController.HighlightCharacter(true, 2);
                        currentCharacter = 2;
                        selectionChanged = true;
                    }
                }
                else if (currentCharacter == 1)
                {
                    if (!selectedCharacters[2])
                    {
                        selectionController.HighlightCharacter(false, 1);
                        selectionController.HighlightCharacter(true, 2);
                        currentCharacter = 2;
                        selectionChanged = true;
                    }
                }
            }
            else if (_activeJoystick.yAxisDown)
            {
                if (currentCharacter == 2)
                {
                    if (!selectedCharacters[1])
                    {
                        selectionController.HighlightCharacter(false, 2);
                        selectionController.HighlightCharacter(true, 1);
                        currentCharacter = 1;
                        selectionChanged = true;
                    }
                    else if (!selectedCharacters[0])
                    {
                        selectionController.HighlightCharacter(false, 2);
                        selectionController.HighlightCharacter(true, 0);
                        currentCharacter = 0;
                        selectionChanged = true;
                    }
                }
                else if (currentCharacter == 1)
                {
                    if (!selectedCharacters[0])
                    {
                        selectionController.HighlightCharacter(false, 1);
                        selectionController.HighlightCharacter(true, 0);
                        currentCharacter = 0;
                        selectionChanged = true;
                    }
                }
            }
        }

        if (selectionChanged)
        {
            canChangeSelection = false;
            selectionTimer     = 0f;
        }
    }