Ejemplo n.º 1
0
    public void RefreshPlayerList(GameData gameData)
    {
        for (int i = 0, count = nameEntries.Count; i < count; ++i)
        {
            GameObject.Destroy(nameEntries[i]);
        }
        nameEntries.Clear();

        int numPlayers = gameData.Players.Count;

        for (int i = 0; i < numPlayers; ++i)
        {
            GameObject playerEntry =
                GameObject.Instantiate(PlayerNameEntryPrefab, PlayerListContainer);
            PlayerNameItem namePanel = playerEntry.GetComponent <PlayerNameItem>();
            namePanel.SetName(gameData.Players[i].PlayerName);
            nameEntries.Add(playerEntry);
        }

        PlayerCountText.text = string.Format("Players: {0}", numPlayers);
    }
Ejemplo n.º 2
0
    private void RefreshPlayerList(GameData gameState)
    {
        for (int i = 0, count = playerList.Count; i < count; ++i)
        {
            GameObject.Destroy(playerList[i].gameObject);
        }
        playerList.Clear();

        for (int i = 0, count = gameState.Players.Count; i < count; ++i)
        {
            PlayerData player      = gameState.Players[i];
            GameObject playerEntry = GameObject.Instantiate(
                Resources.Load <GameObject>("LobbyNameEntry"),
                PlayerListContainer);
            PlayerNameItem nameItem = playerEntry.GetComponent <PlayerNameItem>();
            nameItem.SetName(player.PlayerName);
            nameItem.SetNumTricks(player);
            nameItem.SetTurnHighlight(gameState.CurrentPlayerTurnIndex == gameState.Players.IndexOf(player));
            nameItem.SetLeaderHighlight(gameState.CurrentLeaderIndex == gameState.Players.IndexOf(player));
            playerList.Add(nameItem);
        }
    }
Ejemplo n.º 3
0
    public void ShowPopup(GameData gameData, Action <GameData, string, bool> onJoinGame, bool joinLobby)
    {
        this.joinLobby = joinLobby;
        for (int i = 0, count = playerNameItems.Count; i < count; ++i)
        {
            GameObject.Destroy(playerNameItems[i]);
        }
        playerNameItems.Clear();

        game = gameData;
        List <PlayerData> playerList = gameData.Players;

        for (int i = 0, count = playerList.Count; i < count; ++i)
        {
            PlayerData player      = playerList[i];
            GameObject playerEntry =
                GameObject.Instantiate(PlayerNameEntryPrefab, PlayerList);
            PlayerNameItem namePanel = playerEntry.GetComponent <PlayerNameItem>();
            namePanel.SetName(gameData.Players[i].PlayerName, OnJoinAsPlayer);
            playerNameItems.Add(playerEntry);
        }
        this.onJoinGame = onJoinGame;
        gameObject.SetActive(true);
    }