Esempio n. 1
0
    /// <summary>
    /// Adds player to the playe list and sets it up
    /// </summary>
    /// <param name="playerName">Username of the player that should be added</param>
    /// <param name="state">State of the player that is beeing added</param>
    public void AddPlayer(string playerName, PlayerListItem.PlayerState state)
    {
        GameObject go = Instantiate(playerListItemPrefab);

        go.transform.SetParent(transform, false);
        PlayerListItem player = go.GetComponent <PlayerListItem>();

        player.playerName = playerName;
        player.state      = state;
        player.SetUp();
    }
Esempio n. 2
0
 /// <summary>
 /// Update players state given as parameter
 /// </summary>
 /// <param name="playerName">Username of the player that should be updated in the list</param>
 /// <param name="state">New state of the player</param>
 public void UpdatePlayer(string playerName, PlayerListItem.PlayerState state)
 {
     foreach (Transform child in transform)
     {
         PlayerListItem player = child.gameObject.GetComponent <PlayerListItem>();
         if (player.playerName == playerName)
         {
             player.state = state;
             player.SetUp();
             break;
         }
     }
 }