Exemple #1
0
    public IEnumerator DownloadLevel(string url, JSONObject jsonObject)
    {
        var www = new WWW(url);

        yield return(www);

        if (www.isDone && www.text != "")
        {
            jsonObject = new JSONObject(www.text);
            try
            {
                LoadedLevels.Clear();
                var levelArray = jsonObject.GetField("levelArray").list;
                foreach (var level in levelArray)
                {
                    LoadedLevels.Add(SerializedLevel.FromJson(level));
                }
                Debug.Log("Number of loaded levels: " + LoadedLevels.Count);
                PopulateToGrid();
                InvokeLevelsLoaded(true);
            }
            catch
            {
                LoadDefaultLevels();
            }
        }

        //NGUIDebug.Log("Levels Loaded:" + jsonObject);
    }
    public void LoadDefaultLevels()
    {
        var jsonObject = new JSONObject(LevelFile.text);
        var levelArray = jsonObject.GetField("levelArray").list;

        foreach (var level in levelArray)
        {
            LoadedLevels.Add(SerializedLevel.FromJson(level));
        }

        FireLevelsAreReady();
    }
Exemple #3
0
    public void LoadDefaultLevels()
    {
        var jsonObject = new JSONObject(Levels.text);
        var levelArray = jsonObject.GetField("levelArray").list;

        foreach (var level in levelArray)
        {
            LoadedLevels.Add(SerializedLevel.FromJson(level));
        }
        PopulateToGrid();
        InvokeLevelsLoaded(true);
    }