Example #1
0
        /// <summary>
        /// 将远程调用的方法解码为EntityAttachedPluto调用。
        /// </summary>
        /// <param name="data">远程调用方法的二进制数组</param>
        /// <param name="unLen">数据偏移量</param>
        protected override void DoDecode(byte[] data, ref int unLen)
        {
            //ushort klen = (ushort)VUInt16.Instance.Decode(data, ref unLen);
            string key = (string)VString.Instance.Decode(data, ref unLen);

            EventDispatcher.TriggerEvent <string>(Events.FrameWorkEvent.ReConnectKey, key);
            var info = new BaseAttachedInfo();

            info.typeId = (ushort)VUInt16.Instance.Decode(data, ref unLen); //entity type id
            info.id     = (uint)VUInt32.Instance.Decode(data, ref unLen);   //entity unique id
            info.dbid   = (ulong)VUInt64.Instance.Decode(data, ref unLen);  //dbid
            var entity = DefParser.Instance.GetEntityByID(info.typeId);

            if (entity != null)
            {
                info.entity = entity;
                info.props  = new List <KeyValuePair <EntityDefProperties, object> >();
                while (unLen < data.Length)
                {//还有数据就解析
                    var index = (ushort)VUInt16.Instance.Decode(data, ref unLen);
                    EntityDefProperties prop;
                    var flag = entity.Properties.TryGetValue(index, out prop);
                    if (flag)
                    {
                        info.props.Add(new KeyValuePair <EntityDefProperties, object>(prop, prop.VType.Decode(data, ref unLen)));
                    }
                }
            }
            Arguments = new object[1] {
                info
            };
        }
Example #2
0
        /// <summary>
        ///     将远程调用的方法解码为EntityAttachedPluto调用。
        /// </summary>
        /// <param name="data">远程调用方法的二进制数组</param>
        /// <param name="unLen">数据偏移量</param>
        protected override void DoDecode(byte[] data, ref int unLen)
        {
            //ushort klen = (ushort)VUInt16.Instance.Decode(data, ref unLen);
            var info = new BaseAttachedInfo();

            info.typeId = (ushort)VUInt16.Instance.Decode(data, ref unLen); //entity type id
            info.id     = (uint)VUInt32.Instance.Decode(data, ref unLen);   //entity unique id
            info.dbid   = (ulong)VUInt64.Instance.Decode(data, ref unLen);  //dbid
            var entity = DefParser.Instance.GetEntityByID(info.typeId);

            if (entity != null)
            {
                info.entity = entity;
                info.props  = new List <EntityPropertyValue>();
                while (unLen < data.Length)
                {
//还有数据就解析
                    var index = (ushort)VUInt16.Instance.Decode(data, ref unLen);
                    EntityDefProperties prop;
                    var flag = entity.Properties.TryGetValue(index, out prop);
                    if (flag)
                    {
                        info.props.Add(new EntityPropertyValue(prop, prop.VType.Decode(data, ref unLen)));
                    }
                }
            }
            Arguments = new object[1] {
                info
            };
            if (RPCMsgLogManager.IsRecord)
            {
                RPCMsgLogManager.Receive(MSGIDType.CLIENT_ENTITY_ATTACHED, Arguments);
            }
        }
Example #3
0
        /// <summary>
        /// 将远程调用的方法解码为EntityAttachedPluto调用。
        /// </summary>
        /// <param name="data">远程调用方法的二进制数组</param>
        /// <param name="unLen">数据偏移量</param>
        protected override void DoDecode(byte[] data, ref int unLen)
        {

            //ushort klen = (ushort)VUInt16.Instance.Decode(data, ref unLen);
            string key = (string)VString.Instance.Decode(data, ref unLen);
            EventDispatcher.TriggerEvent<string>(Events.FrameWorkEvent.ReConnectKey, key);
            var info = new BaseAttachedInfo();
            info.typeId = (ushort)VUInt16.Instance.Decode(data, ref unLen); //entity type id
            info.id = (uint)VUInt32.Instance.Decode(data, ref unLen);//entity unique id
            info.dbid = (ulong)VUInt64.Instance.Decode(data, ref unLen); //dbid
            var entity = DefParser.Instance.GetEntityByID(info.typeId);
            if (entity != null)
            {
                info.entity = entity;
                info.props = new List<KeyValuePair<EntityDefProperties, object>>();
                while (unLen < data.Length)
                {//还有数据就解析
                    var index = (ushort)VUInt16.Instance.Decode(data, ref unLen);
                    EntityDefProperties prop;
                    var flag = entity.Properties.TryGetValue(index, out prop);
                    if (flag)
                        info.props.Add(new KeyValuePair<EntityDefProperties, object>(prop, prop.VType.Decode(data, ref unLen)));
                }
            }
            Arguments = new object[1] { info };
        }
