Esempio n. 1
0
    private void OnPriceLoaded(object obj)
    {
        SimpleCacheLoader loader = obj as SimpleCacheLoader;

        if (loader.state == SimpleLoadedState.Failed)
        {
            //Debug.LogError(loader.uri);
            return;
        }
        string    json      = loader.loadedData.ToString();
        object    jsonObj   = MyJsonTool.FromJson(json);
        PriceData priceData = new PriceData();

        priceData.Deserialize(jsonObj as Dictionary <string, object>);
        mainpageData.AddPriceData(priceData);
    }
    // Use this for initialization


    void Start()
    {
        //  string str=  MyJsonTool.ToJson(SchemeManifest.Instance);
        //  using (StreamWriter stream = new StreamWriter(Application.streamingAssetsPath+"/ObjectToJson.txt",true,System.Text.Encoding.UTF8) )
        //  {
        //      stream.WriteLine(str);
        //  }
        //Debug.Log(str);
        string Path = Application.streamingAssetsPath + "/ObjectToJson.txt";
        string str  = "";

        using (StreamReader stream = new StreamReader(File.Open(Path, FileMode.Open), System.Text.Encoding.UTF8))
        {
            str = stream.ReadToEnd();
        }

        object obj = MyJsonTool.FromJson(str);
        //SchemeManifest.Instance.Deserialize(obj as Dictionary<string ,object>);

        //Debug.Log("schemeName : = " + SchemeManifest.Instance.name);
        //Debug.Log("guid : = " + SchemeManifest.Instance.guid );
    }
    private void onloaded(object obj)
    {
        SimpleOutterLoader loader = obj as SimpleOutterLoader;

        if (loader.state == SimpleLoadedState.Failed)
        {
            //Debug.LogError(loader.uri);
            return;
        }
        string json     = loader.loadedData.ToString();
        object jsonData = MyJsonTool.FromJson(json);

        MsgFromIOS.InfoFromIOS info = loader.bringData as MsgFromIOS.InfoFromIOS;

        OriginalProjectData         data = new OriginalProjectData();
        Dictionary <string, object> dic  = jsonData as Dictionary <string, object>;

        ///在线端数据
        if (dic.ContainsKey("products"))
        {
            //data.DeSerialize(dic);
        }
        ///移动端新数据
        else if (dic.ContainsKey("version"))
        {
            data.DeSerialize(dic);
        }
        ///移动端旧数据 或 错误数据
        else
        {
            data.DeSerialize(dic);
        }

        switch (info.enterType)
        {
        case "4":
        case "5":
            data.isTemplate = true;
            data.isNew      = true;
            data.templateId = info.projectId;
            data.id         = "";
            data.tempId     = jsonCacheManager.GetNewSchemeTempId();
            break;

        default:
            data.id     = info.projectId;
            data.tempId = info.tempId;
            data.isNew  = false;
            break;
        }
        //data.templateId = info.templateId;
        data.tempEffectMetas.Clear();
        List <object> matelist = info.msg as List <object>;

        for (int i = 0; i < matelist.Count; i++)
        {
            data.tempEffectMetas.Add(matelist[i].ToString());
        }

        //放到队列加载后
        //undoHelper.SetCurrentData(data);

        switch (info.enterType)
        {
        case "3":
        case "5":
            mainpageMachine.setState(ToThreeDState.Name);
            break;

        default:
            mainpageMachine.setState(ToTwoDState.Name);
            break;
        }

        float minX = 0;
        float maxX = 0;
        float minY = 0;
        float maxY = 0;

        for (int i = 0; i < data.data.pointList.Count; i++)
        {
            Vector2 v2 = data.data.pointList[i].pos;
            if (v2.x < minX)
            {
                minX = v2.x;
            }
            if (v2.x > maxX)
            {
                maxX = v2.x;
            }
            if (v2.y < minY)
            {
                minY = v2.y;
            }
            if (v2.y > maxY)
            {
                maxY = v2.y;
            }
        }
        Vector2 pos = Vector2.zero;

        pos.x = (minX + maxX) / 2;
        pos.y = (minY + maxY) / 2;
        CameraControler.Instance.ResetAllCamera(pos);

        QueueSimpleLoader queueloader = new QueueSimpleLoader(data);

        for (int i = 0; i < data.data.productList.Count; i++)
        {
            Product product = data.data.productList[i];
            if (product.assetBundlePath.IndexOf("http://") == -1)
            {
                continue;                                                  //if (string.IsNullOrEmpty(product.model3d)) continue;
            }
            SimpleOutterLoader outLoader = LoaderPool.WaitOutterLoad(product.assetBundlePath, SimpleLoadDataType.prefabAssetBundle, null, product, onloadedBforClone);
            queueloader.AddQueueItem(outLoader);
        }
        if (queueloader.getCount != 0)
        {
            queueloader.addEventListener(LoadEvent.QueueProgress, OnAllProductProgress);
            queueloader.addEventListener(LoadEvent.QueueComplete, OnLoadedAllProduct);
        }
        else
        {
            undoHelper.SetCurrentData(data);
        }
    }