예제 #1
0
        //发送请求移动消息
        //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() < 1)
                {
                    ret.AddBool(false);
                    return(false);
                }

                int mode    = args.GetInt(0);
                int arg_num = args.GetCount() - 1;

                StoreArchive ar = StoreArchive.Load(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(1 + i);
                    ar.WriteFloat(value);
                }

                return(m_sender.Send(ar.GetData(), ar.GetLength()));
            }
            catch (System.Exception ex)
            {
                LogSystem.LogError(ex);
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// 服务器定位消息
        /// </summary>
        /// <param name="data"></param>
        /// <param name="len"></param>
        /// <returns></returns>
        private int proc_server_location(ref Byte[] data, int len)
        {
            if (len < 16)
            {
                return(len);
            }

            LoadArchive arLoad = LoadArchive.Load(data, len);
            // Byte[] buffer = new Byte[1024];
            StoreArchive arStore = StoreArchive.Load(m_pBuffer_SP, 4096);

            uint nMsgType = 0;

            arLoad.ReadUInt8(ref nMsgType);
            arStore.WriteUInt8(nMsgType);

            ObjectID objectId = ObjectID.zero;

            arLoad.ReadObject(ref objectId);
            arStore.WriteObject(objectId);

            int x = 0;

            arLoad.ReadInt16(ref x);
            arStore.WriteFloat(x / 100.0f);

            int y = 0;

            arLoad.ReadInt16(ref y);
            arStore.WriteFloat(y / 100.0f);

            int z = 0;

            arLoad.ReadInt16(ref z);
            arStore.WriteFloat(z / 100.0f);

            int orient = 0;

            arLoad.ReadInt16(ref orient);
            arStore.WriteFloat(orient / 100.0f);

            data = arStore.GetData();
            return(arStore.GetLength());
        }
예제 #3
0
        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);
        }
예제 #4
0
        //发送请求移动消息
        //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);
            }
        }
예제 #5
0
        bool AddMsgVarList(ref StoreArchive storeAr, ref VarList args,
                           int beg, int end)
        {
            try
            {
                for (int i = beg; i < end; i++)
                {
                    switch (args.GetType(i))
                    {
                    case VarType.Int:
                    {
                        storeAr.WriteInt8(VarType.Int);
                        storeAr.WriteInt32(args.GetInt(i));
                    }
                    break;

                    case VarType.Int64:
                    {
                        storeAr.WriteInt8(VarType.Int64);
                        storeAr.WriteInt64(args.GetInt64(i));
                    }
                    break;

                    case VarType.Float:
                    {
                        storeAr.WriteInt8(VarType.Float);
                        storeAr.WriteFloat(args.GetFloat(i));
                    }
                    break;

                    case VarType.Double:
                    {
                        storeAr.WriteInt8(VarType.Double);
                        storeAr.WriteDouble(args.GetDouble(i));
                    }
                    break;

                    case VarType.String:
                    {
                        storeAr.WriteInt8(VarType.String);
                        storeAr.WriteString(args.GetString(i));
                    }
                    break;

                    case VarType.WideStr:
                    {
                        storeAr.WriteInt8(VarType.WideStr);
                        storeAr.WriteWideStr(args.GetWideStr(i));
                    }
                    break;

                    case VarType.Object:
                    {
                        storeAr.WriteInt8(VarType.Object);
                        storeAr.WriteObject(args.GetObject(i));
                    }
                    break;

                    default:
                        //Log.Trace("unkown data type");
                        break;
                    } //end switch
                }     //end for
            }
            catch (Exception ex)
            {
                //Log.Trace("Exception:" + ex.ToString());
                return(false);
            }//end try catch
            return(true);
        }
