Exemplo n.º 1
0
    void SortPlayers()
    {
        List <CaptainsMessPlayer> players = mess.Players();
        int i    = 0;
        int size = players.Count;

        List <CaptainsMessPlayer> SortedList = players.OrderBy(o => o.GetComponent <NetworkedPlayerScript>().nameText).ToList();

        foreach (CaptainsMessPlayer player in SortedList)
        {
            NetworkedPlayerScript nps = player.GetComponent <NetworkedPlayerScript>();
            if (!nps.isLocalPlayer)
            {
                RemotePlayerScript rps = player.GetComponent <RemotePlayerScript>();

                Vector3 goal = rps.SetPosition(++i, size);

                if (nps.playerButton.activeSelf == false)
                {
                    nps.playerButton.SetActive(true);
                    nps.playerButton.transform.localPosition = new Vector3(i * 160, -340, 0);
                }

                nps.playerButton.transform.DOLocalMove(goal, movementSpeed);
                nps.playerButton.transform.DOScale(Vector3.one, movementSpeed);
            }
            nps.SetColor();
            nps.SetNameText();
        }

        if (size >= 4)
        {
            GUIManagerScript.SetButton(true);
        }
        else
        {
            GUIManagerScript.SetButton(false);
        }

        playerParent.GetComponent <RectTransform>().sizeDelta = new Vector2(160 * (size + 1), 340);
    }