// wstring //public bool SetValue(int row, int col, string result) //{ // if (row >= GetRowCount() || col >= GetColcount() || row < 0 || col < 0) // { // return false; // } // VarList rowItem = rowSet[row]; // if (rowItem == null) // { // return false; // } // if (col < rowItem.GetCount()) // { // rowItem.SetString(col, result); // } // else // { // rowItem.AddString(result); // } // return true; //} // OBJECITID public bool SetValue(int row, int col, ObjectID result) { if (row >= GetRowCount() || col >= GetColcount() || row < 0 || col < 0) { return(false); } VarList rowItem = rowSet[row]; if (rowItem == null) { return(false); } if (col < rowItem.GetCount()) { rowItem.SetObject(col, result); } else { rowItem.AddObject(result); } return(true); }
public void GetObjectList(ref VarList result) { if (result == null) { return; } foreach (KeyValuePair <ObjectID, GameObj> kvp in mObjects) { GameObj obj = kvp.Value; if (obj != null && (!obj.GetIdent().IsNull())) { result.AddObject(obj.GetIdent()); } } }
/// <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; } } }
public void GetRoleInfo(ref VarList args, ref VarList ret) { try { if (mRoles == null || mRoles.Count == 0) { return; } if (args == null || ret == null) { return; } if (args.GetCount() == 0) { return; } if (args.GetType(0) != VarType.Int) { return; } int nIndex = args.GetInt(0); if (nIndex >= mRoles.Count) { return; } VarList paraList = mRoles[nIndex].paraList; for (int i = 0; i < paraList.GetCount(); i++) { switch (paraList.GetType(i)) { case VarType.Bool: { ret.AddBool(paraList.GetBool(i)); } break; case VarType.Int: { ret.AddInt(paraList.GetInt(i)); } break; case VarType.Int64: { ret.AddInt64(paraList.GetInt64(i)); } break; case VarType.Float: { ret.AddFloat(paraList.GetFloat(i)); } break; case VarType.Double: { ret.AddDouble(paraList.GetDouble(i)); } break; case VarType.String: { ret.AddString(paraList.GetString(i)); } break; case VarType.WideStr: { ret.AddWideStr(paraList.GetWideStr(i)); } break; case VarType.Object: { ret.AddObject(paraList.GetObject(i)); } break; default: return; } } } catch (Exception ex) { //Log.Trace("GameReceiver.GetRoleInfo Exception:" + ex.ToString()); } return; }
public bool SetValue(int row, int col, Var result) { try { if (row >= GetRowCount() || col >= GetColcount() || row < 0 || col < 0) { return(false); } if (null == result) { return(false); } VarList rowItem = rowSet[row]; if (rowItem == null) { return(false); } if (col > rowItem.GetCount()) { //Log.Trace("col error col=" + col.ToString()); return(false); } switch (result.Type) { case VarType.Int: { if (col < rowItem.GetCount()) { rowItem.SetInt(col, result.GetInt()); } else { rowItem.AddInt(result.GetInt()); } } break; case VarType.Int64: { if (col < rowItem.GetCount()) { rowItem.SetInt64(col, result.GetInt64()); } else { rowItem.AddInt64(result.GetInt64()); } } break; case VarType.Float: { if (col < rowItem.GetCount()) { rowItem.SetFloat(col, result.GetFloat()); } else { rowItem.AddFloat(result.GetFloat()); } } break; case VarType.Double: { if (col < rowItem.GetCount()) { rowItem.SetDouble(col, result.GetDouble()); } else { rowItem.AddDouble(result.GetDouble()); } } break; case VarType.String: { if (col < rowItem.GetCount()) { rowItem.SetString(col, result.GetString()); } else { rowItem.AddString(result.GetString()); } } break; case VarType.WideStr: { if (col < rowItem.GetCount()) { rowItem.SetWideStr(col, result.GetWideStr()); } else { rowItem.AddWideStr(result.GetWideStr()); } } break; case VarType.Object: { if (col < rowItem.GetCount()) { rowItem.SetObject(col, result.GetObject()); } else { rowItem.AddObject(result.GetObject()); } } break; default: //Log.Trace("typer error type=" + result.Type.ToString()); return(false); }//end switch //rowSet[row] = rowItem; //int nCount = rowItem.GetCount(); return(true); } catch (Exception ex) { Log.TraceExcep(ref ex); return(false); } }
//添加一个参数 public static void AddObjectArgs(ref VarList args, ref object o) { System.Type itype = o.GetType(); if (itype == typeof(bool)) { args.AddBool((bool)o); } else if (itype == typeof(int)) { args.AddInt((int)o); } else if (itype == typeof(long)) { args.AddInt64((long)o); } else if (itype == typeof(float)) { args.AddFloat((float)o); } else if (itype == typeof(double)) { args.AddDouble((double)o); } else if (itype == typeof(ObjectID)) { args.AddObject((ObjectID)o); } else if (itype == typeof(string)) { args.AddString((string)o); } else if (itype == typeof(byte[])) { args.AddUserData((byte[])o); } else if (itype == typeof(WideString)) { args.AddWideStr(((WideString)o).mstrContent); } else if (itype == typeof(VarList)) { int iCount = ((VarList)o).GetCount(); for (int j = 0; j < iCount; j++) { switch (((VarList)o).GetType(j)) { case VarType.Bool: args.AddBool(((VarList)o).GetBool(j)); break; case VarType.Int: args.AddInt(((VarList)o).GetInt(j)); break; case VarType.Int64: args.AddInt64(((VarList)o).GetInt64(j)); break; case VarType.Float: args.AddFloat(((VarList)o).GetFloat(j)); break; case VarType.Double: args.AddDouble(((VarList)o).GetDouble(j)); break; case VarType.String: args.AddString(((VarList)o).GetString(j)); break; case VarType.WideStr: args.AddWideStr(((VarList)o).GetWideStr(j)); break; case VarType.Object: args.AddObject(((VarList)o).GetObject(j)); break; case VarType.UserData: args.AddUserData(((VarList)o).GetUserData(j)); break; } } } }
private bool InnerRecvProperty(GameObj obj, LoadArchive loadAr, int count, bool change) { VarList.VarData key = new VarList.VarData(); for (int i = 0; i < count; i++) { int index = 0; if (!loadAr.ReadInt16(ref index)) { return(false); } if (index >= mPropertyTable.Count) { return(false); } PropData propData = GetPropDataByIndex(index); if (propData == null) { return(false); } propData.nCount = propData.nCount + 1; if (!InnerParsePropValue(loadAr, propData.nType, ref key)) { return(false); } if (!obj.UpdateProperty(ref propData.strName, key)) { return(false); } if (change) { VarList argList = new VarList(); argList.AddObject(obj.GetIdent()); argList.AddString(propData.strName); Excute_CallBack("on_object_property_change", argList); } } return(true); }