Esempio n. 1
0
        /// <summary>
        /// 注册网络消息。
        /// </summary>
        public void RegisterNetMsg()
        {
            CoreEntry.netMgr.bindMsgHandler(NetMsgDef.S_TELEPORT_FREE_TIME, OnTeleportFreeTime);
            CoreEntry.netMgr.bindMsgHandler(NetMsgDef.S_MEINFO, OnInitData);
            CoreEntry.netMgr.bindMsgHandler(NetMsgDef.S_WORLDLEVEL, OnInitWorldlevel);
            CoreEntry.netMgr.bindMsgHandler(NetMsgDef.S_MODLE_FIGHT_CHANGE, OnPowerChange);
            CoreEntry.netMgr.bindMsgHandler(NetMsgDef.S_SET_PK_RULE, OnSetPKRule);
            CoreEntry.gEventMgr.AddListener(GameEvent.GE_SC_MAINPLAYER_ENTER_SCENE, OnGameEventEnterScene);
            CoreEntry.gEventMgr.AddListener(GameEvent.GE_BAG_INFO, OnBagChange);
            CoreEntry.gEventMgr.AddListener(GameEvent.GE_BAG_ITEM_ADD, OnBagChange);
            CoreEntry.gEventMgr.AddListener(GameEvent.GE_BAG_ITEM_DEL, OnBagChange);
            CoreEntry.gEventMgr.AddListener(GameEvent.GE_BAG_ITEM_UPDATE, OnBagChange);
            CoreEntry.gEventMgr.AddListener(GameEvent.GE_CLEANUP_USER_DATA, OnCleanupUserData);

            mRideData.RegisterNetMsg();
            mBagData.RegisterNetMsg();
            mSkillData.RegisterNetMsg();
            //mShopData.RegisterNetMsg();
            mTeamData.RegisterNetMsg();
            mGuildData.RegisterNetMsg();
            mResLevelData.RegisterNetMsg();
            mJingJieData.RegisterNetMsg();
            mChatData.RegisterNetMsg();
            mEquipMgr.ResisterMsg();
            mMagicKeyMgr.ResisterMsg();
            mLevelFuBenDataMgr.ResisterMsg();
            mBossFuBenDataMgr.ResisterMsg();
            ExpFuBenDataMgr.ResisterMsg();
            mNeiGonginDataMgrr.ResisterMsg();
            mStoneData.RegisterNetMsg();
            mBeautyWomanMgr.ResisterMsg();
            mCrownData.RegisterNetMsg();
            mMailDataMgr.ResisterMsg();
            mFashionData.RegisterNetMsg();
            mFriendData.RegisterNetMsg();
            mSecretDuplDataMgr.ResisterMsg();
            mTreasureFuBenDataMgr.ResisterMsg();
            funcData.RegisterNetMsg();

            //Lua层注册
            LuaTable           G     = LuaMgr.Instance.GetLuaEnv().Global;
            LuaTable           table = G.Get <LuaTable>("ModelManager");
            MemberFunctionCall fun   = table.Get <MemberFunctionCall>("RegisterNetMsg");

            if (fun != null)
            {
                fun(table);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 初始化数据。
        /// </summary>
        /// <param name="data">网络消息数据。</param>
        public void OnInitData(MsgData data)
        {
            MsgData_sMeInfo info = data as MsgData_sMeInfo;

            MainRole.Instance.serverID = info.RoleID;
            MainRole.Instance.faction  = info.ZhenYing;
            mBasicAttr.ClearBasicAttr();
            mRoleID                  = info.RoleID;
            mBasicAttr.Wing          = info.Wing;
            mBasicAttr.ZhenFa        = info.ZhenFaID;
            mBasicAttr.Faction       = info.ZhenYing;
            mBasicAttr.Dress         = info.Dress;
            mBasicAttr.EquipStarMin  = info.EquipStarMin;
            mBasicAttr.Weapon        = info.Weapon;
            mBasicAttr.FashionWing   = info.FashionWing;
            mBasicAttr.FashionDress  = info.FashionDress;
            mBasicAttr.FashionWeapon = info.FashionWeapon;
            mBasicAttr.FashionState  = info.FashionState;
            mBasicAttr.ShenBing      = info.ShenBing;
            ShenBingId               = info.ShenBing;
            mBasicAttr.Name          = GetPlayerName(UiUtil.GetNetString(info.RoleName), out mServerGroup);
            mBasicAttr.SetBasicAttrValue((int)BasicAttrEnum.Gender, info.Gender);
            mBasicAttr.SetBasicAttrValue((int)BasicAttrEnum.Prof, info.Job);
            mBasicAttr.Lord = info.GuanZhi;
            mIcon           = info.Icon;
            CoreEntry.gEventMgr.TriggerEvent(GameEvent.GE_PLAYER_INFO, EventParameter.Get());
            CoreEntry.gAutoAIMgr.ReloadConfig();
            NetLogicGame.Instance.SendReqDianfengInfo();
            NetLogicGame.Instance.SendReqGetMailList();

            //若已经创建了玩家对象则更新
            if (CoreEntry.gActorMgr.MainPlayer != null)
            {
                CoreEntry.gActorMgr.MainPlayer.mBaseAttr.Name = mBasicAttr.Name;
                CoreEntry.gActorMgr.MainPlayer.mBaseAttr.Lord = mBasicAttr.Lord;
                CoreEntry.gActorMgr.MainPlayer.Faction        = info.ZhenYing;
            }
            mTeamData.SendTeamInfoRequest();

            //Lua层初始化
            LuaTable           G     = LuaMgr.Instance.GetLuaEnv().Global;
            LuaTable           table = G.Get <LuaTable>("ModelManager");
            MemberFunctionCall fun   = table.Get <MemberFunctionCall>("InitPlayerData");

            if (fun != null)
            {
                fun(table);
            }
        }
Esempio n. 3
0
        /// <summary>
        ///  切换账号清除数据
        /// </summary>
        private void OnCleanupUserData(GameEvent ge, EventParameter parameter)
        {
            //Lua层
            LuaTable           G     = LuaMgr.Instance.GetLuaEnv().Global;
            LuaTable           table = G.Get <LuaTable>("ModelManager");
            MemberFunctionCall fun   = table.Get <MemberFunctionCall>("Reset");

            if (fun != null)
            {
                fun(table);
            }
            //邮件
            mMailDataMgr.ReSet();
            mStoneData.ClearData();
            mBasicAttr.ClearBasicAttr();
            mBasicAttr.Name             = " ";
            mRoleID                     = 0;
            UnbindMoney                 = 0;
            Account.Instance.ServerId   = 0;
            Account.Instance.ServerName = "no";
            BossFuBenDataMgr.Instance.Reset();
        }