示例#1
0
        // double
        public bool SetValue(int row, int col, double 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.SetDouble(col, result);
            }
            else
            {
                rowItem.AddDouble(result);
            }

            return(true);
        }
示例#2
0
    /// <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;
            }
        }
    }
示例#3
0
        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;
        }
示例#4
0
        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);
            }
        }
示例#5
0
    //添加一个参数
    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;
                }
            }
        }
    }
示例#6
0
    //发送客户端自定义消息,请保留此功能,谢谢!
    public static bool SendCustomGM(string content)
    {
        if (mGameSender == null)
        {
            return(false);
        }

        VarList args = VarList.GetVarList();

        string[] split = content.Split(' ');
        int      len   = split.Length;

        if (len % 2 == 0)
        {
            for (int i = 0; i < len; ++i)
            {
                switch (split[i])
                {
                case "BOOL":
                    ++i;
                    args.AddBool(Convert.ToBoolean(split[i]));
                    break;

                case "INT":
                    ++i;
                    args.AddInt(Convert.ToInt32(split[i]));
                    break;

                case "INT64":
                    ++i;
                    args.AddInt64(Convert.ToInt64(split[i]));
                    break;

                case "FLOAT":
                    ++i;
                    args.AddFloat(Convert.ToSingle(split[i]));
                    break;

                case "DOUBLE":
                    ++i;
                    args.AddDouble(Convert.ToDouble(split[i]));
                    break;

                case "STRING":
                    ++i;
                    args.AddString(split[i]);
                    break;

                case "WIDESTR":
                    ++i;
                    args.AddWideStr(split[i]);
                    break;
                }
            }
        }

        if (mGameSender.Custom(ref args))
        {
            args.Collect();
            return(true);
        }
        args.Collect();
        return(false);
    }