Пример #1
0
    private void renderLevels(string response)
    {
        List <JavaLevel> jlevels = JsonArraySpliter.splitJsonArray <JavaLevel>(response);

        foreach (JavaLevel jlevel in jlevels)
        {
            GameObject levelButton = (GameObject)Instantiate(ElementReferences.instance.getGameObject("button prefab"), ElementReferences.instance.getGameObject("community levels menu").transform.GetChild(0).GetChild(1));
            levelButton.GetComponentInChildren <Text>().text =
                jlevel.name + " by " + jlevel.creator.name + "\nplayes: " +
                jlevel.playes + " solves: " + jlevel.solves + " likes: " + jlevel.likes;

            levelButton.GetComponent <Button>().onClick.AddListener(delegate {
                Level level = new Level(jlevel);
                PositionManager.instance.playCommunityLevel(level);
                Menu.instance.closeCommunityLevelsMenu();
                GameObject creatorButton = ElementReferences.instance.getGameObject("creator");
                creatorButton.SetActive(true);
                creatorButton.GetComponentInChildren <Text>().text = "Click here for more from " + level.creatorName;

                /*if (HttpClient.instance.isSignedIn && jlevel.creator.id == user.id) {
                 *      GameObject delete = (GameObject)Instantiate(deleteButton,canvas);
                 *      delete.GetComponent<Button>().onClick.AddListener(delegate {
                 *              Menu.instance.openAreYouSureRemove();
                 *      });
                 * }*/
            });
            if (HttpClient.instance.isSignedIn && jlevel.creator.id == user.id)
            {
                levelButton.GetComponentInChildren <Text> ().color = creatorColor;
            }
        }
    }
Пример #2
0
 public void getFollowedCreatores()
 {
     if (!HttpClient.instance.isSignedIn)
     {
         return;
     }
     HttpClient.instance.request(userControllerUrl + "/getFollowingList", delegate(string response) {
         print(response);
         List <User> creators = JsonArraySpliter.splitJsonArray <User> (response);
         if (creators == null)
         {
             print("no followed creators");
             return;
         }
         Menu.instance.clearCommunityLevelsMenu();
         foreach (User creator in creators)
         {
             Menu.instance.showCreatorButton(creator.id, creator.name);
         }
     });
 }