Exemplo n.º 1
0
        public void cacheCartoon(Line l, NodeBase n, Cartoon cartoon, Rect rect)
        {
            if (cartoon != null)
            {
                CartoonData cd = PoolData <CartoonData> .Get();

                cd.Reset(n, cartoon, rect, l);
                DataList.Add(cd);
            }
        }
Exemplo n.º 2
0
    public static void SaveAllJsonData()
    {
        string _path = GAME_JSON_PATH;

        if (!_path.StartsWith("/"))
        {
            _path = _path.Insert(0, "/");
        }

        string temp_path = string.Format("{0}{1}", Application.dataPath, _path);

        string[]    fileNames = Directory.GetFiles(temp_path, "*.json");
        CartoonData all_data  = new CartoonData();

        all_data.M_cartoons = new List <CartoonItemJson>();

        CartoonItemJson cur_file;

        byte[] jsonByte;
        foreach (var fileName in fileNames)
        {
            using (FileStream fsReader = new FileStream(fileName, FileMode.Open))
            {
                jsonByte = new byte[fsReader.Length];
                fsReader.Read(jsonByte, 0, (int)fsReader.Length);
                fsReader.Close();

                string jsonStr = System.Text.Encoding.UTF8.GetString(jsonByte);

                cur_file = fastJSON.JSON.ToObject <CartoonItemJson>(jsonStr);

                all_data.M_cartoons.Add(cur_file);
            }
        }


        _path = CONFIG_JSON_PATH;

        if (!_path.StartsWith("/"))
        {
            _path = _path.Insert(0, "/");
        }

        if (!_path.EndsWith("/"))
        {
            _path = _path + "/";
        }

        temp_path = string.Format("{0}{1}{2}{3}", Application.dataPath, _path, "Cartoon", ".json");

        string j_str = fastJSON.JSON.ToJSON(all_data);

        ExportJigsawJson.CreateJson(temp_path, j_str);
    }
Exemplo n.º 3
0
        public void InitCartoonData()
        {
            if (m_dict.Count > 0)
            {
                return;
            }
            EngineCoreEvents.ResourceEvent.GetAssetEvent.SafeInvoke("Cartoon.json", (assetName, assetObject) =>
            {
                CartoonData data = Utf8Json.JsonSerializer.Deserialize <CartoonData>(assetObject.ToString());

                foreach (var cartoon in data.M_cartoons)

                {
                    CartoonDataManager.Instance.AddData(cartoon);
                }
                ;

                EngineCoreEvents.ResourceEvent.ReleaseAssetEvent.SafeInvoke(assetName, assetObject);
            }, LoadPriority.PostLoad);
        }