public void SetData() { CacheVo vo = CacheManager.CheckPhoneCache(); for (int i = 0; i < vo.sizeList.Count; i++) { //string NpcName = GlobalData.NpcModel.GetNpcById(i + 1).NpcName; PlayerPB playerPB = (PlayerPB)(i + 1); string NpcName = Util.GetPlayerName(playerPB); long size = vo.sizeList[i] / (1024 * 1024); int isize = int.Parse(size.ToString()); toggles[i].transform.Find("Label").GetText().text = I18NManager.Get("Phone_DownloadContext", NpcName, isize); } for (int i = 0; i < 4; i++) { int NpcId = i + 1; if (vo.ids.Contains(NpcId)) { SetToggle(NpcId, false); } else { SetToggle(NpcId, true); } } }
void CheckIsShowDownload() { CacheVo vo = CacheManager.CheckPhoneCache(); if (vo.needDownload) { rightDownload.Show(); } else { rightDownload.Hide(); } }
public static void ClickItem(int NpcId, Action finish = null, Action cancel = null) { int needtoTips = 1; int cunId = 1008699 + NpcId; if (PlayerPrefs.HasKey("RecordLoveStory" + cunId)) { needtoTips = PlayerPrefs.GetInt("RecordLoveStory" + cunId); } Debug.LogError("cunId " + cunId); CacheVo vo = CacheManager.CheckPhoneCache(); if (vo.needDownload == false || !vo.ids.Contains(NpcId) || needtoTips != 1) { finish?.Invoke(); return; } PlayerPB playerPB = (PlayerPB)(NpcId); string NpcName = Util.GetPlayerName(playerPB); long size = 10; if (NpcId < vo.sizeList.Count) { size = vo.sizeList[NpcId - 1] / (1024 * 1024); } int isize = int.Parse(size.ToString()); if (Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork) { CacheManager.DownloadPhoneCache(NpcId, (str) => { finish?.Invoke(); }); } else { //弹出确认框 string content = I18NManager.Get("Phone_IsDownloadContext", NpcName, isize); CacheManager.ConfirmPhoneNeedToDownload(content , I18NManager.Get("Download_JumpDownload"), cunId, NpcId, str => { finish?.Invoke(); }, () => { cancel?.Invoke(); }); } }
/// <summary> /// 返回未下载的索引数值 /// </summary> /// <returns>未下载的索引数值</returns> public static CacheVo CheckMainStoryCache(int chapter) { Stopwatch sw = Stopwatch.StartNew(); CacheVo vo = new CacheVo(); vo.ids = new List <int>(); ResIndex resIndex = GetIndexFile(ResPath.MainStoryIndex); if (resIndex == null) { return(vo); } if (resIndex.packageDict.ContainsKey(chapter.ToString()) == false) { FlowText.ShowMessage(I18NManager.Get("Download_IndexNoExist") + chapter); return(vo); } ResPack resPack = resIndex.packageDict[chapter.ToString()]; _releasePath = resPack.releasePath; foreach (var resItem in resPack.items) { FileInfo fileInfo = new FileInfo(AssetLoader.ExternalHotfixPath + "/" + _releasePath + "/" + resItem.Path); if (fileInfo.Exists == false || fileInfo.Length != resItem.Size) { vo.needDownload = true; break; } } if (vo.needDownload) { vo.ids.Add(Convert.ToInt32(chapter)); } vo.sizeList = new List <long>() { resPack.packageSize }; Debug.LogError("CheckMainStoryCache 时间:" + sw.ElapsedMilliseconds); return(vo); }
public static long GetExtendSize(CacheVo vo) { long allsize = 0; foreach (var v in vo.sizeList) { allsize += v; } if (allsize > 0) { LoadingProgress.Instance.AddPackCount(1); } return(allsize); }
private void ShowWindow() { if (GuideManager.IsPass4_12() && GuideManager.CurFunctionGuide(GuideTypePB.LoveGuideCoaxSleep) == FunctionGuideStage.Function_CoaxSleep_OneStage) { return; } if (GuideManager.CurStage() == GuideStage.Over) { _cacheVo = CacheManager.CheckExtendCache(); if (!_cacheVo.needDownload) { ShowPopupWindow(); } } }
/// <summary> /// 返回未下载的索引数值 /// </summary> /// <returns>未下载的索引数值</returns> public static CacheVo CheckPhoneCache() { Stopwatch sw = Stopwatch.StartNew(); CacheVo vo = new CacheVo(); vo.sizeList = new List <long>(); vo.ids = new List <int>(); _phoneCacheList = new List <int>(); ResIndex resIndex = GetIndexFile(ResPath.PhoneAudioPackageIndex); if (resIndex == null) { return(vo); } foreach (var resPack in resIndex.packageDict) { string role = resPack.Key; _releasePath = resPack.Value.releasePath; bool isNeedDownload = false; foreach (var resItem in resPack.Value.items) { FileInfo fileInfo = new FileInfo(AssetLoader.ExternalHotfixPath + "/" + _releasePath + "/" + resItem.Path); if (fileInfo.Exists == false || fileInfo.Length != resItem.Size) { vo.needDownload = true; isNeedDownload = true; break; } } vo.sizeList.Add(resPack.Value.packageSize); if (isNeedDownload) { _phoneCacheList.Add(Convert.ToInt32(role)); vo.ids.Add(Convert.ToInt32(role)); } } Debug.LogError("CheckPhoneCache 时间:" + sw.ElapsedMilliseconds); return(vo); }
public static bool IsVisitStoryItemLoaddown(int NpcId, Action finish = null, Action cancel = null) { int needtoTips = 1; int cunId = 1008799 + NpcId; //if (PlayerPrefs.HasKey("RecordLoveStory" + cunId)) //{ // needtoTips = PlayerPrefs.GetInt("RecordLoveStory" + cunId); //} //Debug.LogError("cunId " + cunId); CacheVo vo = CacheManager.CheckVisitStoryCache(); if (vo.needDownload == false || !vo.ids.Contains(NpcId) || needtoTips != 1) { finish?.Invoke(); return(false); } return(true); }
public static CacheVo CheckExtendCache() { Stopwatch sw = Stopwatch.StartNew(); CacheVo vo = new CacheVo(); ResIndex resIndex = GetIndexFile(ResPath.Extend); if (resIndex == null) { return(vo); } if (IsDownloadMarked()) { return(vo); } if (resIndex.packageDict.ContainsKey(ResPath.Extend) == false) { FlowText.ShowMessage(I18NManager.Get("Download_IndexNoExist")); return(vo); } ResPack resPack = resIndex.packageDict[ResPath.Extend]; _releasePath = resPack.releasePath; FileMark fm = new FileMark(AssetLoader.ExternalHotfixPath, ResPath.Backend); if (fm.IsMatch == false) { vo.needDownload = true; } vo.sizeList = new List <long>() { resPack.packageSize }; Debug.LogError("CheckExtend 时间:" + sw.ElapsedMilliseconds); return(vo); }
public static CacheVo CheckAppStartCache() { Stopwatch sw = Stopwatch.StartNew(); CacheVo vo = new CacheVo(); FileMark fm = new FileMark(AssetLoader.ExternalHotfixPath, ResPath.AppStart); if (fm.IsMatch) { return(vo); } ResIndex resIndex = GetIndexFile(ResPath.AppStart); if (resIndex == null) { return(vo); } ResPack resPack = resIndex.packageDict[ResPath.AppStart]; _releasePath = resPack.releasePath; foreach (var resItem in resPack.items) { FileInfo fileInfo = new FileInfo(AssetLoader.ExternalHotfixPath + "/" + _releasePath + "/" + resItem.Path); if (fileInfo.Exists == false || fileInfo.Length != resItem.Size) { vo.needDownload = true; break; } } vo.sizeList = new List <long>() { resPack.packageSize }; Debug.LogError("CheckAppStartCache 时间:" + sw.ElapsedMilliseconds); return(vo); }
/// <summary> /// 获取到需要后台下载的包cachevo /// </summary> /// <returns></returns> public static long CheckCurBackEndCacheSize() { Stopwatch sw = Stopwatch.StartNew(); ResIndex resIndex = GetIndexFile(ResPath.Backend); if (resIndex == null) { return(0); } if (resIndex.packageDict.Count == 0) { Debug.LogError("Download_IndexNoExist"); return(0); } long allsize = 0; foreach (var v in resIndex.packageDict) { //要遍历几遍! CacheVo vo = new CacheVo(); ResPack resPack = v.Value; _releasePath = resPack.releasePath; vo.sizeList = new List <long>() { resPack.packageSize }; FileMark fm = new FileMark(AssetLoader.ExternalHotfixPath, ResPath.Backend + "_" + v.Key); if (fm.IsMatch == false) { allsize += resPack.packageSize; } } Debug.Log("CheckBackEnd===Size 时间:" + sw.ElapsedMilliseconds); return(allsize); }
/// <summary> /// 获取到需要后台下载的包cachevo /// </summary> /// <returns></returns> public static Dictionary <string, CacheVo> CheckBackEndCacheDic(bool handlePackCount) { Stopwatch sw = Stopwatch.StartNew(); Dictionary <string, CacheVo> cacheVodic = new Dictionary <string, CacheVo>(); ResIndex resIndex = GetIndexFile(ResPath.Backend); if (resIndex == null) { return(cacheVodic); } if (resIndex.packageDict.Count == 0) { Debug.LogError("Download_IndexNoExist"); return(cacheVodic); } if (IsDownloadMarked()) { return(cacheVodic); } foreach (var v in resIndex.packageDict) { FileMark fm = new FileMark(AssetLoader.ExternalHotfixPath, ResPath.Backend + "_" + v.Key); if (fm.IsMatch == false) { CacheVo vo = new CacheVo(); vo.needDownload = true; cacheVodic.Add(v.Key, vo); } } if (handlePackCount) { LoadingProgress.Instance.AddPackCount(cacheVodic.Count); } return(cacheVodic); }
public static int GetNeedVisitStoryItemLoaddownSize(int NpcId) { int needtoTips = 1; int cunId = 1008799 + NpcId; //if (PlayerPrefs.HasKey("RecordLoveStory" + cunId)) //{ // needtoTips = PlayerPrefs.GetInt("RecordLoveStory" + cunId); //} //Debug.LogError("cunId " + cunId); CacheVo vo = CacheManager.CheckVisitStoryCache(); if (vo.needDownload == false || !vo.ids.Contains(NpcId) || needtoTips != 1) { return(0); } long size = vo.sizeList[NpcId - 1] / (1024 * 1024); int isize = int.Parse(size.ToString()); return(isize + 1); }
public static CacheVo CheckLoveStoryCache(int cardId) { Stopwatch sw = Stopwatch.StartNew(); CacheVo vo = new CacheVo(); ResIndex resIndex = GetIndexFile(ResPath.LoveStoryIndex); if (resIndex == null || resIndex.packageDict.ContainsKey(cardId.ToString()) == false) { return(vo); } ResPack resPack = resIndex.packageDict[cardId.ToString()]; _releasePath = resPack.releasePath; foreach (var resItem in resPack.items) { FileInfo fileInfo = new FileInfo(AssetLoader.ExternalHotfixPath + "/" + _releasePath + "/" + resItem.Path); if (fileInfo.Exists == false || fileInfo.Length != resItem.Size) { vo.needDownload = true; break; } } vo.sizeList = new List <long>() { resPack.packageSize }; Debug.LogError("CheckLoveStoryCache 时间:" + sw.ElapsedMilliseconds); return(vo); }
private void LoveStep3() { stroyList.gameObject.SetActive(false); pointarrow.gameObject.SetActive(false); storyview.gameObject.SetActive(true); GuideArrow.DoAnimation(storyview.Find("Stage/Circle")); // var arrow = storyview.Find("Stage/Circle/Arrow").GetComponent<Image>(); // RectTransform rect = arrow.rectTransform; // rect.DOLocalMove(new Vector2(rect.localPosition.x + 30.0f, // rect.localPosition.y + 30.0f), 0.5f).SetLoops(-1, LoopType.Yoyo); PointerClickListener.Get(storyview.Find("Stage/Circle/ClickArea").gameObject).onClick = go => { //进入想要去的剧情!//good!//需要,gate和vo var gate = new AppointmentGateRuleVo(_appointmentRuleVo.GateInfos[0]); // SendMessage(new Message(MessageConst.CMD_APPOINTMENT_ENSUREOPENGATE, // Message.MessageReciverType.UnvarnishedTransmission,gate,_appointmentRuleVo)); _cacheVo = CacheManager.CheckLoveStoryCache(_userCardVo.CardId); if (_cacheVo != null && _cacheVo.needDownload) { CacheManager.DownloadLoveStoryCache(_userCardVo.CardId, str => { ModuleManager.Instance.EnterModule(ModuleConfig.MODULE_STORY, false, false, gate, _appointmentRuleVo.Id); }, null, str => { Debug.LogError("Cancle?!"); ModuleManager.Instance.EnterModule(ModuleConfig.MODULE_STORY, false, false, gate, _appointmentRuleVo.Id); }); Debug.LogError("download"); } else { ModuleManager.Instance.EnterModule(ModuleConfig.MODULE_STORY, false, false, gate, _appointmentRuleVo.Id); } gameObject.Hide(); }; }
private void Awake() { rightDownload = transform.Find("RightTop").gameObject; transform.Find("FunctionBar/Sms/Label").GetComponent <Text>().color = ColorUtil.HexToColor("DA7DED"); transform.Find("FunctionBar/Sms").GetComponent <Toggle>().onValueChanged.AddListener(delegate(bool b) { transform.Find("FunctionBar/Sms/Label").GetComponent <Text>().color = b ? ColorUtil.HexToColor("DA7DED") : ColorUtil.HexToColor("808080"); if (b) { SendMessage(new Message(MessageConst.CMD_PHONE_SHOW_SMS)); SendMessage(new Message(MessageConst.CMD_PHONE_HIDE_BG_REDPOINT, PhoneModeType.Sms)); CheckIsShowDownload(); } }); transform.Find("FunctionBar/Telephone").GetComponent <Toggle>().onValueChanged.AddListener(delegate(bool b) { transform.Find("FunctionBar/Telephone/Label").GetComponent <Text>().color = b ? ColorUtil.HexToColor("DA7DED") : ColorUtil.HexToColor("808080"); if (b) { SendMessage(new Message(MessageConst.CMD_PHONE_SHOW_TELE)); SendMessage(new Message(MessageConst.CMD_PHONE_HIDE_BG_REDPOINT, PhoneModeType.Call)); CacheVo vo = CacheManager.CheckPhoneCache(); CheckIsShowDownload(); } }); transform.Find("FunctionBar/Friends").GetComponent <Toggle>().onValueChanged.AddListener(delegate(bool b) { transform.Find("FunctionBar/Friends/Label").GetComponent <Text>().color = b ? ColorUtil.HexToColor("DA7DED") : ColorUtil.HexToColor("808080"); if (b) { SendMessage(new Message(MessageConst.CMD_PHONE_SHOW_FRIENDS)); SendMessage(new Message(MessageConst.CMD_PHONE_HIDE_BG_REDPOINT, PhoneModeType.Friend)); rightDownload.Hide(); } }); transform.Find("FunctionBar/Weibo").GetComponent <Toggle>().onValueChanged.AddListener(delegate(bool b) { transform.Find("FunctionBar/Weibo/Label").GetComponent <Text>().color = b ? ColorUtil.HexToColor("DA7DED") : ColorUtil.HexToColor("808080"); if (b) { SendMessage(new Message(MessageConst.CMD_PHONE_SHOW_WEIBO)); SendMessage(new Message(MessageConst.CMD_PHONE_HIDE_BG_REDPOINT, PhoneModeType.Weibo)); rightDownload.Hide(); } }); transform.Find("RightTop/Download").GetButton().onClick.AddListener(() => { PopupManager.ShowWindow <PhoneDownloadTipsWindow>("Prefabs/PhoneDownloadTipsWindow").WindowActionCallback = evt => { CheckIsShowDownload(); }; }); }
public static bool ClickVisitStoryItem(int NpcId, Action finish = null, Action cancel = null) { int needtoTips = 1; int cunId = 1008799 + NpcId; //if (PlayerPrefs.HasKey("RecordLoveStory" + cunId)) //{ // needtoTips = PlayerPrefs.GetInt("RecordLoveStory" + cunId); //} //Debug.LogError("cunId " + cunId); CacheVo vo = CacheManager.CheckVisitStoryCache(); if (vo.needDownload == false || !vo.ids.Contains(NpcId) || needtoTips != 1) { finish?.Invoke(); return(false); } PlayerPB playerPB = (PlayerPB)(NpcId); string NpcName = Util.GetPlayerName(playerPB); int isize = GetNeedVisitStoryItemLoaddownSize(NpcId); if (Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork) { CacheManager.DownloadVisitStoryCache(NpcId, (str) => { finish?.Invoke(); }); } else { //弹出确认框 string content = I18NManager.Get("Download_ConfirmDownloadLoveStory2", isize.ToString()); string cancelText = I18NManager.Get("Download_JumpDownload"); PopupManager.ShowConfirmWindow(content, "Download_JumpDownload", null, cancelText).WindowActionCallback = evt => { if (evt == WindowEvent.Ok) { CacheManager.DownloadVisitStoryCache(NpcId, (s) => { finish?.Invoke(); }); } if (evt == WindowEvent.Cancel) { cancel?.Invoke(); } }; //string content = I18NManager.Get("Download_ConfirmDownloadLoveStory2", isize); //CacheManager.ConfirmVisitStoryNeedToDownload(content //, I18NManager.Get("Download_JumpDownload"), cunId, NpcId, str => //{ // finish?.Invoke(); //}, () => //{ // cancel?.Invoke(); //}); } return(true); }