Exemplo n.º 1
0
    public void Deserializer(Dictionary <string, object> dic)
    {
        foreach (string key in dic.Keys)
        {
            switch (key)
            {
            case "createdTime":
                createTime = BumJsonTool.getStringValue(dic, key);
                break;

            case "userId":
                userId = BumJsonTool.getStringValue(dic, key);
                break;

            case "status":
                loginStatus = BumJsonTool.getStringValue(dic, key);
                break;

            case "userPhone":
                userPhone = BumJsonTool.getStringValue(dic, key);
                BumBase.LogWarning(userPhone);
                break;

            case "uuidModel":
                uuidModel = BumJsonTool.getStringListValue(dic, key);
                break;

            default:
                break;
            }
        }
    }
Exemplo n.º 2
0
    private IEnumerator loadTexture2DFromWWW(string url, Action <object> onloaded, Action <object> progressEvent, bool existAssetCache = false)
    {
        string path = url;

        if (existAssetCache)
        {
            path = BumDefine.bumThumbnailPathFile + BumDefine.getFileByUrl(url) + "/texture";
        }
        WWW www = new WWW(path);

        while (!www.isDone)
        {
            if (progressEvent != null)
            {
                progressEvent(www.progress);
            }
            yield return(null);
        }

        do
        {
            if (!string.IsNullOrEmpty(www.error))
            {
                BumBase.Log(www.error);
                break;
            }

            Texture2D texture = www.texture;
            if (texture != null)
            {
                //texture = bundle.LoadAsset<Texture2D>("texture");
                if (!existAssetCache)
                {
                    createCache(url, texture, BumResourceType.eBumResourceType_texture2D);
                }
                //bundle.Unload(false);
            }
            else
            {
                texture = www.texture;

                pool.addData(path, texture, BumResourceType.eBumResourceType_texture2D);

                if (!existAssetCache)
                {
                    createCache(url, texture, BumResourceType.eBumResourceType_texture2D);
                }
            }

            onloaded(texture);
        } while (false);

        www.Dispose();
        www = null;
    }
Exemplo n.º 3
0
    void doSend(BumProtocolInfo protocolInfo, WWWForm postForm)
    {
        WWW www = null;

        switch (protocolInfo.protocolType)
        {
        case BumProtocolType.eProtocolType_GET: www = new WWW(serverURL + protocolInfo.url); break;

        case BumProtocolType.eProtocolType_POST: www = new WWW(serverURL + protocolInfo.url, postForm); break;

        case BumProtocolType.eProtocolType_POST_WITH_COOKIES:
            BumBase.Assert(BumLogic.clientUser.userConfig.cookieRequestHeader != null);
            www = new WWW(serverURL + protocolInfo.url, postForm.data, BumLogic.clientUser.userConfig.cookieRequestHeader);
            break;
        }

        BumApp.Instance.StartCoroutine(protocolInfo.dispatchProtocol(www));
    }
Exemplo n.º 4
0
    private IEnumerator loadJsonFromWWW(string url, Action <object> onloaded, Action <object> progressEvent, bool existAssetCache = false)
    {
        string path = url;

        if (existAssetCache)
        {
            path = BumDefine.bumDataConfigPathFile + BumDefine.getJsonFileByUrl(url);
        }

        WWW www = new WWW(url);

        while (!www.isDone)
        {
            if (progressEvent != null)
            {
                progressEvent(www.progress);
            }
            //yield return www;
        }

        do
        {
            if (!string.IsNullOrEmpty(www.error))
            {
                BumBase.Log(www.error);
                break;
            }
            string json  = System.Text.Encoding.UTF8.GetString(www.bytes);
            int    index = json.IndexOf("[");
            if (index > 0 && index < 2)
            {
                json = json.Substring(index);
            }
            if (!existAssetCache)
            {
                createCache(url, json, BumResourceType.eBumResourceType_json);
            }
            Debug.Log(json);
            onloaded(json);
        } while (false);
        www.Dispose();
        www = null;
        yield return(null);
    }
Exemplo n.º 5
0
    public void parseErrorCode(string id)
    {
        if (!ErrorCodeMap.ContainsKey(id))
        {
            string message = string.Format("can not parse the error code: {0}", id);
            BumBase.LogError(message);
            return;
        }

        BumErrorInfo info = null;

        ErrorCodeMap.TryGetValue(id, out info);
        if (info == null)
        {
            return;
        }

        info.ErrorHandler(info.ErrorTips);
    }