Example #4
0
        public byte[] ServerEncode(BaseAttachedInfo info)
        {
            Push(VUInt16.Instance.Encode(MSGIDType.CLIENT_ENTITY_ATTACHED));
            Push(VUInt16.Instance.Encode(info.typeId));
            Push(VUInt32.Instance.Encode(info.id));
            Push(VUInt64.Instance.Encode(info.dbid));
            if (info.props != null)
            {
                for (int i = 0; i < info.props.Count; i++)
                {
                    var prop = info.props[i];
                    Push(VUInt16.Instance.Encode(CurrentEntity.PropertiesIdMapping[prop.Property.Name]));
                    Push(prop.Property.VType.Encode(prop.Value));
                }
            }


            var result = new Byte[m_unLen];

            Buffer.BlockCopy(m_szBuff, 0, result, 0, m_unLen);
            EndPluto(result);
            return(result);
        }
Example #5
0
        public override void Login(string _passport, string _password, string _loginArgs)
        {
            var baseInfo = new BaseAttachedInfo();
            baseInfo.typeId = 1; //entity type id
            baseInfo.id = (uint)Guid.NewGuid().GetHashCode();
            baseInfo.dbid = (uint)Guid.NewGuid().GetHashCode(); //dbid
            baseInfo.entity = DefParser.Instance.GetEntityByName("Account");
            baseInfo.props = new List<KeyValuePair<EntityDefProperties, object>>();

            EventDispatcher.TriggerEvent<BaseAttachedInfo>(Events.FrameWorkEvent.EntityAttached, baseInfo);
        }
Example #6
0
    // 协议处理函数
    static private void OnEntityAttached(BaseAttachedInfo baseInfo)
    {
        if (baseInfo.entity == null)
        {
            LoggerHelper.Error("Entity Attach Error.");
            return;
        }
        switch (baseInfo.entity.Name)
        {
            case "Account":
                {
                    m_currentEntity = theAccount;
                    LoggerHelper.Debug("account attach");
                    Action action = () =>
                    {
                        Mogo.GameLogic.LocalServer.LocalServerResManager.Initialize();
                        MogoGlobleUIManager.Instance.ShowGlobleStaticText(false, "");
                        theAccount.SetEntityInfo(baseInfo);
                        theAccount.OnEnterWorld();
                        theAccount.CheckVersionReq();
                        theAccount.entity = baseInfo.entity;
                        isReConnect = false;
                        LoadCharacterScene();

                        if (PlatformSdkManager.Instance)
                            PlatformSdkManager.Instance.SetupNotificationData();
                    };
                    lock (MogoWorld.GameDataLocker)
                    {
                        if (MogoWorld.IsGameDataReady)
                        {
                            Driver.Invoke(action);
                        }
                        else
                        {
                            MogoWorld.OnGameDataReady = action;
                        }
                    }
                    break;
                }
            case "Avatar":
                {
                    LoggerHelper.Debug("self attach");
                    bool ab = false; //用于切换cell连接时容错
                    if (MogoWorld.thePlayer == null)
                    {
                        ab = true;
                        thePlayer = new EntityMyself();
                        thePlayer.deviator = RandomHelper.GetRandomInt(1, 3000);
                        thePlayer.CalcuDmgBase();
                    }
                    m_currentEntity = thePlayer;
                    thePlayer.SetEntityInfo(baseInfo);
                    if (ab)
                    {
                        thePlayer.OnEnterWorld();
                    }
                    //thePlayer.UpdateSkillToManager();
                    thePlayer.entity = baseInfo.entity;
                    // EventDispatcher.TriggerEvent(Events.OperationEvent.GetAllActivity);
                    break;
                }
            default:
                break;
        }
    }