/* @brief: 视窗对象属性变化回调 * @param: args 回调参数 * @return void */ public static void on_view_object_property_change(VarList args) { string strViewID = args.GetString(0); string strObjID = args.GetString(1); string strName = args.GetString(2); List <IDataView> iDataView; if (mViews.TryGetValue(strViewID, out iDataView) && iDataView != null) { for (int i = 0; i < iDataView.Count; i++) { if (iDataView[i] != null) { try { iDataView[i].on_view_object_property_change(strViewID, strObjID, strName); } catch (System.Exception e) { LogSystem.LogError(e.ToString()); } } } } }
/* @brief:表数据单行中列数据改变消息入口点 * @param: args 该事件参数列表 * @return void */ public static void on_viewobj_record_single_grid(VarList args) { string strViewID = args.GetString(0); string strViewIndex = args.GetString(1); string strRecordName = args.GetString(2); int iRow = args.GetInt(3); int iCol = args.GetInt(4); if (!mViewObjRecords.ContainsKey(strViewID)) { return; } Dictionary <string, Dictionary <string, List <IRecord> > > dicRecord; if (mViewObjRecords.TryGetValue(strViewID, out dicRecord) && dicRecord != null) { Dictionary <string, List <IRecord> > _dicRecord; if (dicRecord.TryGetValue(strViewIndex, out _dicRecord) && _dicRecord != null) { List <IRecord> iRecord; if (_dicRecord.TryGetValue(strRecordName, out iRecord) && iRecord != null) { for (int i = 0; i < iRecord.Count; i++) { if (iRecord[i] != null) { try { iRecord[i].on_record_single_grid(strRecordName, iRow, iCol); } catch (System.Exception e) { LogSystem.LogError(e.ToString()); } } } } } } ///分发数据类信息 ARecord aRecord; if (mDataRecords.TryGetValue(strRecordName, out aRecord) && aRecord != null) { try { aRecord.on_record_single_grid(strRecordName, iRow, iCol); } catch (System.Exception e) { LogSystem.LogError(e.ToString()); } } }
/* * @brief: 对象属性变化事件入口点 * @param: args 该事件相应参数列表 * @return void */ public static void on_object_property_change(VarList args) { string strIdent = args.GetString(0); string strPropName = args.GetString(1); IObject cObj; if (mObjectsDic.TryGetValue(strIdent, out cObj) && cObj != null) { cObj.OnObjectPropertyChange(strPropName); //BindPropManager.CallBackProp(cObj, strPropName); } }
/* @brief:表数据单行添加消息入口点 * @param: args 该事件参数列表 * @return void */ public static void on_view_record_add_row(VarList args) { string strViewID = args.GetString(0); string strRecordName = args.GetString(1); int iRow = args.GetInt(2); int iRows = args.GetInt(3); //LogSystem.Log(strViewID, strRecordName, iRow, iRows); if (!mViewRecords.ContainsKey(strViewID)) { return; } Dictionary <string, List <IRecord> > dicRecord; if (mViewRecords.TryGetValue(strViewID, out dicRecord) && dicRecord != null) { List <IRecord> iRecord; if (dicRecord.TryGetValue(strRecordName, out iRecord) && iRecord != null) { for (int i = 0; i < iRecord.Count; i++) { if (iRecord[i] != null) { try { iRecord[i].on_record_add_row(strRecordName, iRow, iRows); } catch (System.Exception e) { LogSystem.LogError(e.ToString()); } } } } } ///分发数据类信息 ARecord aRecord; if (mDataRecords.TryGetValue(strRecordName, out aRecord) && aRecord != null) { try { aRecord.on_record_add_row(strRecordName, iRow, iRows); } catch (System.Exception e) { LogSystem.LogError(e.ToString()); } } }
/* @brief: 分发表格清除消息 * @param:回调参数列表 * @return void */ public static void onTableClear(VarList args) { int index = 2; string tableName = args.GetString(index++); List <ITable> iTabel; if (mRecords.TryGetValue(tableName, out iTabel) && iTabel != null && mRecordCols.ContainsKey(tableName)) { for (int i = 0; i < iTabel.Count; i++) { if (iTabel[i] != null) { try { iTabel[i].on_table_clear(tableName, args, index); } catch (System.Exception e) { LogSystem.LogError(e.ToString()); } } } } }
/// <summary> /// 自动根据类型读取index位置的数据 返回值为string /// </summary> /// <param name="args"></param> /// <param name="index"></param> /// <returns></returns> public static string GetVarList(VarList args, int index) { int type = args.GetType(index); switch (type) { case VarType.Bool: return(args.GetBool(index) ? "true" : "false"); case VarType.Int: return(args.GetInt(index).ToString()); case VarType.String: return(args.GetString(index)); case VarType.WideStr: return(args.GetWideStr(index)); case VarType.Object: return(args.GetObject(index).ToString()); case VarType.Float: return(args.GetFloat(index).ToString()); case VarType.Double: return(args.GetDouble(index).ToString()); case VarType.Int64: return(args.GetInt64(index).ToString()); default: return("null"); } }
/* @brief:表数据单行数据改变消息入口点 * @param: args 该事件参数列表 * @return void */ public static void on_record_grid(VarList args) { string strRecordName = args.GetString(1); int iCount = args.GetInt(2); List <IRecord> iRecord; if (mRecords.TryGetValue(strRecordName, out iRecord) && iRecord != null) { for (int i = 0; i < iRecord.Count; i++) { if (iRecord[i] != null) { try { iRecord[i].on_record_grid(strRecordName, iCount); } catch (System.Exception e) { LogSystem.LogError(e.ToString()); } } } } }
/// <summary> /// 服务器自动将玩家踢出游戏 /// </summary> /// <param name="args"></param> public static void on_game_out(VarList args) { int p = 2; string content = args.GetString(p++); ConnectStage.isGameOut = true; // if (!GUIManager.HasView<SystemPrompt>()) // { // GUIManager.ShowView<SystemPrompt>(); // } // GUIManager.CallViewFunc<SystemPrompt>((IView view) => // { // SystemPrompt pPanel = view as SystemPrompt; // if (pPanel != null) // { // PromptType prompt = PoolManager.PopObject<PromptType>(PoolManager.PoolKey.Object_PromptType); // prompt.layer = 3; // prompt.title = TextManager.GetUIString("UI30108"); // prompt.content = TextManager.GetString(content); // prompt.style = PromptType.Style.OK; // prompt.callback_ok = OnSureGameOutClick; // pPanel.UpdateContent(prompt); // } // }); }
/* @brief: 分发表格删除指定内容消息 * @param:回调参数列表 * @return void */ public static void onTableDelete(VarList args) { int index = 2; string tableName = args.GetString(index++); int row = args.GetInt(index++); List <ITable> iTabel; if (mRecords.TryGetValue(tableName, out iTabel) && iTabel != null && mRecordCols.ContainsKey(tableName)) { int iCols = mRecordCols[tableName]; for (int i = 0; i < iTabel.Count; i++) { if (iTabel[i] != null) { try { iTabel[i].on_table_delete(tableName, args, row, (args.GetCount() - index) / iCols, iCols, index); } catch (System.Exception e) { LogSystem.LogError(e.ToString()); } } } } }
/* @brief: 格子系统移动位置 * @param: args 该事件相应参数列表 * @return void */ public static void on_moving_grid(VarList args) { string strIdent = args.GetString(0); IObject cObject = ObjectManager.FindObject(strIdent); if (cObject != null) { } }
public bool AddMsgVarList(StoreArchive ar, VarList args, int beg, int end) { try { for (int i = beg; i < end; ++i) { switch (args.GetType(i)) { case VarType.Int: ar.WriteInt8(VarType.Int); ar.WriteInt32(args.GetInt(i)); break; case VarType.Int64: ar.WriteInt8(VarType.Int64); ar.WriteInt64(args.GetInt64(i)); break; case VarType.Float: ar.WriteInt8(VarType.Float); ar.WriteFloat(args.GetFloat(i)); break; case VarType.Double: ar.WriteInt8(VarType.Double); ar.WriteDouble(args.GetDouble(i)); break; case VarType.String: ar.WriteInt8(VarType.String); ar.WriteString(args.GetString(i)); break; case VarType.WideStr: ar.WriteInt8(VarType.WideStr); ar.WriteWideStr(args.GetWideStr(i)); break; case VarType.Object: ar.WriteInt8(VarType.Object); ar.WriteObject(args.GetObject(i)); break; default: break; } } } catch (Exception ex) { LogSystem.LogError(ex.ToString()); return(false); } return(true); }
/* * @brief: 对象属性添加事件入口点 * @param: args 该事件相应参数列表 * @return void */ public static void on_object_property(VarList args) { string strIdent = args.GetString(0); IObject cobj; if (mObjectsDic.TryGetValue(strIdent, out cobj) && cobj != null) { cobj.OnObjectProperty(); } }
/* @brief: 对象添加事件入口点 * @param: args 该事件相应参数列表 * @return void */ public static void on_add_object(VarList args) { string strIdent = args.GetString(0); if (string.IsNullOrEmpty(strIdent)) { return; } CallAddObject(strIdent); }
/* @brief: 格子系统移动位置 * @param: args 该事件相应参数列表 * @return void */ public static void on_location_grid(VarList args) { string strIdent = args.GetString(0); IObject cObject = ObjectManager.FindObject(strIdent); if (cObject != null) { //cObject.on_location_grid(); //取格子位置,通知对象移动到制定的格子 } }
/// <summary> /// 文本协议Socket消息接受,只用于获取服务器列表数据 /// </summary> /// <param name="textSock"></param> /// <param name="args"></param> static void OnTextSockRecieveData(TextSock textSock, ref VarList args) { LogSystem.Log("OnTextSockRecieveData"); int count = args.GetCount(); if (count <= 0) { LogSystem.Log("OnTextSockRecieveData param null"); return; } ///消息头 string strHeader = args.GetString(0); LogSystem.Log("OnTextSockRecieveData", strHeader); if (strHeader.Equals("svrlist")) { ///服务器列表 string strServerName = args.GetString(1); string strMemberAddr = args.GetString(2); int nMemberPort = args.GetInt(3); int iLoad = args.GetInt(4); LogSystem.Log(strServerName, "|", strMemberAddr, "|", nMemberPort, "|", iLoad); textSock.Disconnect(); if (string.IsNullOrEmpty(strServerName)) { mstrMemberAddress = strMemberAddr; mstrMemberPort = nMemberPort; miRecieveMemberType = -2; } else { mstrMemberAddress = strMemberAddr; mstrMemberPort = nMemberPort; miRecieveMemberType = 1; } } else if (strHeader.Equals("version_error")) { miRecieveMemberType = 2; } }
//发送请求移动消息 //public bool RequestMove(int mode, int arg_num, float[] args, string info) public bool RequestMove(ref VarList args, ref VarList ret) { try { if (args.GetCount() < 3) { //Log.Trace(" arguments count must be > 3"); ret.AddBool(false); return(false); } int mode = args.GetInt(0); int arg_num = args.GetInt(1); if (arg_num > 256) { //Log.Trace("more arguments"); ret.AddBool(false); return(false); } if (args.GetCount() < (arg_num + 2)) { //Log.Trace("too few arguments"); ret.AddBool(false); return(false); } StoreArchive ar = new StoreArchive(m_buffer, m_buffer.Length); ar.WriteInt8(GlobalClineMsgId.CLIENT_REQUEST_MOVE);//消息ID ar.WriteInt8(mode); ar.WriteInt16(arg_num); for (int i = 0; i < arg_num; i++) { float value = args.GetFloat(2 + i); ar.WriteFloat(value); } string info = ""; if (args.GetCount() > (arg_num + 2)) { info = args.GetString(arg_num + 2); } ar.WriteStringNoLen(info); return(m_sender.Send(ar.GetData(), ar.GetLength())); } catch (System.Exception ex) { Log.TraceExcep(ref ex); return(false); } }
/// <summary> /// 服务器发送计费串 /// </summary> /// <param name="args">参数列表</param> public static void on_charger_validstring(VarList args) { string strValidateString = args.GetString(0); if (strValidateString == null) { LogSystem.Log("//Debug strValidateString is null"); } else { //Game.Instance.SetValidateString(strValidateString); } }
/* @brief: 响应服务器同步位置事件入口 * @param: args 该事件相应参数列表 * @return void */ public static void on_location(VarList args) { string strIdent = args.GetString(0); IObject cobj; if (mObjectsDic.TryGetValue(strIdent, out cobj) && cobj != null) { cobj.OnLocation(); // 更新玩家AOI RangeTools.MotifyObjectAoi(mRole, cobj); } }
public static void PrintVarlist(string strTitle, VarList args, bool flag = false) { if (!flag) { return; } string str = UtilTools.StringBuilder("[", strTitle, " ", DateTime.Now.ToLongTimeString(), "]"); for (int i = 0; i < args.GetCount(); ++i) { switch (args.GetType(i)) { case VarType.Bool: str += (args.GetBool(i) ? "true" : "false"); break; case VarType.Int: str += args.GetInt(i); break; case VarType.String: str += args.GetString(i); break; case VarType.WideStr: str += args.GetWideStr(i); break; case VarType.Object: str += args.GetObject(i); break; case VarType.Int64: str += args.GetInt64(i); break; case VarType.Float: str += args.GetFloat(i); break; default: str += "unknown"; break; } str += " | "; } LogSystem.Log(str); }
/* * @brief: 对象删除前消息事件入口点 * @param: args 该事件相应参数列表 * @return void */ public static void on_before_remove_object(VarList args) { string strIdent = args.GetString(0); IObject cobj; if (mObjectsDic.TryGetValue(strIdent, out cobj) && cobj != null) { //BindPropManager.UnBindAllProp(strIdent); // if (cobj.mVisualTrans != null) // { // mObjTrans.Remove(cobj.mVisualTrans); // } // cobj.OnRemoveObjectBefore(false); } }
public string QueryString(int row, int col) { if (row >= GetRows() || col >= GetColCount()) { return(""); } VarList row_value = (VarList)rowSet[row]; if (row_value.GetType(col) != VarType.String) { return(""); } return(row_value.GetString(col)); }
/* @brief: 响应服务器移动事件入口 * @param: args 该事件相应参数列表 * @return void */ public static void on_moving(VarList args) { string strIdent = args.GetString(0); IObject cobj; if (mObjectsDic.TryGetValue(strIdent, out cobj) && cobj != null) { cobj.OnMoving(); // 更新玩家AOI RangeTools.MotifyObjectAoi(mRole, cobj); } else { LogSystem.LogWarning("Recive on_moving , but ", strIdent, " you can't find in mObjects"); } }
/* * @brief: 对象删除消息事件入口点 * @param: args 该事件相应参数列表 * @return void */ public static void on_remove_object(VarList args) { string strIdent = args.GetString(0); IObject obj = FindObject(strIdent); if (obj != null) { mObjectsDic.Remove(strIdent); //mObjects2.Remove(obj.miCreateID); obj.OnRemoveObject(); //if( mTalkTaskNpc == obj ) //{ // TimerManager.Destroy("TalkTask"); // mTalkTaskNpc = null; //} ObjAddOrRemoveChange.ExecuteCalls(obj, false); } }
/// <summary> /// 赋值VarList /// </summary> /// <param name="args"></param> /// <param name="index"></param> /// <param name="newList"></param> public static void CopyVarList(ref VarList args, ref VarList newList, int start, int count) { int index = start; for (; index < args.GetCount() && count > 0; index++, count--) { int type = args.GetType(index); switch (type) { case VarType.Bool: newList.AddBool(args.GetBool(index)); break; case VarType.Int: newList.AddInt(args.GetInt(index)); break; case VarType.String: newList.AddString(args.GetString(index)); break; case VarType.WideStr: newList.AddWideStr(args.GetWideStr(index)); break; case VarType.Object: newList.AddObject(args.GetObject(index)); break; case VarType.Float: newList.AddFloat(args.GetFloat(index)); break; case VarType.Double: newList.AddDouble(args.GetDouble(index)); break; case VarType.Int64: newList.AddInt64(args.GetInt64(index)); break; } } }
/* @brief:表数据单行中列数据改变消息入口点 * @param: args 该事件参数列表 * @return void */ public static void on_scene_record_single_grid(VarList args) { string strRecordName = args.GetString(0); int iRow = args.GetInt(1); int iCol = args.GetInt(2); List <IRecord> iRecord; if (mSceneRecords.TryGetValue(strRecordName, out iRecord) && iRecord != null) { for (int i = 0; i < iRecord.Count; i++) { if (iRecord[i] != null) { try { iRecord[i].on_record_single_grid(strRecordName, iRow, iCol); } catch (System.Exception e) { LogSystem.LogError(e.ToString()); } } } } ///分发数据类信息 ARecord aRecord; if (mDataRecords.TryGetValue(strRecordName, out aRecord) && aRecord != null) { try { aRecord.on_record_single_grid(strRecordName, iRow, iCol); } catch (System.Exception e) { LogSystem.LogError(e.ToString()); } } }
/* @brief:表数据清空消息入口点 * @param: args 该事件参数列表 * @return void */ public static void on_record_clear(VarList args) { string strRecordName = args.GetString(1); List <IRecord> iRecord; if (mRecords.TryGetValue(strRecordName, out iRecord) && iRecord != null) { for (int i = 0; i < iRecord.Count; i++) { if (iRecord[i] != null) { try { iRecord[i].on_record_clear(strRecordName); } catch (System.Exception e) { LogSystem.LogError(e.ToString()); } } } } ///分发数据类信息 ARecord aRecord; if (mDataRecords.TryGetValue(strRecordName, out aRecord) && aRecord != null) { try { aRecord.on_record_clear(strRecordName); } catch (System.Exception e) { LogSystem.LogError(e.ToString()); } } }
public string GetString(int row, int col) { try { if (row >= GetRowCount() || col >= GetColcount()) { return(""); } VarList row_value = (VarList)rowSet[row]; if (row_value.GetType(col) != VarType.String) { return(""); } return(row_value.GetString(col)); } catch (Exception ex) { Log.TraceExcep(ref ex); return(""); } }
public string GetString(int row, int col) { try { if (row >= GetRowCount() || col >= GetColcount()) { return(string.Empty); } VarList row_value = (VarList)rowSet[row]; if (row_value.GetType(col) != VarType.String) { return(string.Empty); } return(row_value.GetString(col)); } catch (Exception ex) { LogSystem.LogError(ex); return(string.Empty); } }
/// <summary> /// 文本协议Socket消息接受,只用于获取服务器列表数据 /// </summary> /// <param name="textSock"></param> /// <param name="args"></param> static void OnTextSockRecieveData(ServerStateSock textSock, ref VarList args) { LogSystem.Log("OnTextSockRecieveData"); instance.serverList.Clear(); int serverCount = args.GetInt(0); int index = 1; for (int i = 0; i < serverCount; i++) { string serverDataStr = args.GetString(index); index++; string[] dataArray = UtilTools.Split(serverDataStr, '/'); //LoginUI.ServerInfo info = new LoginUI.ServerInfo(); //info.mId = int.Parse(dataArray[0]); //info.mServerName = dataArray[1]; //info.mIp = dataArray[2]; //info.mPort = dataArray[3]; int state = UtilTools.IntParse(dataArray[6]); int service = UtilTools.IntParse(dataArray[5]); // if (instance.serverList.ContainsKey(info.Name)) // { // instance.serverList[info.Name] = info; // } // else // { // instance.serverList.Add(info.Name, info); // } } instance.dataIsReady = true; if (instance.onServerListOK != null) { instance.onServerListOK(true); } }
public void CloneObj(ref IGameObj obj, ref IGameObj cloneObj) { Dictionary <string, GameProperty> mPropSet = cloneObj.PropSets(); foreach (KeyValuePair <string, GameProperty> kvp in mPropSet) { string key = kvp.Key; obj.UpdateProperty(ref key, kvp.Value.propValue.Clone()); } VarList recordList = new VarList(); cloneObj.GetRecordList(ref recordList); int count = recordList.GetCount(); for (int i = 0; i < count; i++) { string recordName = recordList.GetString(i); GameRecord record = cloneObj.GetGameRecordByName(recordName).Clone(); obj.AddRecord2Set(recordName, ref record); } }