Ejemplo n.º 1
0
    void AddPlayer(PlayerInput.CharacterActions newcharacterActions)
    {
        GameObject newPlayer = GameObject.Instantiate(playerPrefab, spawnPositions[numberOfPlayers].position, Quaternion.Euler(0, 0, 0));

        playerList.Add(newPlayer.GetComponent <PlayerInput>());
        newPlayer.GetComponent <PlayerInput>().SetControls(newcharacterActions);

        SetPlayerText(numberOfPlayers, new int[] { 4, 5, 6 });

        ++numberOfPlayers;
    }
Ejemplo n.º 2
0
    IEnumerator SetupControls()
    {
        List <BindingSource> usedSources = new List <BindingSource>();

        for (int i = 0; i < 4; ++i)
        {
            string displayText = "";

            PlayerInput.CharacterActions newCharacterActions = new PlayerInput.CharacterActions();

            newCharacterActions.ListenOptions.IncludeMouseScrollWheel          = false;
            newCharacterActions.ListenOptions.AllowDuplicateBindingsPerSet     = false;
            newCharacterActions.ListenOptions.IncludeMouseButtons              = false;
            newCharacterActions.ListenOptions.IncludeUnknownControllers        = true;
            newCharacterActions.ListenOptions.IncludeModifiersAsFirstClassKeys = true;
            newCharacterActions.ListenOptions.OnBindingFound = ((PlayerAction x, BindingSource newSource) => !usedSources.Contains(newSource));


            newCharacterActions.Left.ListenForBinding();
            displayText = "Player " + (i + 1).ToString() + " press Left";
            print(displayText);
            SetPlayerText(i, new int[] { 1, 2, 7 });

            while (newCharacterActions.Left.Bindings.Count <= 0)
            {
                yield return(null);
            }

            usedSources.Add(newCharacterActions.Left.Bindings[0]);

            newCharacterActions.Right.ListenForBinding();
            displayText = "Player " + (i + 1).ToString() + " press Right";
            print(displayText);

            SetPlayerText(i, new int[] { 3, 4, 8 });
            while (newCharacterActions.Right.Bindings.Count <= 0)
            {
                yield return(null);
            }

            usedSources.Add(newCharacterActions.Right.Bindings[0]);

            AddPlayer(newCharacterActions);
        }
    }