Beispiel #1
0
    public void BindFBActual(string _fbtoken, string _fbid, Action bindSucessCallback = null)
    {
        BindBody body = new BindBody(URLConfig.BindUser);

        body.type       = "facebook";
        body.id         = _fbid;
        body.thirdtoken = _fbtoken;
        body.gameUid    = StorageManager.Inst.GetStorage <StorageAccountInfo>().Uid;

        HttpRequestTool.SendMessage(
            body,
            (x) => {
            JSONNode respons = JSONNode.Parse(x);
            int code         = respons["code"];
            if (code == 0)
            {
                fbid = _fbid;
                Debug.Log("Bind Success 1:" + x);
                if (bindSucessCallback != null)
                {
                    bindSucessCallback();
                }
                EventUtil.EventDispatcher.TriggerEvent(EventKey.FB_Bind_Sucess);
                UIManager.Inst.ShowMessage(LanguageTool.Get("bind_fb_success"));
                //弹出绑定成功面板
                //UIManager.Inst.ShowUI(UIModuleEnum.UIFacebookTips, FacebookTipType.Login_Suc);
            }
            else if (code == -10008)
            {
                Debug.Log("Bind Success 2 :" + "该fb之前已经绑定过当前游戏账号了,无需再次操作");
                UIManager.Inst.ShowMessage(LanguageTool.Get("bind_fb_success"));
                fbid = _fbid;
                //弹出绑定失败面板
                //UIManager.Inst.ShowUI(UIModuleEnum.UIFacebookTips, FacebookTipType.Login_Fail);
            }
            else if (code == -10010)
            {
                Debug.Log("Bind Success 3 :" + "找到fb之前绑定过的游戏进度,即将切换到该游戏进度");
                UIManager.Inst.ShowMessage(LanguageTool.Get("fb_bind_account_reloading"));
                // 清除fb数据
                fbid = _fbid;
                // 清除本地缓存数据
                PlayerPrefs.DeleteAll();
                //重启游戏
                // GameController.Inst.Restart();
                SceneLoadManager.Inst.LoadScene(SceneName.StartScene);
            }
        },
            (x) => {
            Debug.LogError("Bind Fail :" + x);
        }, null, true
            );
    }
Beispiel #2
0
 public void LogoutFB()
 {
     UIManager.Inst.ShowMessage(LanguageTool.Get("fb_logout_success"));
     // fb退出登录
     //FBTool.logout();
     // 清除fb数据
     fbid = null;
     // 清除玩家数据
     PlayerPrefs.DeleteAll();
     // 重启游戏
     SceneLoadManager.Inst.LoadScene(SceneName.StartScene);
 }
Beispiel #3
0
 void Refresh()
 {
     if (text == null)
     {
         text = GetComponent <Text>();
     }
     if (text != null && !string.IsNullOrEmpty(text.text) && text.text.StartsWith("@"))
     {
         langKey = text.text.Substring(1);
     }
     if (!string.IsNullOrEmpty(langKey))
     {
         text.text = LanguageTool.Get(langKey);
     }
 }
Beispiel #4
0
        /// <summary>
        /// 下载最新的AssetBundle
        /// </summary>
        /// <param name="assetUrl"></param>
        /// <param name="loadBaseBundle"></param>
        /// <returns></returns>
        public static IEnumerator LoadAssetBundle(string assetUrl, List <string> needLoadBundleNames, ProgressInfo progressInfo, bool quietDownLoad = false)
        {
            //下载
            progressInfo.totalCount = needLoadBundleNames.Count;
            progressInfo.start      = true;
            int i = 0;

            while (i < needLoadBundleNames.Count)
            {
                float fileSize  = Instance._versionInfo.GuessBundleByAssetName(needLoadBundleNames[i]).Size / 1024;
                int   freeSpace = SimpleDiskUtils.DiskUtils.CheckAvailableSpace();
                if (fileSize > freeSpace)
                {
                    UIManager.Instance.ShowUI(UIModuleEnum.UICommonTipWithTitle, "", "Available space is not enough,please retry after release", "ok");
                    while (fileSize > freeSpace)
                    {
                        yield return(new WaitForSeconds(2f));
                    }
                    freeSpace = SimpleDiskUtils.DiskUtils.CheckAvailableSpace();
                }

                progressInfo.curIndex = i;
                string filePath = string.Format("{0}/{1}", assetUrl, needLoadBundleNames[i]);
                yield return(DownloadManager.DownLoadFile(needLoadBundleNames[i], filePath, FilePathTools.persistentDataPath_Platform, progressInfo, null));

                if (progressInfo.curIndexDone)
                {
                    i++;
                }
                else if (!quietDownLoad)
                {
                    bool   closeTip    = false;
                    Action tipCallback = () =>
                    {
                        closeTip = true;
                    };
                    DebugUtil.LogError("AssetBundleManager.LoadAssetBundle fail,filePath:" + filePath);
                    UIManager.Instance.ShowUI(UIModuleEnum.UICommonTipWithTitle, "", LanguageTool.Get("Net_Problem_Tips") + "..", LanguageTool.Get("Button_ok"), tipCallback);
                    while (!closeTip)
                    {
                        yield return(null);
                    }
                }
            }
            progressInfo.sucess = true;
        }
