Exemple #1
0
    private void UpdateView(GameInfo gameInfo)
    {
        CleanGarbageCollector();
        string text   = gameInfo.PlayersNow + "/" + gameInfo.PlayersMax + " joined";
        var    obj    = CardsGenerator.DrawObjectWithTextFromPrefab(new Vector2(0, 0), "DefaultTextWhite", text);
        var    script = obj.AddComponent <ClickActionScript>();

        GarbageCollector.Add(obj);
    }
    private void AllGameInfosResponse(ResponseOrError <List <GameInfo> > responseOrError)
    {
        if (responseOrError.IsSuccess)
        {
            CleanGarbageCollector();

            List <GameInfo> info = responseOrError
                                   .Response
                                   .FindAll((obj) =>
                                            obj.CreatorNickName != PlayerNickName &&
                                            obj.Available &&
                                            obj.PlayersNow < obj.PlayersMax);

            if (info.IsEmpty())
            {
                string text = "no games available";
                var    obj  = CardsGenerator.DrawObjectWithTextFromPrefab(new Vector2(0, 0), "DefaultTextWhite", text);
                GarbageCollector.Add(obj);
            }
            else
            {
                for (int i = 0; i < info.Count; i++)
                {
                    GameInfo game   = info[i];
                    float    y      = StartingAxisY - i * SpaceBetweenTexts;
                    string   text   = game.CreatorNickName + "'s game, players " + game.PlayersNow + "/" + game.PlayersMax;
                    var      obj    = CardsGenerator.DrawObjectWithTextFromPrefab(new Vector2(0, y), "DefaultTextWhite", text);
                    var      script = obj.AddComponent <ClickActionScript>();
                    script.ClickMethod    = OnGameItemClick;
                    script.ClickParameter = game;
                    GarbageCollector.Add(obj);
                }
            }
        }

        Invoke("GetAvailableGames", 2);
    }