Example #1
0
    public void AddPlayerJoinIndicator(JoinPlayerData player)
    {
        PlayerJoinIndicator indic = Instantiate(joinTag, joinBar);

        indic.transform.ResetTransform();
        indic.title.text    = "Player " + (player.playerNumber + 1);
        indic.outline.color = player.playerColor;
    }
Example #2
0
    void GatherJoiningPlayerInput(out bool updateIndicators)
    {
        updateIndicators = false;

        for (int i = 0; i < 4; i++)
        {
            //Join or Leave
            if (cInput.GetKeyDown("Menu" + i))
            {
                int playerIndex = joiningPlayers.FindIndex(givenPlayer => givenPlayer.playerNumber == i);
                if (playerIndex < 0)
                {
                    joiningPlayers.Add(new JoinPlayerData(i, playerColors[i], i));
                    joiningPlayers.Sort((p1, p2) => p1.playerNumber - p2.playerNumber);
                }
                else
                {
                    joiningPlayers.RemoveAt(joiningPlayers.FindIndex(player => player.playerNumber == i));
                }
                updateIndicators = true;
            }

            //Select Color
            float horizontal = 0;
            if (cInput.GetKeyDown("Left" + i))
            {
                horizontal = -1;
            }
            if (cInput.GetKeyDown("Right" + i))
            {
                horizontal = 1;
            }

            if (horizontal != 0)
            {
                int index = joiningPlayers.FindIndex(givenPlayer => givenPlayer.playerNumber == i);
                if (index >= 0)
                {
                    JoinPlayerData player = joiningPlayers[index];
                    int            cIndex = player.playerColorIndex;
                    cIndex                  = horizontal < 0 ? (cIndex + playerColors.Length - 1) % playerColors.Length : (cIndex + 1) % playerColors.Length;
                    player.playerColor      = playerColors[cIndex];
                    player.playerColorIndex = cIndex;
                    updateIndicators        = true;
                    //Debug.Log("Update " + i);
                }
            }
        }
    }