Ejemplo n.º 1
0
 public LobbyManager()
 {
     buttons    = null;
     _tableList = new BGA.TableListData();
 }
Ejemplo n.º 2
0
        private void Reload()
        {
            string selectedId = GetSelectedGameId();

            Logger.Instance.Log("DETAIL", "previously selected id: " + selectedId);
            OnGameSelected(-1);

            for (int i = 0; i < _buttonList.Count; ++i)
            {
                GameObject.Destroy(_buttonList[i]);
            }
            _buttonList.Clear();
            _change     = false;
            _nextChange = DateTime.Now + _refreshTimeSpan;

            BGA.TableListData tables = Http.Instance.Lobby.Tables;
            _keys = tables.GetSortedKeys();

            GenerateDefaultLines(tables.Count);

            for (int i = 0; i < tables.Count; ++i)
            {
                string        id   = _keys[i];
                BGA.TableData data = tables[id];

                string players = "";
                if (data.player1 != null)
                {
                    players += data.player1.fullname + "(" + data.player1.rank + ")";
                }
                if (data.player2 != null)
                {
                    players += " - " + data.player2.fullname + "(" + data.player2.rank + ")";
                }

                string status = "";
                if (data.isOpen && data.playerCount == 1)
                {
                    if (data.HasPlayer(Http.Instance.BgaUserId))
                    {
                        status = "En attente";
                    }
                    else
                    {
                        status = "Rejoindre";
                    }
                }
                else if (data.playerCount == 2)
                {
                    if (data.HasPlayer(Http.Instance.BgaUserId))
                    {
                        status = "Reprendre";
                    }
                    else
                    {
                        status = "Observer";
                    }
                }
                else
                {
                    status = "Invalide";
                }

                GameObject line = _buttonList[i];
                line.transform.FindChild("Joueurs").gameObject.GetComponent <Text>().text = players;
                line.transform.FindChild("Etat").gameObject.GetComponent <Text>().text    = status;

                Logger.Instance.Log("DETAIL", "compare ids " + id + " and " + selectedId);
                if (id == selectedId)
                {
                    Logger.Instance.Log("DETAIL", "newly selected id: " + selectedId);
                    OnGameSelected(i);
                }
            }
        }