/// <summary> /// 检查本地所有版本信息与服务器所有版本信息,看是否要更新本地的所有版本信息xml文件 /// </summary> /// <returns></returns> bool CheckLocalAndServerPatch() { //没有本地所有版本信息xml文件,需要更新xml文件 if (!File.Exists(m_LocalXmlPath)) { return(true); } //读取本地所有版本信息,xml转换成类信息 m_LocalInfo = BinarySerializeOpt.XmlDeserialize(m_LocalXmlPath, typeof(ServerInfo)) as ServerInfo; VersionInfo localGameVesion = null; if (m_LocalInfo != null) { foreach (VersionInfo version in m_LocalInfo.GameVersion) { //从本地所有版信息中找到游戏的当前版本信息 if (version.Version == CurVersion) { localGameVesion = version; break; } } } //本地当前版本信息和服务器不一致,需要更新本地所有版本信息xml文件 if (localGameVesion != null && m_GameVersion.Pathces != null && localGameVesion.Pathces != null && m_GameVersion.Pathces.Length > 0 && m_GameVersion.Pathces[m_GameVersion.Pathces.Length - 1].Version != localGameVesion.Pathces[localGameVesion.Pathces.Length - 1].Version) { return(true); } return(false); }
/// <summary> /// 加载数据表 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="path">二进制路径</param> /// <returns></returns> public T LoadData <T>(string path) where T : ExcelBase { if (string.IsNullOrEmpty(path)) { return(null); } if (m_AllExcelData.ContainsKey(path)) { Debug.LogError("重复加载相同配置文件" + path); return(m_AllExcelData[path] as T); } T data = BinarySerializeOpt.BinaryDeserilize <T>(path); #if UNITY_EDITOR if (data == null) { Debug.Log(path + "不存在,从xml加载数据了!"); string xmlPath = path.Replace("Binary", "Xml").Replace(".bytes", ".xml"); data = BinarySerializeOpt.XmlDeserialize <T>(xmlPath); } #endif if (data != null) { data.Init(); } m_AllExcelData.Add(path, data); return(data); }
/// <summary> /// xml转二进制 /// </summary> /// <param name="name"></param> private static void XmlToBinary(string name) { if (string.IsNullOrEmpty(name)) { return; } try { Type type = null; foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) { Type tempType = asm.GetType(name); if (tempType != null) { type = tempType; break; } } if (type != null) { string xmlPath = XmlPath + name + ".xml"; string binaryPath = BinaryPath + name + ".bytes"; object obj = BinarySerializeOpt.XmlDeserialize(xmlPath, type); BinarySerializeOpt.BinarySerilize(binaryPath, obj); Debug.Log(name + "xml转二进制成功,二进制路径为:" + binaryPath); } } catch { Debug.LogError(name + "xml转二进制失败!"); } }
/// <summary> /// 反序列化xml到类 /// </summary> /// <param name="name"></param> /// <returns></returns> private static object GetObjFormXml(string name) { Type type = null; foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) { Type tempType = asm.GetType(name); if (tempType != null) { type = tempType; break; } } if (type != null) { string xmlPath = XmlPath + name + ".xml"; return(BinarySerializeOpt.XmlDeserialize(xmlPath, type)); } return(null); }