Exemplo n.º 6
0
    public void Startup()
    {
        System.TimeSpan ts = System.DateTime.Now - BumApp.Instance.clientInitTime;
        BumBase.Log("====================================Init Total Use {0}s===========================================", ts.TotalSeconds);

        //do...
        //if (string.IsNullOrEmpty(BumLogic.clientUser.userLocalRecord.userPhone))
        //{

        //    BumRep.uiManager.openWindow<BumUILoginPage>(0);
        //}
        //else
        //{
        //    BumRep.uiManager.openWindow<BumUIMainPage>();
        //    BumRep.uiManager.openWindow<BumUIBottomTools>();
        //}
        //BumRep.uiManager.openWindow<BumUIMainPage>();
        //BumRep.uiManager.openWindow<BumUIBottomTools>();
        //UIManager.Instance.OnOpen(PageType.MainPage);
    }
Exemplo n.º 7
0
    void Awake()
    {
        BumBase.Log("====================================================================================");
        BumBase.Log("Application.platform = {0}", Application.platform);
        BumBase.Log("Application.dataPath = {0}", Application.dataPath);
        BumBase.Log("Application.streamingAssetsPath = {0}", Application.streamingAssetsPath);
        BumBase.Log("Application.persistentDataPath = {0}", Application.persistentDataPath);
        BumBase.Log("Application.temporaryCachePath = {0}", Application.temporaryCachePath);
        BumBase.Log("Application.unityVersion = {0}", Application.unityVersion);
        BumBase.Log("SystemInfo.deviceModel = {0}", SystemInfo.deviceModel);
        BumBase.Log("====================================================================================");

        Instance = this;

        appLogic = new BumLogic();
        appRep   = new BumRep();

        setDivce();
        DontDestroyOnLoad(this);
    }
Exemplo n.º 8
0
    private IEnumerator loadUserInfoJsonFromWWW(string url, Action <object> onloaded, Action <object> progressEvent, bool existAssetCache = false)
    {
        string path = url;

        if (existAssetCache)
        {
            path = BumDefine.bumUserConfigPathFile + BumDefine.getJsonFileByUrl(url);
        }
        WWW www = new WWW(path);

        while (!www.isDone)
        {
            if (progressEvent != null)
            {
                progressEvent(www.progress);
            }
            yield return(null);
        }

        do
        {
            if (!string.IsNullOrEmpty(www.error))
            {
                BumBase.Log(www.error);
                break;
            }
            string json = System.Text.Encoding.UTF8.GetString(www.bytes);
            if (!existAssetCache)
            {
                createCache(url, json, BumResourceType.eBumResourceType_userInfo);
            }

            onloaded(json);
        } while (false);
        www.Dispose();
        www = null;
    }
Exemplo n.º 9
0
    private IEnumerator loadAssetBundleFormWWW(string url, Action <object> onloaded, Action <object> progressEvent, bool existAssetCache = false, object param = null, Action <GameObject, object> beforeClone = null)
    {
        string path = url;

        if (existAssetCache)
        {
            path = BumDefine.bumAssetBundlePathFile + BumDefine.getFileByUrl(url) + "/product";
        }

        WWW www = new WWW(path);

        while (!www.isDone)
        {
            if (progressEvent != null)
            {
                progressEvent(www.progress);
            }
            yield return(null);
        }

        do
        {
            if (!string.IsNullOrEmpty(www.error))
            {
                BumBase.Log(www.error);
                break;
            }

            AssetBundle bundle = www.assetBundle;
            if (bundle == null)
            {
                break;
            }

            UnityEngine.Object[] objs = bundle.LoadAllAssets();

            for (int i = 0; i < objs.Length; i++)
            {
                if (!objs[i].GetType().Equals(typeof(GameObject)))
                {
                    continue;
                }
                //if (!objs[i].name.Equals("product")) continue;

                GameObject data = objs[i] as GameObject;
                data.name = BumDefine.getIdByUrl(url);

                //pool.addData(path,data, BumResourceType.eBumResourceType_assetBundle);

                //if (!existAssetCache) createCache(url,www.bytes,BumResourceType.eBumResourceType_assetBundle);
                if (beforeClone != null)
                {
                    beforeClone(data, param);
                }
                if (onloaded != null)
                {
                    onloaded(data);
                }
            }

            bundle.Unload(false);
        } while (false);
        www.Dispose();
        www = null;
    }