internal void CreatePlayer(BoltConnection boltConnection = null) { Map mainMap = MapManager.FindMap(1); Transform spawnPoint = RandomUtils.GetRandomElement(mainMap.Settings.FindSpawnPoints(Team.Alliance)); ClassType classType; string playerName; string unityId; if (boltConnection == null) { playerName = serverRoomToken.LocalPlayerName; unityId = SystemInfo.deviceUniqueIdentifier; classType = (ClassType)PlayerPrefs.GetInt(UnitUtils.PreferredClassPrefName, 0); } else { var connectionToken = (ClientConnectionToken)boltConnection.ConnectToken; playerName = connectionToken.Name; unityId = connectionToken.UnityId; classType = connectionToken.PrefferedClass; } if (!mainMap.Settings.Balance.ClassesByType.TryGetValue(classType, out ClassInfo classInfo) || !classInfo.IsAvailable) { classType = ClassType.Mage; } var playerCreateToken = new Player.CreateToken { Position = spawnPoint.position, Rotation = spawnPoint.rotation, DeathState = DeathState.Alive, FreeForAll = true, ModelId = 1, ClassType = classType, OriginalModelId = 1, FactionId = mainMap.Settings.Balance.DefaultFaction.FactionId, PlayerName = playerName }; Player newPlayer = UnitManager.Create <Player>(BoltPrefabs.Player, playerCreateToken); newPlayer.AssignControl(boltConnection); newPlayer.UpdateVisibility(true); var newPlayerInfo = new PlayerServerInfo(boltConnection, newPlayer, unityId); playerInfos.Add(newPlayerInfo); playerInfosByPlayerId[newPlayer.Id] = newPlayerInfo; if (boltConnection != null) { playerInfosByConnection[boltConnection] = newPlayerInfo; } else { serverPlayerInfo = newPlayerInfo; } }
internal void CreatePlayer(BoltConnection boltConnection = null) { Map mainMap = MapManager.FindMap(1); Transform spawnPoint = RandomUtils.GetRandomElement(mainMap.Settings.FindSpawnPoints(Team.Alliance)); string playerName; string unityId; if (boltConnection == null) { playerName = serverRoomToken.LocalPlayerName; unityId = SystemInfo.deviceUniqueIdentifier; } else { var connectionToken = (ClientConnectionToken)boltConnection.ConnectToken; playerName = connectionToken.Name; unityId = connectionToken.UnityId; } var playerCreateToken = new Player.CreateToken { Position = spawnPoint.position, Rotation = spawnPoint.rotation, DeathState = DeathState.Alive, FreeForAll = true, ModelId = 1, OriginalModelId = 1, FactionId = mainMap.Settings.Balance.DefaultFaction.FactionId, PlayerName = playerName }; Player newPlayer = UnitManager.Create <Player>(BoltPrefabs.Player, playerCreateToken); newPlayer.AssignControl(boltConnection); var newPlayerInfo = new PlayerServerInfo(boltConnection, newPlayer, unityId); playerInfos.Add(newPlayerInfo); playerInfosByPlayerId[newPlayer.Id] = newPlayerInfo; if (boltConnection != null) { playerInfosByConnection[boltConnection] = newPlayerInfo; } else { serverPlayerInfo = newPlayerInfo; } }