Exemplo n.º 1
0
    public void OnPlayerChanged(SyncList <Players.PlayerInfo> .Operation op, int index)
    {
        UniTestNetworkManager     nm        = UniTestNetworkManager.singleton.gameObject.GetComponent <UniTestNetworkManager>();
        List <Players.PlayerInfo> nmPlayers = nm.GetPlayers();

        switch (op)
        {
        case SyncList <Players.PlayerInfo> .Operation.OP_ADD:
        {
            GameObject addedGO = ClientScene.FindLocalObject(nmPlayers[index].netId);

            if (addedGO)
            {
                Players.Add(addedGO.GetComponent <Player>());
            }
            break;
        }

        case SyncList <Players.PlayerInfo> .Operation.OP_CLEAR:
        {
            Players.Clear();
            break;
        }

        case SyncList <Players.PlayerInfo> .Operation.OP_INSERT:
        {
            GameObject addedGO = ClientScene.FindLocalObject(nmPlayers[index].netId);

            if (addedGO)
            {
                Players.Insert(index, addedGO.GetComponent <Player>());
            }
            break;
        }

        case SyncList <Players.PlayerInfo> .Operation.OP_REMOVE:
        {
            GameObject addedGO = ClientScene.FindLocalObject(nmPlayers[index].netId);

            if (addedGO)
            {
                Players.Remove(addedGO.GetComponent <Player>());
            }
            break;
        }

        case SyncList <Players.PlayerInfo> .Operation.OP_REMOVEAT:
        {
            GameObject addedGO = ClientScene.FindLocalObject(nmPlayers[index].netId);

            if (addedGO)
            {
                Players.RemoveAt(index);
            }
            break;
        }
        }
    }
Exemplo n.º 2
0
    public void UpdatePlayerList()
    {
        UniTestNetworkManager     nm        = UniTestNetworkManager.singleton.gameObject.GetComponent <UniTestNetworkManager>();
        List <Players.PlayerInfo> nmPlayers = nm.GetPlayers();

        if (Players.Count != nmPlayers.Count)
        {
            ResetPlayerList();
        }
    }
Exemplo n.º 3
0
    public void ResetPlayerList()
    {
        Players.Clear();
        UniTestNetworkManager     nm        = UniTestNetworkManager.singleton.gameObject.GetComponent <UniTestNetworkManager>();
        List <Players.PlayerInfo> nmPlayers = nm.GetPlayers();

        for (int i = 0; i < nmPlayers.Count; i++)
        {
            GameObject playerGO = ClientScene.FindLocalObject(nmPlayers[i].netId);

            if (playerGO)
            {
                Players.Add(playerGO.GetComponent <Player>());
            }
        }
    }