示例#1
0
    // Update is called once per frame
    private void Update()
    {
#if UNITY_EDITOR || INTERNAL_BUILD
        if (Input.GetKeyDown(KeyCode.Alpha1) || Input.GetKeyDown(KeyCode.Alpha2) || Input.GetKeyDown(KeyCode.Alpha3) || Input.GetKeyDown(KeyCode.Alpha4))
        {
            int value = Input.GetKeyDown(KeyCode.Alpha1) ? 0 : Input.GetKeyDown(KeyCode.Alpha2) ? 1 : Input.GetKeyDown(KeyCode.Alpha3) ? 2 : Input.GetKeyDown(KeyCode.Alpha4) ? 3 : -1;
            if (value >= 0)
            {
                if (player1SelectedCharacter < 0)
                {
                    player1CurrentlyHighlighted = SetSelectionItem("1", value);
                    SetSelectedItem("1", player1CurrentlyHighlighted);
                }
                else if (player2SelectedCharacter < 0)
                {
                    player2CurrentlyHighlighted = SetSelectionItem("2", value);
                    SetSelectedItem("2", player2CurrentlyHighlighted);
                }
            }
        }
#endif
        if (frameSkip <= 0)
        {
            if (characterSelectMode)
            {
                if (player1SelectedCharacter < 0)
                {
                    if (player1.GetButtonDown(RewiredConsts.Action.Select))
                    {
                        SetSelectedItem("1", player1CurrentlyHighlighted);
                    }
                    if (player1.GetButtonRepeating(RewiredConsts.Action.MenuDown))
                    {
                        player1CurrentlyHighlighted = SetSelectionItem("1", player1CurrentlyHighlighted + 1);
                    }
                    if (player1.GetButtonRepeating(RewiredConsts.Action.MenuUp))
                    {
                        player1CurrentlyHighlighted = SetSelectionItem("1", player1CurrentlyHighlighted - 1);
                    }
                }
                if (player1.GetButtonDown(RewiredConsts.Action.Back))
                {
                    SetSelectedItem("1", -1);
                    player1SelectedCharacter = -1;
                }
                if (player2SelectedCharacter < 0)
                {
                    if (player2.GetButtonDown(RewiredConsts.Action.Select))
                    {
                        SetSelectedItem("2", player2CurrentlyHighlighted);
                    }
                    if (player2.GetButtonRepeating(RewiredConsts.Action.MenuDown))
                    {
                        player2CurrentlyHighlighted = SetSelectionItem("2", player2CurrentlyHighlighted + 1);
                    }
                    if (player2.GetButtonRepeating(RewiredConsts.Action.MenuUp))
                    {
                        player2CurrentlyHighlighted = SetSelectionItem("2", player2CurrentlyHighlighted - 1);
                    }
                }
                if (player2.GetButtonDown(RewiredConsts.Action.Back))
                {
                    SetSelectedItem("2", -1);
                    player2SelectedCharacter = -1;
                }
                if (player1SelectedCharacter >= 0 && player2SelectedCharacter >= 0)
                {
                    SetupStageSelectMode();
                }
            }
            else if (stageSelectMode)
            {
                if ((player1.GetButtonRepeating(RewiredConsts.Action.MenuRight) || player2.GetButtonRepeating(RewiredConsts.Action.MenuRight)) && highlightedStage < stages.Length - 1)
                {
                    AudioManager.instance.PlaySound(changeSfx);
                    stages[highlightedStage++].SetActive(false);
                    stages[highlightedStage].SetActive(true);
                    leftArrow.SetActive(highlightedStage > 0);
                    rightArrow.SetActive(highlightedStage < stages.Length - 1);
                    arenaNameText.text = arenaNames[highlightedStage];
                }
                if ((player1.GetButtonRepeating(RewiredConsts.Action.MenuLeft) || player2.GetButtonRepeating(RewiredConsts.Action.MenuLeft)) && highlightedStage > 0)
                {
                    AudioManager.instance.PlaySound(changeSfx);
                    stages[highlightedStage--].SetActive(false);
                    stages[highlightedStage].SetActive(true);
                    leftArrow.SetActive(highlightedStage > 0);
                    rightArrow.SetActive(highlightedStage < stages.Length - 1);
                    arenaNameText.text = arenaNames[highlightedStage];
                    frameSkip          = 5;
                }
                if (player1.GetButtonDown(RewiredConsts.Action.Select) || player2.GetButtonDown(RewiredConsts.Action.Select))
                {
                    AudioManager.instance.PlaySound(selectionSfx);
                    characterSelectMode = false;
                    stageSelectMode     = false;
                    gameSceneName       = stages[highlightedStage].name;
                    eventSystem.enabled = false;
                    StartCoroutine(confirmSelection.Animate(analogGlitch));
                    confirmSelection.AnimationFinished = ShowGamepadCard;
                }
                if (player1.GetButtonDown(RewiredConsts.Action.Back) || player2.GetButtonDown(RewiredConsts.Action.Back))
                {
                    AudioManager.instance.PlaySound(cancelSfx);
                    SetupCharacterSelectMode();
                }
            }
            else
            {
                if (eventSystem.currentSelectedGameObject != currentSelectedGameObject && eventSystem.currentSelectedGameObject != null)
                {
                    currentSelectedGameObject = eventSystem.currentSelectedGameObject;
                    StartCoroutine(changeSelection.Animate(analogGlitch));
                }
                if (!eventSystem.currentSelectedGameObject && (ReadAnyControllerInput("1") || ReadAnyControllerInput("2")))
                {
                    eventSystem.SetSelectedGameObject(eventSystem.firstSelectedGameObject);
                }
                if (ReadAnyControllerInput("1"))
                {
                    inputModule.verticalAxis   = "Vertical1";
                    inputModule.horizontalAxis = "Horizontal1";
                    inputModule.submitButton   = "Swing1";
                }
                else if (ReadAnyControllerInput("2"))
                {
                    inputModule.verticalAxis   = "Vertical2";
                    inputModule.horizontalAxis = "Horizontal2";
                    inputModule.submitButton   = "Swing2";
                }
            }
        }
        else
        {
            frameSkip--;
        }
    }