public void Refresh() { _challengeLevelConfig = ConfigManager.GetConfig(ConfigManager.ConfigType.ChallengeLevelConfig) as ChallengeLevelConfig; if (_challengeLevelConfig == null) { Debug.LogError("没有ChallengeLevelConfig,玩个毛"); return; } while (MajorLevelSectorList.Count < _challengeLevelConfig.MajorLevelList.Count) { MajorLevelSectorList.Add(null); } for (int i = 0; i < _challengeLevelConfig.MajorLevelList.Count; i++) { if (MajorLevelSectorList[i] == null) { MajorLevelSectorList[i] = PrefabHelper.InstantiateAndReset(MajorLevelSectorTemplate, transform); MajorLevelSectorList[i].name = "MajorLevelSector " + i; MajorLevelSectorList[i].SetActive(true); MajorLevelSectorList[i].transform.localEulerAngles = new Vector3(0, 0, -i * OffsetAngle); } var majorLevelId = _challengeLevelConfig.MajorLevelList[i].MajorLevelId; var cui = CommonData.ChallengeUnlockInfoList.Find( x => x.MajorLevelId == majorLevelId); MajorLevelSectorList[i].GetComponentInChildren <Island>() .SetAndRefresh(PushLevelUI, majorLevelId, cui, _challengeLevelConfig.MajorLevelList[i]); } //LastNotOpenSign.name = "MajorLevelButton " + CommonData.ChallengeUnlockInfoList.Count; MajorLevelSectorTemplate.SetActive(false); }
//在联网前,读取Read本地缓存文件,如果没有文件,hashcode为"",第一行是hashcode //加载Load hashcode,数据,到内存 //登录,比较新hashcode,相同则跳过;不同,则申请新的hashcode //申请的结果和运行时动态更新都是收到服务端的ResponseTextConfig,加载hashcode,数据,到内存,组装新文件替换缓存 /// <summary> /// 从硬盘读取bytes加载到内存。每次刚运行时调用 /// </summary> public static void ReadCacheAndLoadAllLargeConfigs() { for (int i = 0; i < Configs.Length; i++) { var configType = (ConfigType)i; var path = GetFilePath(configType); byte[] bytes = null; if (File.Exists(path)) { try { //bytes = File.ReadAllBytes(path); } catch (Exception e) { Debug.LogException(e); } } if (bytes != null) { IReceiveable configCmd = null; switch (configType) { case ConfigType.CoreConfig: configCmd = new CoreConfig(); break; case ConfigType.RechargeConfig: configCmd = new RechargeConfig(); break; case ConfigType.SkillConfig: configCmd = new SkillConfig(); break; case ConfigType.SkillParameterConfig: configCmd = new SkillParameterConfig(); break; case ConfigType.ExchangeConfig: configCmd = new ExchangeConfig(); break; case ConfigType.VegetableConfig: configCmd = new VegetableConfig(); break; case ConfigType.ChallengeLevelConfig: configCmd = new ChallengeLevelConfig(); break; case ConfigType.SkillIntroTextConfig: configCmd = new SkillIntroTextConfig(); break; case ConfigType.SkillLevelDetailTextConfig: configCmd = new SkillLevelDetailTextConfig(); break; case ConfigType.VegetableIntroTextConfig: configCmd = new VegetableIntroTextConfig(); break; case ConfigType.WaitHintTextConfig: configCmd = new WaitHintTextConfig(); break; case ConfigType.CharacterConfig: configCmd = new CharacterConfig(); break; case ConfigType.EquipConfig: configCmd = new EquipConfig(); break; case ConfigType.MajorLevelIntroTextConfig: configCmd = new MajorLevelIntroTextConfig(); break; case ConfigType.EquipIntroTextConfig: configCmd = new EquipIntroTextConfig(); break; case ConfigType.CharacterIntroTextConfig: configCmd = new CharacterIntroTextConfig(); break; case ConfigType.OAuthParamConfig: configCmd = new OAuthParamConfig(); break; default: Debug.LogError("遇到新的ConfigType,需添加代码。type:" + configType); break; } if (configCmd != null) { configCmd.ParseFrom(bytes); SetConfig(configType, configCmd); } } } }