private void LoadAssetsInfo(BaseRes res, Dictionary <string, ResData> assetInfo) { List <ResData> datas = res.atlas; foreach (ResData atlas in datas) { assetInfo.Add(atlas.name, atlas); } datas = res.audios; foreach (ResData audio in datas) { assetInfo.Add(audio.name, audio); } datas = res.prefabs; foreach (ResData prefab in datas) { assetInfo.Add(prefab.name, prefab); } datas = res.textures; foreach (ResData texture in datas) { assetInfo.Add(texture.name, texture); } datas = res.fonts; foreach (ResData font in datas) { assetInfo.Add(font.name, font); } }
/// <summary> /// 初始游戏下载文件 /// </summary> private void InitGameDownLoadFiles(int productId) { GameResConfig serverLobbyRes = serverTableResConfig.gameResConfig; BaseRes serverGameRes = serverLobbyRes.FindProductRes(productId); ComparisonFiles(serverGameRes, productId); }
/// <summary> /// Write header for a resource group. /// </summary> /// <param name="theResGroup">Name of the resource group.</param> /// <param name="theResourceDict">Dictionary with the resources for this group.</param> private void WriteHeaderFileGroup(String theResGroup, SortedDictionary <String, BaseRes> theResourceDict) { // extract function aStreamWriter.WriteLine("\t// " + theResGroup + " Resources" + Environment.NewLine); aStreamWriter.WriteLine("\tbool " + mFunctionPrefix + "Extract" + theResGroup + "Resources(ResourceManager* theMgr);" + Environment.NewLine); // get extern references Set <String> aExternRefSet = new Set <String>(); foreach (KeyValuePair <String, BaseRes> aBaseRes in theResourceDict) { BaseRes aRes = aBaseRes.Value; String aVarName = aRes.mId; String aTypeName = GetTypeName(aRes); aExternRefSet.Add("\textern " + aTypeName + " " + aVarName + ";" + Environment.NewLine); } // write extern references foreach (KeyValuePair <String, bool> aExternRef in aExternRefSet) { aStreamWriter.Write(aExternRef.Key); } aStreamWriter.WriteLine(""); }
public bool CheckGameHotUpdate(int productId) { #if STREAM_ASSET if (!TableGameConfig.openHotUpdate || !TableGameConfig.openGameHp) { return(false); } LocalResConfigMgr localResConfigMgr = LocalResConfigMgr.Instance; localResConfigMgr.LoadGameResConfig(productId); BaseRes gameResConfig = localResConfigMgr.FindGameRes(productId); string serverGameVer = TableGameConfig.GetGameVersion(productId); if (string.IsNullOrEmpty(serverGameVer) || string.IsNullOrEmpty(gameResConfig.version) || CheckVersion(serverGameVer, gameResConfig.version) <= 0) { Debugger.Log("Game version code is same! product id==" + productId); return(false); } return(true); #else return(false); #endif }
public async Task <BaseRes <T> > Execute <T>(string url, string jsonStr) { var res = new BaseRes <T>(); var client = new RestClient(""); var request = new RestRequest(); request.RequestFormat = RestSharp.DataFormat.Json; request.AddParameter("application/json", jsonStr, ParameterType.RequestBody); var result = await client.ExecutePostTaskAsync(request); if (result.StatusCode != System.Net.HttpStatusCode.OK) { //log.ErrorFormat("get {0} response from service!", result.StatusCode); res.statusCode = "FAILD"; res.status = $"{false}"; res.message = result.ErrorMessage; } else { res.statusCode = "SUCCESS"; res.status = $"{true}"; } res.result = JsonConvert.DeserializeObject <T>(result.Content, jSettings); return(res); }
/// <summary> /// 重建游戏资源配置 /// </summary> /// <param name="res"></param> /// <param name="productId"></param> public void RebuildGameRes(BaseRes res, int productId) { if (!products.ContainsKey(productId)) { return; } products.Remove(productId); products.Add(productId, res); }
public LobbyResConfig() { scripts = new ScriptRes(); common = new BaseRes(); hotUpdate = new BaseRes(); login = new BaseRes(); lobby = new BaseRes(); game = new BaseRes(); }
/// <summary> /// 查找产品资源 /// </summary> /// <param name="id"></param> /// <returns></returns> public BaseRes FindProductRes(int id) { BaseRes res = null; if (!products.TryGetValue(id, out res)) { return(null); } return(res); }
/// <summary> /// 获取产品资源 /// </summary> /// <param name="id"></param> /// <returns></returns> public BaseRes GetOrAddProductRes(int id) { BaseRes res = null; if (!products.TryGetValue(id, out res)) { res = new BaseRes(); products.Add(id, res); } return(res); }
private void ComparisonFiles(BaseRes baseRes, int productId = -1) { // 比对图集资源 ComparisonFiles(baseRes.atlas, productId); // 比对纹理资源 ComparisonFiles(baseRes.textures, productId); // 比对声音 ComparisonFiles(baseRes.audios, productId); // 比对字体 ComparisonFiles(baseRes.fonts, productId); // 比对预制 ComparisonFiles(baseRes.prefabs, productId); }
/// <summary> /// Write global variables for a resource group. /// </summary> /// <param name="theResGroup">Name of the resource group.</param> /// <param name="theResourceDict">Dictionary with the resources for this group.</param> private void WriteSourceFileVariables(String theResGroup, SortedDictionary <String, BaseRes> theResourceDict) { aStreamWriter.WriteLine("// " + theResGroup + " Resources" + Environment.NewLine); foreach (KeyValuePair <String, BaseRes> aBaseRes in theResourceDict) { BaseRes aRes = aBaseRes.Value; String aVarName = aRes.mId; String aTypeName = GetTypeName(aRes); aStreamWriter.WriteLine(aTypeName + " Sexy::" + aVarName + ";"); } aStreamWriter.WriteLine(""); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; var res = ""; if (!string.IsNullOrEmpty(context.Request["type"])) { var reqType = context.Request["type"]; var gson = context.Request["gson"]; if (string.IsNullOrEmpty(gson)) { return; } if ("true".Equals(ConfigurationManager.AppSettings["showlog"])) { SimpleLog.WriteLog(gson); } AndroidOperateService AService = new AndroidOperateService(); Object objectRes = new BaseRes() { errMsgNo = 1, isErrMsg = true, errMsg = "不支持该操作" }; switch (reqType) { case "0": //注册 objectRes = AService.Reg(JsonTool.Deserialize <EquipmentReg>(gson)); break; case "1": //登录 objectRes = AService.Login(JsonTool.Deserialize <LoginReq>(gson)); break; case "2": objectRes = AService.GetContacts(JsonTool.Deserialize <ContactReq>(gson)); break; default: break; } res = JsonTool.Serialize(objectRes); } if ("true".Equals(ConfigurationManager.AppSettings["showlog"])) { SimpleLog.WriteLog(res); } context.Response.Write(res); }
/// <summary> /// 同步具体产品游戏资源配置数据 /// </summary> public void SyncGameResConfig(GameResConfig gameResConfig, int productId) { BaseRes newGameRes = gameResConfig.FindProductRes(productId); if (newGameRes == null) { return; } LocalTableResConfig.gameResConfig.RebuildGameRes(newGameRes, productId); ABAssetDataMgr.Instance.SyncGameAssetInfo(LocalTableResConfig, productId); string xmlPath = ABConfiger.GetSandboxFilePath(TableGameRes.FILE_NAME); XMLSerializer.Save <TableGameRes>(xmlPath, LocalTableResConfig); }
/// <summary> /// Get the type name of the resource. /// </summary> /// <param name="theRes">The resource information.</param> /// <returns>The type name as string.</returns> private String GetTypeName(BaseRes theRes) { switch (theRes.mType) { case ResType.Image: return("SexyImage*"); case ResType.Sound: return("int"); case ResType.Music: return("int"); case ResType.Font: return("SexyFont*"); case ResType.Movie: return("SexyMovie*"); } return(""); }
/// <summary> /// 判断access_token是否过期 /// </summary> /// <param name="res"></param> /// <param name="needRefresh"></param> /// <returns></returns> public bool IsAccessTokenError(BaseRes res, bool needRefresh = true) { var rel = res.errcode == "42001" || res.errcode == "41001" || res.errcode == "40002" || res.errcode == "40014"; if (rel && needRefresh) { if (needRefresh) { // 超时并且需要刷新 RefreshToken(); } else { throw new BusinessBaseException(ExceptionCode.WechatCannotDelete); } } return(rel); }
/// <summary> /// 判断access_token是否过期 /// </summary> /// <param name="res"></param> /// <param name="needRefresh"></param> /// <returns></returns> public bool IsAccessTokenError(BaseRes res, bool needRefresh = true) { var rel = res.errcode == "42001" || res.errcode == "41001" || res.errcode == "40002" || res.errcode == "40014"; if (rel && needRefresh) { if (needRefresh) { // 超时并且需要刷新 RefreshToken(); } else { throw new Exception("IsAccessTokenError 系统异常"); } } return(rel); }
// 检查是否下载服务器资源配置表 private bool CheckDownLoadResConfig() { // 检查是否需要热更新 if (!TableGameConfig.openHotUpdate) { return(false); } LocalResConfigMgr localResConfigMgr = LocalResConfigMgr.Instance; // 比对大厅资源版本 LobbyResConfig lobbyResConfig = localResConfigMgr.LocalLobbyResConfig; if (TableGameConfig.openLobbyHp && CheckVersion(TableGameConfig.version, lobbyResConfig.version) > 0) { return(true); } // 判断是否游戏是否需要更新 if (!TableGameConfig.openGameHp) { return(false); } // 比对游戏资源版本 GameResConfig gameResConfig = localResConfigMgr.LocalGameResConfig; var enumerator = TableGameConfig.gameVersion.GetEnumerator(); while (enumerator.MoveNext()) { int productId = enumerator.Current.Key; string gameVer = enumerator.Current.Value; BaseRes gameRes = gameResConfig.FindProductRes(productId); if (gameRes == null || CheckVersion(gameVer, gameRes.version) > 0) { return(true); } } return(false); }
/// <summary> /// Write the extract resources function for a resource group. /// </summary> /// <param name="theResGroup">Name of the resource group.</param> /// <param name="theResourceDict">Dictionary with the resources for this group.</param> private void WriteSourceFileGroup(String theResGroup, SortedDictionary <String, BaseRes> theResourceDict) { aStreamWriter.WriteLine("bool Sexy::" + mFunctionPrefix + "Extract" + theResGroup + "Resources(ResourceManager* theManager)"); aStreamWriter.WriteLine("{"); aStreamWriter.WriteLine("\tgNeedRecalcVariableToIdMap = true;" + Environment.NewLine); aStreamWriter.WriteLine("\tResourceManager &aMgr = *theManager;" + Environment.NewLine); aStreamWriter.WriteLine("\ttry"); aStreamWriter.WriteLine("\t{"); foreach (KeyValuePair <String, BaseRes> aBaseRes in theResourceDict) { String anId = aBaseRes.Key; BaseRes aRes = aBaseRes.Value; String aVarName = aRes.mId; String aMethodName = ""; switch (aRes.mType) { case ResType.Image: aMethodName = "GetImageThrow"; break; case ResType.Sound: aMethodName = "GetSoundThrow"; break; case ResType.Music: aMethodName = "GetMusicThrow"; break; case ResType.Font: aMethodName = "GetFontThrow"; break; case ResType.Movie: aMethodName = "GetMovieThrow"; break; } aStreamWriter.WriteLine("\t\t" + aVarName + " = aMgr." + aMethodName + "(_S(\"" + anId + "\"));"); } aStreamWriter.WriteLine("\t}"); aStreamWriter.WriteLine("\tcatch (ResourceManagerException&)"); aStreamWriter.WriteLine("\t{"); aStreamWriter.WriteLine("\t\treturn false;"); aStreamWriter.WriteLine("\t}"); aStreamWriter.WriteLine("\treturn true;"); aStreamWriter.WriteLine("}" + Environment.NewLine); }
/// <summary> /// 加载游戏资源配置 /// </summary> /// <param name="resConfig"></param> /// <param name="productId">产品ID</param> public void LoadGameAssetsInfo(TableGameRes resConfig, int productId) { GameResConfig gameResConfig = resConfig.gameResConfig; BaseRes gameRes = gameResConfig.FindProductRes(productId); if (gameRes == null) { return; } Dictionary <string, ResData> assetInfo = gameAssetsInfo.FindGameAsset(productId); if (assetInfo != null) { return; } assetInfo = gameAssetsInfo.CreateGameAsset(productId); LoadAssetsInfo(gameRes, assetInfo); }
/// <summary> /// 写入文件 /// </summary> /// <param name="HttpContext"></param> /// <param name="moreSize"></param> /// <param name="biz_type"></param> /// <param name="biz_id"></param> /// <param name="is_async">是否是异步线程写入</param> /// <returns></returns> private static async Task <dynamic> UploadFolder(HttpContext HttpContext, int moreSize, string biz_type, long biz_id, bool is_async = false) { //错误消息 string error = string.Empty, url = string.Empty, original = string.Empty, data = string.Empty; //状态 StateCode state = StateCode.State_200; //结果集合 List <dynamic> result = new List <dynamic>(); //当前资源站点域名 string domain = AppGlobal.Res; if (HttpContext.Request.Form.Files.Count() > 0) { foreach (var file in HttpContext.Request.Form.Files) { //原文件名 original = file.FileName; //访问路径 文件名 string[] filedata = { }; try { filedata = Uploader.GetUploadPath(biz_type, biz_id, original); //资源根目录 string localPath = Directory.CreateDirectory("wwwroot/" + filedata[0] + "/").FullName; //获取图片基本信息 BaseRes res = GetBaseRes(biz_type, localPath, filedata[0], filedata[1].Split('.')[0], original, file.Length, domain); Img img = (Img)res; img.biz_type = biz_type; if (ImgType.User.Equals(biz_type)) { img.biz_id = biz_id; SaveAutoComplete(img); } else { //保存图片 SaveImgMsg(img); } //文件字节 byte[] fileBytes = new byte[file.Length]; //文件扩展名 string f_name = img.extend_name.ToLower(); var is_img = ((".gif".Equals(f_name) || ".jpg".Equals(f_name) || ".jpeg".Equals(f_name) || ".bmp".Equals(f_name) || ".png".Equals(f_name))); //如果是图片类型 if (is_img) { if (file.Length < int.Parse(ConfigManage.AppSettings <string>("UploadSettings:imageMaxSize"))) { //写入图片 if (await Uploader.WriteFile(file, localPath, filedata[1], is_async) && is_img) { switch (moreSize) { //创建小图 case 1: CreateThumbnailPicture(localPath + filedata[1], GetThmUrl(localPath), filedata[1]); break; //创建中图 case 2: CreateThumbnailPicture(localPath + filedata[1], GetMedUrl(localPath), filedata[1], true); break; //创建小图和中图 case 3: CreateThumbnailPicture(localPath + filedata[1], GetThmUrl(localPath), filedata[1]); CreateThumbnailPicture(localPath + filedata[1], GetMedUrl(localPath), filedata[1], true); break; default: break; } } } } else { await Uploader.WriteFile(file, localPath, filedata[1], is_async); } url = domain + filedata[0] + filedata[1]; data = filedata[1].Split('.')[0]; } catch (Exception e) { state = StateCode.State_500; error = e.Message; } //图片列表 result.Add(new { key = data, val = url, original, state }); } } return(new { state, url, original, data, result, error }); }
/// <summary> /// Parse common resource attributes, save the data in resource dictionary and variable list. /// </summary> /// <param name="theType">The resource type.</param> /// <returns>False if attribute path is missing or the element already exists, otherwise true.</returns> private bool ParseCommonResource(ResType theType) { String aPath = aXMLReader.GetAttribute("path"); String anId = aXMLReader.GetAttribute("id"); String aTempString; if (aPath == null) { mErrorString = "No path specified"; if (anId != null) { mErrorString += " ID: " + anId; } return(false); } if (anId == null) { anId = mDefaultIdPrefix + Common.GetFileName(aPath, true); } else { anId = mDefaultIdPrefix + anId; } mOutputForm.WriteLine("Parsing Element " + anId); Application.DoEvents(); AddFile(aPath); if (theType == ResType.Image) { aTempString = aXMLReader.GetAttribute("alphaimage"); if (aTempString != null) { AddFile(aTempString); } aTempString = aXMLReader.GetAttribute("alphagrid"); if (aTempString != null) { AddFile(aTempString); } } BaseRes aRes = new BaseRes(); aRes.mType = theType; aRes.mId = anId; aTempString = aXMLReader.GetAttribute("alias"); if (aTempString != null) { aRes.mAlias.Add(mDefaultIdPrefix + aTempString); } for (ushort i = 0; i < MAX_ALIASES; i++) { aTempString = aXMLReader.GetAttribute("alias" + i.ToString()); if (aTempString != null) { aRes.mAlias.Add(mDefaultIdPrefix + aTempString); } } try { mCurrentResGroup.Add(anId, aRes); } catch (ArgumentException) { mErrorString = "An element with Key = " + anId + " already exists."; return(false); } // save the resource information for the codewriter mVariableList.Add(aRes); return(true); }