예제 #6
0
        /// <summary>
        /// 服务器所有目标点移动
        /// </summary>
        /// <param name="data"></param>
        /// <param name="len"></param>
        /// <returns></returns>
        private int proc_server_all_dest(ref Byte[] data, int len)
        {
            LoadArchive arLoad = LoadArchive.Load(data, len);
            // Byte[] buffer = new Byte[1024];
            StoreArchive arStore = StoreArchive.Load(m_pBuffer_SP, 4096);

            uint nMsgType = 0;

            arLoad.ReadUInt8(ref nMsgType);
            arStore.WriteUInt8(nMsgType);

            uint nCount = 0;

            arLoad.ReadUInt16(ref nCount);
            arStore.WriteUInt16(nCount);

            if (nCount > 50)
            {
                LogSystem.Log("proc_server_all_dest");
                return(len);
            }
            for (int i = 0; i < nCount; ++i)
            {
                ObjectID objectId = ObjectID.zero;
                arLoad.ReadObject(ref objectId);
                arStore.WriteObject(objectId);

                int x = 0;
                arLoad.ReadInt16(ref x);
                arStore.WriteFloat(x / 100.0f);

                int y = 0;
                arLoad.ReadInt16(ref y);
                arStore.WriteFloat(y / 100.0f);

                int z = 0;
                arLoad.ReadInt16(ref z);
                arStore.WriteFloat(z / 100.0f);

                int orient = 0;
                arLoad.ReadInt16(ref orient);
                arStore.WriteFloat(orient / 100.0f);

                int moveSpeed = 0;
                arLoad.ReadInt16(ref moveSpeed);
                arStore.WriteFloat(moveSpeed / 100.0f);

                int rotateSpeed = 0;
                arLoad.ReadInt16(ref rotateSpeed);
                arStore.WriteFloat(rotateSpeed / 100.0f);

                int jumpSpeed = 0;
                arLoad.ReadInt16(ref jumpSpeed);
                arStore.WriteFloat(jumpSpeed / 100.0f);

                int gravity = 0;
                arLoad.ReadInt16(ref gravity);
                arStore.WriteFloat(gravity / 100.0f);

                int mode = 0;
                arLoad.ReadInt32(ref mode);
                arStore.WriteInt32(mode);
            }


            data = arStore.GetData();
            return(arStore.GetLength());
        }
예제 #7
0
        /// <summary>
        /// 服务器移动消息
        /// </summary>
        /// <param name="data"></param>
        /// <param name="len"></param>
        /// <returns></returns>
        private int proc_server_moving(ref Byte[] data, int len)
        {
            if (len < 28)
            {
                return(len);
            }

            LoadArchive arLoad = LoadArchive.Load(data, len);
            // Byte[] buffer = new Byte[1024];
            StoreArchive arStore = StoreArchive.Load(m_pBuffer_SP, 4096);

            uint nMsgType = 0;

            arLoad.ReadUInt8(ref nMsgType);
            arStore.WriteUInt8(nMsgType);

            ObjectID objectId = ObjectID.zero;

            arLoad.ReadObject(ref objectId);
            arStore.WriteObject(objectId);

            int x = 0;

            arLoad.ReadInt16(ref x);
            arStore.WriteFloat(x / 100.0f);

            int y = 0;

            arLoad.ReadInt16(ref y);
            arStore.WriteFloat(y / 100.0f);

            int z = 0;

            arLoad.ReadInt16(ref z);
            arStore.WriteFloat(z / 100.0f);

            int orient = 0;

            arLoad.ReadInt16(ref orient);
            arStore.WriteFloat(orient / 100.0f);

            int moveSpeed = 0;

            arLoad.ReadInt16(ref moveSpeed);
            arStore.WriteFloat(moveSpeed / 100.0f);

            int rotateSpeed = 0;

            arLoad.ReadInt16(ref rotateSpeed);
            arStore.WriteFloat(rotateSpeed / 100.0f);

            int jumpSpeed = 0;

            arLoad.ReadInt16(ref jumpSpeed);
            arStore.WriteFloat(jumpSpeed / 100.0f);

            int gravity = 0;

            arLoad.ReadInt16(ref gravity);
            arStore.WriteFloat(gravity / 100.0f);

            int mode = 0;

            arLoad.ReadInt32(ref mode);
            arStore.WriteInt32(mode);

            data = arStore.GetData();
            return(arStore.GetLength());
        }