Ejemplo n.º 1
0
        private bool InitRoleInstance(PlanesInstance planes, CSCommon.Data.PlayerData pd, Iocp.TcpConnect p2gConnect, UInt16 linkId)
        {
            mPlanes2GateConnect = p2gConnect;
            mClientLinkId       = linkId;

            mPlayerData = pd;
            mPlayerData.RoleDetail._SetHostPlayer(this);
            Bag.InventoryType = CSCommon.eItemInventory.ItemBag;

            //var sp = CSCommon.RoleCommonData.Instance.SexProToTId.Find(x => ((byte)x.Sex == pd.RoleDetail.Sex && (byte)x.Pro == pd.RoleDetail.Profession));
            //if (sp == null)
            //{
            //    Log.Log.Common.Print("SexProToTId is Null sex={0},pro={1}", pd.RoleDetail.Sex, pd.RoleDetail.Profession);
            //    return false;
            //}

            mPlayerData.RoleDetail.TemplateId = CSCommon.CommonUtil.GetTemplateIDBySexAndPro(pd.RoleDetail.Sex, pd.RoleDetail.Profession);

            #region 背包初始化
            Bag.InitBag(this, mPlayerData.RoleDetail.BagSize, mPlayerData.BagItems);
            EquipBag.InitBag(this, (UInt16)CSCommon.eEquipType.MaxBagSize, mPlayerData.EquipedItems);
            FashionBag.InitBag(this, byte.MaxValue, mPlayerData.FashionItems);
            EquipGemBag.InitBag(this, (UInt16)CSCommon.eEquipType.MaxBagSize, mPlayerData.EquipGemItems);
            GemBag.InitBag(this, (UInt16)CSCommon.eEquipType.MaxBagSize, mPlayerData.GemItems);
            #endregion
            InitMartial();
            #region 任务初始化
            InitTask(mPlayerData.TaskData);
            mRecordMgr.Init(this, mPlayerData.AchieveData);
            #endregion
            mSkillMgr.InitBag(this, mPlayerData.SkillDatas);
            #region 状态机初始化
            InitState();
            #endregion
            CalcAllValues();

            //mPlayerData.RoleDetail.RoleMaxHp = FinalRoleValue.MaxHP;
            //暂时先这样,以后需要客户端操作复活
            //if (CurHP <= 0)
            //    Relive();

            //EventDispacth.Instance.AddListener(eGlobleEvent.Fight_KillActor, this);



            return(true);
        }
Ejemplo n.º 2
0
 public void SaveAll()
 {
     // 物品背包
     mPlayerData.BagItems      = Bag.GetBagSaver();
     mPlayerData.EquipedItems  = EquipBag.GetBagSaver();
     mPlayerData.FashionItems  = FashionBag.GetBagSaver();
     mPlayerData.EquipGemItems = EquipGemBag.GetBagSaver();
     mPlayerData.GemItems      = GemBag.GetBagSaver();
     // 任务
     mPlayerData.TaskData = mCurTask.TaskData;
     mRecordMgr.Save(mPlayerData.AchieveData);
     mPlayerData.SkillDatas = mSkillMgr.GetBagSaver();
     SaveMartial();
     //发送存盘数据给数据服务器保存
     RPC.PackageWriter pkg = new RPC.PackageWriter();
     H_RPCRoot.smInstance.HGet_DataServer(pkg).HGet_PlayerManager(pkg).SaveRole(pkg, mPlayerData.RoleDetail.RoleId, mPlayerData);
     pkg.DoCommand(IPlanesServer.Instance.DataConnect, RPC.CommandTargetType.DefaultType);
 }