Esempio n. 1
0
        public static PlayerInstance CreatePlayerInstance(CSCommon.Data.PlayerData pd, Iocp.TcpConnect p2gConnect, UInt16 linkId)
        {
            IActorInitBase actInit = new IActorInitBase();

            actInit.GameType = eActorGameType.Player;
            PlayerInstance ret = new PlayerInstance();

            ret.Initialize(actInit);
            if (false == ret.InitRoleInstance(null, pd, p2gConnect, linkId))
            {
                return(null);
            }

            return(ret);
        }
Esempio n. 2
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);
        }