IEnumerator OnUpdateResource() { string random = DateTime.Now.ToString("yyyymmddhhmmss"); string versionFile = SAGameVersion.asset_path + SAAppConfig.LanguagePlatform + "/" + MD5_NAME + "?rd=" + random; WWW www = new WWW(versionFile); yield return(www); if (www.error != null) { //抱错喽~~~ print("抱错喽~~~ : " + versionFile); yield break; } SAUtils.Log("文件加载完毕"); convertXML = SALang.stringConvertXML(www.text);//等待写入 newVersion = getXmlToDictionary(convertXML.DocumentElement.ChildNodes); progressData.info = "更新资源..."; resListEN = newVersion.GetEnumerator(); totalNum = newVersion.Count; currentNum = 0; dispatchEvent(SAACollection.REFRESH + ActionCollection.LocalFile); yield return(StartCoroutine(download())); }
private void errorHandler(SAFactoryEvent e) { SASocketDataDAO sdd = (SASocketDataDAO)e.Body; SError.Builder error = (SError.Builder)CommandCollection.getDataModel(ProtoTypeEnum.SError, sdd.bytes); SAUtils.LogError("错误码 : " + error.Code); }
//接收数据 protected void AsynRecive() { try { //开始接收数据 //该步骤只读取长度 clear_receive_buffers(CommandCollection.SOCK_CONTEXT_LENGTH); _socket.BeginReceive(receive_buffers, 0, receive_buffers.Length, SocketFlags.None, readMessageLength => { _socket.EndReceive(readMessageLength); msg_length = readUShort(); clear_receive_buffers(msg_length); _socket.BeginReceive(receive_buffers, 0, receive_buffers.Length, SocketFlags.None, receiveMessage => { _socket.EndReceive(receiveMessage); ///---------读取数据 SASocketDataDAO sdd = new SASocketDataDAO(readUShort(), readBytes(msg_length - CommandCollection.SOCK_TYPE_LENGTH)); //CommandCollection.getDataModel((ProtoTypeEnum)sdd.type, sdd.bytes); SAUtils.Log("收到消息号 : " + (ProtoTypeEnum)sdd.type); dispatchEvent(Command + (ProtoTypeEnum)sdd.type, sdd); AsynRecive(); }, null); }, null); } catch (Exception ex) { SAUtils.LogError("异常信息:" + ex.Message); AsynRecive(); } }
public SocketDataWorker(string name, string command) : base(name, command) { random = new System.Random(); _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); SAUtils.Log("Socket Init"); }
override protected void mainStart() { SAUtils.Log("start heart"); base.mainStart(); SAAppConfig.Thread = true; sock = (SocketDataWorker)IOCManager.Instance.getIOCDataWorker("Datas.SocketDataWorker"); new Thread(heart).Start(); }
public void hit() { if ((life -= 30) <= 0) { gameObject.GetComponent <Animator> ().Play("die"); gameObject.GetComponent <Collider> ().enabled = false; graph.dispatchEvent(SAACollection.AddScore, fd); SAUtils.Log("加分"); } }
private Dictionary <string, object> _getSuperProperties() { string propertiesJson = get_super_properties(); if (propertiesJson == null || propertiesJson.Length == 0) { return(null); } return(SAUtils.Parse2Dictionary(propertiesJson)); }
override protected void onRegister() { base.onRegister(); //addEventDispatcherWithHandle(SAACollection.NewTarget, newTargetHandler); addEventDispatcherWithHandle(SAACollection.FishDie, fishDieHandler); addEventDispatcherWithHandle(CommandCollection.Sock + ProtoTypeEnum.SFishChapter, fishChapterHandler); //获取房间信息 CEnterRoom.Builder enterRoom = CEnterRoom.CreateBuilder(); sock.sendMessage(ProtoTypeEnum.CEnterRoom, enterRoom.Build().ToByteArray()); SAUtils.Log("onRegister"); }
private void _trackTimerEnd(string eventName, Dictionary <string, object> properties) { AndroidJavaObject jsonObject = null; if (properties != null) { string jsonStr = SAUtils.Parse2JsonStr(properties); jsonObject = SAUtils.Parse2JavaJSONObject(jsonStr); } apiInstance.Call("trackTimerEnd", eventName, jsonObject); }
private void _registerSuperProperties(Dictionary <string, object> properties) { AndroidJavaObject jsonObject = null; if (properties != null) { string jsonStr = SAUtils.Parse2JsonStr(properties); jsonObject = SAUtils.Parse2JavaJSONObject(jsonStr); } apiInstance.Call("registerSuperProperties", jsonObject); }
private void _profileSetOnce(Dictionary <string, object> dic) { if (dic == null) { return; } string jsonStr = SAUtils.Parse2JsonStr(dic); AndroidJavaObject jsonObject = SAUtils.Parse2JavaJSONObject(jsonStr); apiInstance.Call("profileSetOnce", jsonObject); }
//二期内容 private void _trackInstallation(Dictionary <string, object> properties = null, bool disableCallback = false) { AndroidJavaObject jsonObject = null; if (properties != null) { string jsonStr = SAUtils.Parse2JsonStr(properties); jsonObject = SAUtils.Parse2JavaJSONObject(jsonStr); } apiInstance.Call("trackAppInstall", jsonObject, disableCallback); }
private Dictionary <string, object> _getSuperProperties() { AndroidJavaObject jsonObj = apiInstance.Call <AndroidJavaObject>("getSuperProperties"); string jsonStr = jsonObj.Call <string>("toString"); if (jsonStr == null || jsonStr.Length == 0) { return(null); } return(SAUtils.Parse2Dictionary(jsonStr)); }
private void _track(string eventName, Dictionary <string, object> dic = null) { AndroidJavaObject jsonObject = null; if (dic != null) { string jsonStr = SAUtils.Parse2JsonStr(dic); jsonObject = SAUtils.Parse2JavaJSONObject(jsonStr); } apiInstance.Call("track", eventName, jsonObject); }
protected void connectComplete(IAsyncResult ar) { try { _socket.EndConnect(ar); update(SAACollection.COMPLETE); SAUtils.Log("Success ... "); AsynRecive(); } catch (SocketException e) { update(SAACollection.ERROR); SAUtils.Log("ErrorCode ... " + e.ErrorCode); } }
protected override void onSrart(System.Object args) { base.onSrart(args); SAUtils.Log("load resource..."); if (true || !PlayerPrefs.HasKey("resources_version") || PlayerPrefs.GetInt("resources_version") != SAGameVersion.Instance.ioc_version) {//更新资源 refreshLocalVersionInfo(); } else { SAUtils.Log("load version..."); dispatchEvent(SAACollection.REFRESH + ActionCollection.LocalFile + SAACollection.COMPLETE);//更新完成 } //initSocket();//临时直接初始化socket }
private IEnumerator download() { if (resListEN.MoveNext()) { string fileKey = resListEN.Current.Key; localFilePath = Path.Combine(SAAppConfig.RemotePath, fileKey); bool isExist = File.Exists(localFilePath);//判断本地文件 progressData.info = "正在更新资源 : " + fileKey; dispatchEvent(SAACollection.REFRESH + ActionCollection.LocalFile); if (isExist) { isExist = version.ContainsKey(fileKey) && version[fileKey].Equals(resListEN.Current.Value); if (!isExist) { File.Delete(localFilePath); } } if (!isExist)//需要下载 { progressData.name = resListEN.Current.Key; stopWatch.Start(); //loadFileWithName(fileKey); string remoteFilePath = SAGameVersion.asset_path + fileKey; WWW www = new WWW(remoteFilePath); yield return(www); if (www.error != null) { //抱错喽~~~ SAUtils.Log("抱错喽~~~ : " + remoteFilePath); yield break; } SALang.writeLocalByteWithName(www.bytes, resListEN.Current.Key); } ++currentNum; yield return(StartCoroutine(download())); } else { progressData.info = "更新完毕"; dispatchEvent(SAACollection.REFRESH + ActionCollection.LocalFile); downloadComplete(); } }
/// <summary> /// 更新本地版本信息缓存 /// </summary> protected void refreshLocalVersionInfo() { SAUtils.Log("refresh version..."); //获取当前(旧的)版本 version = getXmlToDictionary(SALang.getLocalXMLWithName(MD5_NAME).DocumentElement.ChildNodes); //加载远程(最新)版本信息 progressData.info = "加载版本文件信息..."; addEventDispatcherWithHandle(SAACollection.REFRESH + ActionCollection.LocalFile + SAACollection.COMPLETE, updateLocalFileComplete);//资源加载完成 //加载 if (SAAppConfig.UIRelease) { addEventDispatcherWithHandle(SAACollection.REFRESH + ActionCollection.LocalFile, updateLocalFile);//资源加载 StartCoroutine(OnUpdateResource()); } else { dispatchEvent(SAACollection.REFRESH + ActionCollection.LocalFile + SAACollection.COMPLETE);//更新完成 } }
/// <summary> /// 资源加载完成 /// </summary> /// <param name="e"></param> private void updateLocalFileComplete(SAFactoryEvent e) { removeEventDispatcher(SAACollection.REFRESH + ActionCollection.LocalFile + SAACollection.COMPLETE);//资源加载完成 //初始化 AssetBundleRemoteLua string localFilePath = Path.Combine(SAAppConfig.LuaRelease?SAAppConfig.RemoteLuaDir : SAAppConfig.DevLuaDir, originName + ".lua"); bool isExist = File.Exists(localFilePath);//判断本地文件 if (isExist) { luaEnv = new LuaEnv(); luaEnv.AddLoader(LuaFile); luaEnv.DoString("require '" + localFilePath + "'"); //################以下按照流程顺序补齐lua操作 base.callLuaFun(SAACollection.luaNew, this); //初始化 base.callLuaFun(SAACollection.luaRegister); //注册 base.callLuaFun(SAACollection.luaStart); //启动 //内部自动处理加载关闭以及接下来的执行任务 base.callLuaFun(SAACollection.luaRegisterComplete); //启动完毕 } SAUtils.Log("AssetBundleFactory complete"); int w = Screen.width; int h = Screen.height; //test = Instantiate((GameObject)SACache.getObjectWithName("model/cheqiyu/cheqiyu")); //test.GetComponent<Animator>().Play("swim"); //ProtoTypeEnum.CLogin.ToString() //GameObject test = Instantiate(SACache.getResWithName<GameObject>("Model.FightPanelUI.FightPanelMap")); //GameObject test = Instantiate(UnityEditor.AssetDatabase.LoadAssetAtPath<GameObject>("Assets/_Resources/Model/FightPanelUI/FightPanelMap.prefab")); //test.transform.FindChild("Ground").transform.localPosition = new Vector3(0, 0.7f, 0); //test.transform.FindChild("FourDimensional").transform.localPosition = new Vector3(0, 0.7f, 0); //SALaunch.UIRootCamera.gameObject.SetActive(false); }
private void _track(string eventName, Dictionary <string, object> dic = null) { track(eventName, SAUtils.Parse2JsonStr(dic)); }
private void _registerSuperProperties(Dictionary <string, object> properties) { SALog.Debug("Editor Log: calling registerSuperProperties: properties=" + SAUtils.ToDebugString(properties)); }
private void _trackTimerEnd(string eventName, Dictionary <string, object> properties) { SALog.Debug("Editor Log: calling trackTimerEnd: eventName=" + eventName + ", properties=" + SAUtils.ToDebugString(properties)); }
private void _profileSetOnce(Dictionary <string, object> properties) { SALog.Debug("Editor Log: calling profileSetOnce: properties=" + SAUtils.ToDebugString(properties)); }
//二期内容 private void _trackInstallation(Dictionary <string, object> properties = null, bool disableCallback = false) { SALog.Debug("Editor Log: calling TrackInstallation: properties=" + SAUtils.ToDebugString(properties) + ", " + disableCallback); }
private void _trackTimerEnd(string eventName, Dictionary <string, object> properties) { track_timer_end(eventName, SAUtils.Parse2JsonStr(properties)); }
private void _registerSuperProperties(Dictionary <string, object> properties) { register_super_properties(SAUtils.Parse2JsonStr(properties)); }
private void _trackInstallation(Dictionary <string, object> properties, bool disableCallback) { track_app_install(SAUtils.Parse2JsonStr(properties), disableCallback); }
override protected void onDispose() { base.onDispose(); SAUtils.Log("onDispose"); }
private void _profileSetOnce(Dictionary <string, object> dic) { profile_set_once(SAUtils.Parse2JsonStr(dic)); }
override protected void onRegisterComplete() { base.onRegisterComplete(); SAUtils.Log("onRegisterComplete"); }