public void AddPlayer(string initialName)
    {
        EditPlayerName newPlayer = Instantiate(playerPrefab, playerParent);

        newPlayer.name.text = initialName;
        players.Add(newPlayer);
        Reset();
    }
    public void RemovePlayer()
    {
        if (players.Count == 0)
        {
            return;
        }

        EditPlayerName playerToRemove = players[players.Count - 1];

        players.Remove(playerToRemove);
        Destroy(playerToRemove.gameObject);
    }
    private void TogglePlayer()
    {
        int nextPlayerIndex = (players.IndexOf(currentPlayer) + 1) % players.Count;

        currentPlayer = players[nextPlayerIndex];

        for (int i = 0; i < players.Count; i++)
        {
            if (i == nextPlayerIndex)
            {
                players[i].name.color = Color.blue;
            }
            else
            {
                players[i].name.color = Color.black;
            }
        }
    }
    private void CheckForWin()
    {
        EditPlayerName potentialWinner = null;

        for (int i = 0; i < players.Count; i++)
        {
            if (players[i].score >= 10000)
            {
                if (potentialWinner == null || players[i].score > potentialWinner.score)
                {
                    potentialWinner = players[i];
                }
            }
        }

        // Nobody's in a potential win state - bail.
        if (potentialWinner == null)
        {
            return;
        }

        currentPlayer.hasLost = (currentPlayer.score < potentialWinner.score);

        int loserCount = 0;

        foreach (EditPlayerName player in players)
        {
            if (player.hasLost)
            {
                loserCount++;
            }
        }
        if (loserCount == players.Count - 1)
        {
            editField.text = potentialWinner.name.text + " Wins!";
            winState       = true;
        }
    }
    private void Reset()
    {
        Clear();

        currentPlayer = players[0];

        for (int i = 0; i < players.Count; i++)
        {
            if (i == 0)
            {
                players[i].name.color = Color.blue;
            }
            else
            {
                players[i].name.color = Color.black;
            }

            players[i].scoreText.text  = "0";
            players[i].score           = 0;
            players[i].fill.fillAmount = 0f;
        }
        winState = false;
    }