Beispiel #5
0
        private IEnumerator LoadAssetBundleGroupIEnumerator(string assetUrl, List <string> needLoadBundleNames, bool quietDownLoad = false)
        {
            //下载
            loadingStatus      = LoadingStatus.Loading;
            progressInfo.start = true;
            int i = 0;

            while (i < needLoadBundleNames.Count)
            {
                float fileSize  = this.assetBundleGroupInfo.Get("needLoadBundleNames").Size / 1024;
                int   freeSpace = SimpleDiskUtils.DiskUtils.CheckAvailableSpace();
                if (fileSize > freeSpace)
                {
                    UIManager.Instance.ShowUI(UIModuleEnum.UICommonTipWithTitle, "", "Available space is not enough,please retry after release", "ok");
                    while (fileSize > freeSpace)
                    {
                        if (loadingStatus == LoadingStatus.Pause)
                        {
                            yield break;
                        }
                        yield return(new WaitForSeconds(3f));

                        freeSpace = SimpleDiskUtils.DiskUtils.CheckAvailableSpace();
                    }
                }


                progressInfo.curIndex = progressInfo.startIndex + i;
                //yield return DownloadManager.DownLoadFile(needLoadBundleNames[i], string.Format("{0}/{1}", assetUrl, needLoadBundleNames[i]), FilePathTools.persistentDataPath_Platform, progressInfo, null);
                string fileName      = needLoadBundleNames[i];
                string filePath      = string.Format("{0}/{1}", assetUrl, needLoadBundleNames[i]);
                string desFolderName = FilePathTools.persistentDataPath_Platform;
                using (UnityWebRequest www = new UnityWebRequest(filePath))
                {
                    DownloadHandlerBuffer downHandler = new DownloadHandlerBuffer();
                    www.downloadHandler = downHandler;
                    www.SendWebRequest();
                    while (!www.isDone)
                    {
                        if (loadingStatus == LoadingStatus.Pause)
                        {
                            //设置为Pause状态时,退出下载
                            www.Abort();
                            www.Dispose();
                            yield break;
                        }
                        if (progressInfo != null)
                        {
                            progressInfo.curProgress = www.downloadProgress;
                        }
                        yield return(null);
                    }
                    if (string.IsNullOrEmpty(www.error))
                    {
                        byte[] b        = www.downloadHandler.data;
                        string destFile = string.Format("{0}/{1}", desFolderName, fileName);
                        string destDir  = Path.GetDirectoryName(destFile);
                        if (!Directory.Exists(destDir))
                        {
                            Directory.CreateDirectory(destDir);
                        }

                        if (Directory.Exists(destDir))
                        {
                            Log("AssetBundleGroupLoadHelperItem : create fold {0} sucess", destDir);
                        }
                        else
                        {
                            Log("AssetBundleGroupLoadHelperItem : create fold {0} Fail", destDir);
                        }

                        if (File.Exists(destFile))
                        {
                            File.Delete(destFile);
                        }

                        try
                        {
                            using (FileStream fs = new FileStream(destFile, FileMode.Create))
                            {
                                fs.Seek(0, SeekOrigin.Begin);
                                fs.Write(b, 0, b.Length);
                                fs.Close();
                                Log("AssetBundleGroupLoadHelperItem :write sucess: {0},length:{1}", fileName, b.Length);
                            }
                        }
                        catch (Exception e)
                        {
                            Log("AssetBundleGroupLoadHelperItem: save to local exception:{0}", e.ToString());
                        }
                        if (File.Exists(destFile))
                        {
                            if (progressInfo != null)
                            {
                                progressInfo.curIndexDone = true;
                            }
                        }
                        else
                        {
                            if (progressInfo != null)
                            {
                                progressInfo.curIndexDone = false;
                            }
                        }
                    }
                    else
                    {
                        Log("AssetBundleGroupLoadHelperItem,file path:{0} , error:{1}", filePath, www.error);
                        if (progressInfo != null)
                        {
                            progressInfo.curIndexDone = false;
                        }

                        yield return(new WaitForSeconds(3f));
                    }
                }

                if (progressInfo.curIndexDone)
                {
                    i++;
                }
                else if (!quietDownLoad)
                {
                    if (!UIManager.Instance.IsUIVisible(UIModuleEnum.UICommonTipWithTitle))
                    {
                        UIManager.Instance.ShowUI(UIModuleEnum.UICommonTipWithTitle, "", LanguageTool.Get("Net_Problem_Tips"), LanguageTool.Get("Button_ok"));
                    }
                }
            }
            progressInfo.sucess = true;
            EventDispatcher.TriggerEvent <string>(EventKey.AssetBundleGroupLoadSucess, groupName);
        }