1234567891011121314151617181920212223242526272829303132333435 |
- namespace ET.Server
- {
- public static class PlayerFactory
- {
- /// <summary>
- /// 创建玩家实体
- /// </summary>
- /// <param name="session"></param>
- /// <param name="playerInfo"></param>
- /// <returns></returns>
- public static async ETTask<WNPlayer> CreatPlayer(Session session, PlayerInfo playerInfo)
- {
- WNPlayer player = session.DomainScene().GetComponent<GamePlayerComponent>()
- .AddChild<WNPlayer, Session, PlayerInfo>(session, playerInfo);
- // 绑定sessionId
- player.GameSessionActorId = session.InstanceId;
- player.Session = session;
- player.BasicProp = CharacterCategory.Instance.Get(playerInfo.Pro);
- player.BornType = (int)BORN_TYPE.NORMAL;
- player.EnterState = (int)ENTER_STATE.online;
- // 玩家基础数据组件
- player.AddComponent<PlayerDataComponent, PlayerInfo, WNPlayer>(playerInfo, player);
- // 玩家临时数据组件
- await player.AddComponent<PlayerTempDataComponent, WNPlayer>(player).Init();
- // 玩家技能组件
- await player.AddComponent<PlayerSkillComponent, WNPlayer>(player).Init();
- // 玩家货币组件
- await player.AddComponent<PlayerMoneyComponent, WNPlayer>(player).Init();
- return player;
- }
- }
- }
|