private void UpdateTestPlayerInfo(IPlayerInfo playerInfo) { if (playerInfo.Token == TestUtility.TestToken) { playerInfo.PlayerId = TestUtility.NewPlayerId; playerInfo.PlayerName = "Test_" + playerInfo.PlayerId; playerInfo.Num = ++_testPlayerNum; playerInfo.Camp = _testPlayerNum % 2 == 0 ? 2 : 1; playerInfo.TeamId = playerInfo.Camp; playerInfo.AvatarIds = new List <int> { 1, 8 }; playerInfo.WeaponBags = PlayerEntityFactory.MakeFakeWeaponBag(); } else if (playerInfo.Token == TestUtility.RobotToken) { playerInfo.PlayerId = TestUtility.NewPlayerId; playerInfo.PlayerName = "Robot_" + playerInfo.PlayerId; playerInfo.Num = ++_testPlayerNum; playerInfo.Camp = _testPlayerNum % 2 == 0 ? 1 : 2; playerInfo.TeamId = playerInfo.Camp; playerInfo.AvatarIds = new List <int> { 1, 8 }; playerInfo.WeaponBags = PlayerEntityFactory.MakeFakeWeaponBag(); } }
public override void SingleExecute(PlayerEntity player) { PlayerEntityFactory.PostCreateNewPlayerEntity( player, _contexts); _logger.InfoFormat("created client player entity {0}", player.entityKey); }
private PlayerEntity CreateNewPlayerEntity(IPlayerInfo playerInfo) { return(PlayerEntityFactory.CreateNewServerPlayerEntity(_contexts.player, _contexts.session.commonSession, _contexts.session.commonSession.EntityIdGenerator, SingletonManager.Get <MapConfigManager>().SceneParameters.PlayerBirthPosition, playerInfo, _hallRoom.AllowReConnect)); }
public void Execute() { if (SharedConfig.IsOffline) { if (!_loginSended) { _loginSended = true; var sessionObjects = _contexts.session.commonSession; IEntityIdGenerator idGenerator = sessionObjects.EntityIdGenerator; var id = idGenerator.GetNextEntityId(); var _offlineSelector = new OfflineSnapshotSelector(new EntityKey(id, (int)EEntityType.Player), _contexts.session.commonSession.GameContexts); _contexts.session.clientSessionObjects.SnapshotSelectorContainer.SnapshotSelector = _offlineSelector; _contexts.session.clientSessionObjects.SimulationTimer.CurrentTime = 0; _contexts.session.entityFactoryObject.SceneObjectEntityFactory = new ServerSceneObjectEntityFactory( _contexts.sceneObject, _contexts.player, sessionObjects.EntityIdGenerator, sessionObjects.EntityIdGenerator, _contexts.session.currentTimeObject); _contexts.session.entityFactoryObject.MapObjectEntityFactory = new ServerMapObjectEntityFactory(_contexts.mapObject, sessionObjects.EntityIdGenerator); IPlayerInfo playerInfo = TestUtility.CreateTestPlayer(); playerInfo.EntityId = id; var player = PlayerEntityFactory.CreateNewPlayerEntity(_contexts.player, SingletonManager.Get <MapsDescription>().SceneParameters.PlayerBirthPosition, playerInfo, true, false); _offlineSelector.Init(); _sessionState.FullfillExitCondition(typeof(RequestPlayerInfoSystem)); SingletonManager.Get <SubProgressBlackBoard>().Step(); } } else { var channel = _contexts.session.clientSessionObjects.NetworkChannel; var token = _contexts.session.clientSessionObjects.LoginToken; if (channel != null && channel.IsConnected) { if (!_loginSended) { _loginSended = true; var message = LoginMessage.Allocate(); message.Token = token; message.LoginStage = ELoginStage.GetPlayerInfo; message.ComponentSerializerVersion = ComponentSerializerManager.HashMd5; channel.SendReliable((int)EClient2ServerMessage.Login, message); _logger.InfoFormat("Sending Login Message {0}", message); message.ReleaseReference(); } if (_loginSuccReceived) { _sessionState.FullfillExitCondition(typeof(RequestPlayerInfoSystem)); SingletonManager.Get <SubProgressBlackBoard>().Step(); } } } }
public PlayerSpawningController( PlayerEntityFactory playerEntityFactory, PlayerEntityConfig playerEntityConfig, FloorTileEntityConfig floorTileEntityConfig, ScreenSizeModel screenSizeModel) { _playerEntityFactory = playerEntityFactory; _playerEntityConfig = playerEntityConfig; _floorTileEntityConfig = floorTileEntityConfig; _screenSizeModel = screenSizeModel; }
public List <PlayerWeaponBagData> FilterSortedWeaponBagDatas(PlayerInfoComponent playerInfoComponent, GamePlayComponent gamePlayComponent) { var list = new List <PlayerWeaponBagData>(); var jobAttribute = (gamePlayComponent == null ? (int)EJobAttribute.EJob_EveryMan : gamePlayComponent.JobAttribute); if (jobAttribute == (int)EJobAttribute.EJob_Variant || jobAttribute == (int)EJobAttribute.EJob_Matrix) { var originList = PlayerEntityFactory.MakeVariantWeaponBag(); for (int i = 0; i < originList.Length; i++) { list.Add(originList[i]); } } else { var originList = playerInfoComponent.WeaponBags; for (int i = 0; i < originList.Length; i++) { if (originList[i] == null) { continue; } Logger.InfoFormat("Server Origin Data =====>add BagIndex:{0}", originList[i].BagIndex); list.Add(originList[i]); // ServerRoomWeaponPreLog(playerInfoComponent.WeaponBags); // if ((EGameMode)ModeId == EGameMode.Survival) return null; // if (playerInfoComponent.WeaponBags == null || //playerInfoComponent.WeaponBags.Length == 0) return null; // var valuableBagDatas = new List<PlayerWeaponBagData>(playerInfoComponent.WeaponBags); // for (int i = valuableBagDatas.Count - 1; i >= 0; i--) // { // if (valuableBagDatas[i] == null || valuableBagDatas[i].weaponList.Count == 0 || // valuableBagDatas[i].BagIndex > GlobalConst.WeaponBagMaxCount) // { // valuableBagDatas.RemoveAt(i); // continue; // } // // DebugUtil.LogInUnity("Server init bag item:"+valuableBagDatas[i].ToString(),DebugUtil.DebugColor.Blue); // } // valuableBagDatas.Sort(ModeUtil.RoomWeaponCompareCmd); // return valuableBagDatas; } } return(list); }
public void Handle(INetworkChannel networkChannel, int messageType, object messageBody) { if (messageType == (int)EServer2ClientMessage.PlayerInfo) { PlayerInfoMessage msg = (PlayerInfoMessage)messageBody; _logger.InfoFormat("recv PlayerInfo {0}", msg); PlayerInfo info = new PlayerInfo(); info.ConvertFrom(msg); _loginSuccReceived = true; var playerEntity = PlayerEntityFactory.CreateNewPlayerEntity(_contexts.player, info.InitPosition, info, true, false); playerEntity.ReplaceNetwork(networkChannel); _contexts.session.commonSession.InitPosition = info.InitPosition; } }
public void ExecuteUserCmd(IPlayerUserCmdGetter owner, IUserCmd cmd) { if (!SharedConfig.IsRobot) { return; } var player = owner.OwnerEntity as PlayerEntity; if (player.hasRobot) { return; } var userCmdGenerator = _contexts.session.clientSessionObjects.UserCmdGenerator; if (userCmdGenerator is IRobotUserCmdProviderContainer) { PlayerEntityFactory.CreateRobotPlayerEntity(_contexts, player, new DummyRobotConfig(), (userCmdGenerator as IRobotUserCmdProviderContainer).RobotUserCmdProvider, userCmdGenerator); } }
private void UpdateTestPlayerInfo(IPlayerInfo playerInfo) { if (playerInfo.Token == TestUtility.TestToken) { playerInfo.PlayerId = TestUtility.NewPlayerId; playerInfo.PlayerName = "Test" + playerInfo.PlayerId; playerInfo.Num = ++testPlayerNum; playerInfo.Camp = testPlayerNum % 2 == 0 ? 2 : 1; playerInfo.RoleModelId = 1; playerInfo.TeamId = playerInfo.Camp; playerInfo.BadgeId = 15; playerInfo.AvatarIds = new List <int> { 77, 319, 320, 321 }; playerInfo.WeaponBags = PlayerEntityFactory.MakeFakeWeaponBag(); playerInfo.CampInfo = new CampInfo(1, new List <Preset> { new Preset(2, 12, new List <int> { 325, 326, 327 }, 1005), new Preset(1, 1, new List <int> { 77, 319, 320, 321 }, 1003) }); } else if (playerInfo.Token == TestUtility.RobotToken) { playerInfo.PlayerId = TestUtility.NewPlayerId; playerInfo.PlayerName = "Robot" + playerInfo.PlayerId; playerInfo.Num = ++testPlayerNum; playerInfo.Camp = testPlayerNum % 2 == 0 ? 1 : 2; playerInfo.TeamId = playerInfo.Camp; playerInfo.AvatarIds = new List <int> { 354 }; playerInfo.WeaponBags = PlayerEntityFactory.MakeFakeWeaponBag(); } }