public void Login(string user, string password, string apn, string mac, string model, int channel, int subChanner, int sdkId) { EngineManager engine = EngineManager.GetInstance(); cs_login login = new cs_login(); login.uid = user; login.password = string.IsNullOrEmpty(password) ? new byte[0] : TextUtils.GetBytes(password); //UtilTools.ShowMessage(LoginGameData.accountServerVerificationMD5()); login.sz_param = LoginGameData.accountServerVerificationMD5(); LogSys.LogError("content=" + login.sz_param); login.version = engine.Message.GetAttribute("newVersions"); login.network_type = apn; login.sys_type = (uint)engine.SysType; login.ios_idfa = ""; login.ios_idfv = ""; login.mac_address = mac; login.device_type = model; login.platform_flag = (uint)sdkId; login.chnid = (uint)channel; login.sub_chnid = (uint)subChanner; // UtilTools.ShowWaitWin(WaitFlag.LoginFirst); ClientNetwork.Instance.SendMsg(ProtoID.CS_LOGIN, login); }
/// <summary> /// 初始化场景管理类 /// </summary> public void initialize() { #if UNITY_IOS localNotification = new LocalNotificationIOS(); #elif UNITY_EDITOR #endif if (localNotification == null) { return; } string xmlPath = "Config/localNotification.json"; AssetLoadTask task = new AssetLoadTask(xmlPath, null); task.EventFinished += new task.TaskBase.FinishedHandler(delegate(bool manual, TaskBase currentTask) { Object assetObj = ((AssetLoadTask)currentTask).getTargetAsset(); if (assetObj != null) { localNotification.CleanNotification(); ParseXML(assetObj.ToString()); //LogSys.Log("load config success :" + xmlPath); } else { LogSys.LogError("load config failed:" + xmlPath); } }); }
static public int sendMessage(IntPtr state) { luaProtobuf self = (luaProtobuf)LuaObject.checkSelf(state); //消息ID int idMsg = LuaDLL.luaL_checkinteger(state, 2); //消息内容 LuaTypes type = LuaDLL.lua_type(state, 3); if (type != LuaTypes.LUA_TTABLE) { LogSys.LogError("LUA message error! idMsg = " + idMsg.ToString()); return(0); } LuaTable msgTbl = (LuaTable)LuaObject.checkVar(state, 3); //生成消息 luaMessage msg = luaProtoHelper.readLuaMessage(idMsg, msgTbl); //写入流并发出 using (var stream = new System.IO.MemoryStream()) { using (var protoWriter = new luaProtoWriter(stream)) { protoWriter.writeLuaMessage(msg); protoWriter.close(); } network.protobuf.ClientNetwork.Instance.SendLuaMsg(idMsg, stream); } LuaObject.pushValue(state, true); return(1); }
/// <summary> /// 解析xml数据 /// </summary> /// <param name="Config">xml文件字符串</param> public void ParseXML(byte[] ConfigByte) { string Config = System.Text.Encoding.UTF8.GetString(ConfigByte); SecurityParser SP = new SecurityParser(); SecurityElement SE = null; try { SP.LoadXml(Config); SE = SP.ToXml(); } catch (System.Exception ex) { LogSys.LogError(ex.Message + " " + _fileName + " 加载配置文件错误!!!!!!!!!!!!!!!!!"); return; } foreach (SecurityElement child in SE.Children) { string itemKey = ""; T item = new T(); try { item.Parse(child); itemKey = item.GetKey(); if (string.IsNullOrEmpty(item.GetKey())) { LogSys.LogError("key is empty! file: " + _fileName); } ConfigDataDic.Add(item.GetKey(), item); } catch (Exception e) { LogSys.LogError(string.Format("配置表出错 fileName:[{0}] key:[{1}] error:{2}", _fileName, item.GetKey(), e.Message)); } } }
/// <summary> /// 获取配置数据 /// </summary> /// <param name="type">配置数据类型</param> /// <returns>配置数据类</returns> public ConfigDataCommon GetData(ConfigDataType type) { if (allConfigData == null) { return(null); } if (!allConfigData.ContainsKey(type)) { LogSys.LogError("key don't exist " + type); return(null); } return(allConfigData[type]); }
public T GetArg <T>(string key, T defaultValue) { if (dicArgsValue.ContainsKey(key)) { object val = dicArgsValue[key]; if (val is T) { return((T)val); } LogSys.LogError("GetArg Error!! the event arg '" + key + "' type is " + val.GetType() + " not " + defaultValue.GetType()); } else { LogSys.LogError("GetArg Error!! the event arg '" + key + "' not exist"); } return(defaultValue); }
/* * void Update() * { * if (_javaObj != null) * messsage = _javaObj.CallStatic<string>("GetLOG"); * } * * void OnGUI() * { * if (GUI.Button(new Rect(20, 20, 100, 100), "Save")) * { * //SaveScreenshot(); * * playVideo("threecountrycg.mov", 1136, 640, 1); * } * * if (GUI.Button(new Rect(20, 250, 100, 100), "Copy")) * { * //_javaObj.CallStatic("Copy", "sssssssa"); * * playVideo("newbieguide1.mp4", 1136, 640, 1); * } * * if (GUI.Button(new Rect(20, 400, 100, 100), "Paste")) * { * //_javaObj.CallStatic<string>("Paste"); * * playVideo("newbieguide3.mp4", 1136, 640, 1); * } * * //GUI.TextField(new Rect(0, Screen.height - 100, Screen.width, 100), messsage); * * } * */ /// <summary> /// 开启推送服务器 /// </summary> public void startLocalNotification() { string xmlPath = "Config/localNotification.json"; AssetLoadTask task = new AssetLoadTask(xmlPath, null); task.EventFinished += new task.TaskBase.FinishedHandler(delegate(bool manual, TaskBase currentTask) { UnityEngine.Object assetObj = ((AssetLoadTask)currentTask).getTargetAsset(); if (assetObj != null) { _javaSysUtilsOptObj.Call("startPushNotificationService", assetObj.ToString()); } else { LogSys.LogError("load config failed:" + xmlPath); } }); }
private static void checkConfig() { foreach (var item in ModelDataProcess._dicModelData) { ModelData cfg = item.Value; for (int i = 0; i < cfg._listAnimations.Count; i++) { int animateID = Convert.ToInt32(cfg._listAnimations[i]); if (((animateID >= 300 && animateID <= 400) || animateID >= 1000 ) && !cfg._dicAnimLoop[animateID.ToString()]) { int index = cfg._listAnimEvents.FindIndex(dd => dd._nAnimID == animateID); if (index >= 0) { if (cfg._listAnimEvents[index]._listEvents.Count > 0) { continue; } } LogSys.LogError(string.Format("没有关键帧 {0} {1}", cfg._strAssetName, animateID)); } } //cfg._listAnimEvents; } }
public T GetArg <T>(string key) { if (dicArgsValue.ContainsKey(key)) { object val = dicArgsValue[key]; if (val is T) { return((T)val); } if (key != "EVENT_ID") { uint id = GetArg <uint>("EVENT_ID"); LogSys.LogError("GetArg Error!! the event " + id + "arg type error: '" + key + "' type is " + val.GetType() + ", not " + default(T).GetType()); } } else { LogSys.LogError("GetArg Error!! the event arg '" + key + "' not exist"); } return(default(T)); }
public static void excute() { //if (isInit) //return; //isInit = true; _dicModelData.Clear(); //读取INI文件 if (!File.Exists(Application.dataPath + "/Resources/AnimationClipConfig.ini")) { LogSys.LogError("配置文件不存在 " + Application.dataPath + "/Resources/AnimationClipConfig.ini"); return; } string iniPath = "Assets/Resources/AnimationClipConfig.ini"; IniFiles pIniFile = new IniFiles(iniPath); if (pIniFile != null) { StringCollection strCollect = new StringCollection(); pIniFile.ReadSections(strCollect); foreach (object obj in strCollect) { string strSectionName = obj as string; //读取节点 NameValueCollection valueCollection = new NameValueCollection(); pIniFile.ReadSectionValues(strSectionName, valueCollection); //创建ModelInfo ModelData tempModel = new ModelData(strSectionName); //保存每个动作的开始帧,用于计算事件的时间 Dictionary <string, int> startFrameDic = new Dictionary <string, int>(); Dictionary <string, int> endFrameDic = new Dictionary <string, int>(); //遍历取key-value string strModelName = ""; string strAnimationID = ""; foreach (string key in valueCollection.AllKeys) { //Debug.Log(key + ", " + valueCollection[key]); string strValue = valueCollection[key]; //模型名字 if (key.Contains("modelname")) { strModelName = strValue; tempModel._strModelName = strModelName; //Debug.Log(valueCollection[key]); } else if (key.Contains("anim")) { string strAnimID = key.Substring(key.LastIndexOf('_') + 1); strAnimationID = strSectionName + "_" + strAnimID; string[] split = strValue.Split(new char[] { ',' }); int nStartFrame = Convert.ToInt32(split[0]); int nEndFrame = Convert.ToInt32(split[1]); bool bLoop = Convert.ToBoolean(split[2]); //Debug.Log("" + nStartFrame + ", " + nEndFrame + ", " + Convert.ToString(bLoop)); tempModel._dicAnimLoop[strAnimID] = bLoop; AnimClipInfo pAnimClip = new AnimClipInfo(strAnimationID, nStartFrame, nEndFrame, bLoop); tempModel._listAnimClips.Add(pAnimClip); tempModel._listAnimations.Add(strAnimID); startFrameDic.Add(key, nStartFrame); endFrameDic.Add(key, nEndFrame); if (ModelBindTest.bCheckModel) { if (nStartFrame >= nEndFrame) { LogSys.LogError(string.Format("动作起始错误 {0} {1}", tempModel._strAssetName, strAnimID)); } } } else if (key.Contains("event")) //事件 { string strAnimID = key.Substring(key.LastIndexOf('_') + 1); string animKey = "anim_" + strAnimID; if (startFrameDic.ContainsKey(animKey)) { //Debug.Log(strValue); int nAnimStartFrame = startFrameDic[animKey]; AnimEventInfo animEventInfo = new AnimEventInfo(Convert.ToInt32(strAnimID)); string[] arrEvents = strValue.Split(new char[] { ',' }); for (int i = 0; i < arrEvents.Length; i++) { string[] arrStrEventData = arrEvents[i].Split(new char[] { '-' }); int nKeyFrame = Convert.ToInt32(arrStrEventData[0]); string strEventID = arrStrEventData[1]; if (ModelBindTest.bCheckModel) { int nAnimEndFrame = endFrameDic[animKey]; if (nKeyFrame < nAnimStartFrame || nKeyFrame > nAnimEndFrame) { LogSys.LogError(string.Format("关键帧错误 {0} {1}", tempModel._strAssetName, animKey)); } } //Debug.Log(nKeyFrame); if (nKeyFrame > nAnimStartFrame) //触发帧要大于起始帧 { animEventInfo.insertValuePair(nKeyFrame - nAnimStartFrame, strEventID); } } tempModel._listAnimEvents.Add(animEventInfo); } } else if (key.Contains("bps")) { string[] arrBps = strValue.Split(new char[] { ',' }); for (int i = 0; i < arrBps.Length; i++) { tempModel._listModelBps.Add(arrBps[i]); } } else if (key.Contains("init")) { bool bInit = Convert.ToBoolean(strValue); tempModel.InitFlag = bInit; } else if (key.Contains("colliderType")) { tempModel._nColliderType = Convert.ToInt32(strValue); } else if (key.Contains("colliderParams")) { string[] arrCP = strValue.Split(new char[] { ',' }); for (int i = 0; i < arrCP.Length; i++) { tempModel._nColliderParams.Add(float.Parse(arrCP[i])); } } else if (key.Contains("colliderCenter")) { string[] arrCP = strValue.Split(new char[] { ',' }); for (int i = 0; i < arrCP.Length; i++) { tempModel._nColliderCenter.Add(float.Parse(arrCP[i])); } } } //添加到列表 _dicModelData[strSectionName] = tempModel; } } else { Debug.LogError("Model configure file is not exist!!"); } }
/// <summary> /// 载入xml配置 /// </summary> public override void LoadXML() { string xmlPath = _configPath + _fileName; // Object assets = AssetManager.getInstance().loadXML(xmlPath);//同步加载XML // if (assets != null) { // ParseXML(assets.ToString()); // LogSys.Log("load config success :" + xmlPath); // } //if (AssetManager.getInstance().IsFirstUseStreamingAssets) if (AssetManager.getInstance().IsStreamingAssets(xmlPath)) { xmlPath = UtilTools.PathCheck(xmlPath); AssetBundleLoadTask task = new AssetBundleLoadTask(xmlPath, null); task.EventFinished += new task.TaskBase.FinishedHandler(delegate(bool manual, TaskBase currentTask) { TextAsset assetObj = ((AssetBundleLoadTask)currentTask).getTargetAsset() as TextAsset; if (assetObj != null) { byte[] text_byte = assetObj.bytes; if (UtilTools.ArrayHeadIsWoDong(assetObj.bytes)) { CMyEncryptFile _encrypte = new CMyEncryptFile(); text_byte = _encrypte.Decrypt(assetObj.bytes, assetObj.bytes.Length); } ParseXML(text_byte); //LogSys.Log("load config success :" + xmlPath); } else { LogSys.LogError("load config failed:" + xmlPath); } _bLoadedXML = true; }); } else { AssetLoadTask task = new AssetLoadTask(xmlPath, null); task.EventFinished += new task.TaskBase.FinishedHandler(delegate(bool manual, TaskBase currentTask) { TextAsset assetObj = ((AssetLoadTask)currentTask).getTargetAsset() as TextAsset; if (assetObj != null) { byte[] text_byte = assetObj.bytes; if (UtilTools.ArrayHeadIsWoDong(assetObj.bytes)) { CMyEncryptFile _encrypte = new CMyEncryptFile(); text_byte = _encrypte.Decrypt(assetObj.bytes, assetObj.bytes.Length); } float start_time = Time.realtimeSinceStartup; ParseXML(text_byte); //Utils.LogSys.Log(string.Format("{0:0.00}", Time.realtimeSinceStartup - start_time) + " parse :" + currentTask._taskName); //LogSys.Log("load config success :" + xmlPath); } else { LogSys.LogError("load config failed:" + xmlPath); } _bLoadedXML = true; }); } }
static void CheckModel(){ bCheckModel = true; //加载配置 ModelDataProcess.excute(); bCheckModel = false; //检测配置文件 checkConfig(); if (!Directory.Exists(modelPath)) { LogSys.LogError("无法检测模型,不存在文件夹 " + modelPath); return; } string[] files = Directory.GetFiles(modelPath); _listElementError.Clear(); //文件的数量 int fileNum = files.Length; if (fileNum == 0) { LogSys.LogError("文件夹下没有任何模型 " + modelPath); return; } foreach (var item in ModelDataProcess._dicModelData) { bool result = true; string modelId = item.Key; _curModelId = modelId; ModelData cfg = item.Value; //测试绑点 List<string> listBindError = new List<string>(); UnityEngine.Object obj = Resources.Load("Models/" + modelId); if (obj != null) { GameObject go = GameObject.Instantiate(obj) as GameObject; for (int i = 0; i < cfg._listModelBps.Count; i++) { string bp = cfg._listModelBps[i]; if (!getBp(go.transform, bp)) { listBindError.Add(bp); result = false; } } result = checkElement(go.transform); if (listBindError.Count > 0) { string bindError = ""; for (int i = 0; i < listBindError.Count; i++) { bindError += " [" + listBindError[i] + "] "; } Utils.LogSys.LogError(string.Format("绑点缺失 {0} {1}", modelId, bindError)); } GameObject.DestroyImmediate(go); Utils.LogSys.Log("正确 " + modelId); } } }