public void Connect(string id, string name) { var player = _playerManager.CreatePlayer(id, name); _events.OnPlayerConnected(player); StartNextLevel(player); }
public IEnumerator CreatePlayer(Coroutine coroutine, ulong clientId, string name, string psw, string channelPid, AsyncReturnValue <PlayerController> status) { return(mImpl.CreatePlayer(coroutine, clientId, name, psw, channelPid, status, this)); }
public void PlayerLogin() { var playerName = _messagesRepository.LoginMessage(); player = _playerManager.GetPlayerByPlayerName(playerName); if (player == null) { player = _playerManager.GetById(_playerManager.CreatePlayer(new Player { PlayerName = playerName })); } _messagesRepository.PlayerStatisticsMessage(player); StartHangMan(); }
public void Connect(string id) { var player = _playerManager.CreatePlayer(id); _gameEvents.OnPlayerDisconnected(player); }
public async Task <ExtensionPlayerJoinResult> PlayerJoin(string broadcasterId) { var result = new ExtensionPlayerJoinResult(); if (string.IsNullOrEmpty(broadcasterId)) { result.ErrorMessage = "Invalid broadcaster or bad character id"; return(result); } var activeSession = gameData.GetOwnedSessionByUserId(broadcasterId); if (activeSession == null) { result.ErrorMessage = "Broadcaster does not have an active game session"; return(result); } if (TryGetSession(out var sessionInfo)) { var user = gameData.GetUser(sessionInfo.AccountId); if (user == null) { result.ErrorMessage = "No such user."; return(result); } var existingCharacters = gameData.GetCharactersByUserId(user.Id); if (existingCharacters.Count >= 3) { result.ErrorMessage = "You already have 3 characters."; return(result); } var index = existingCharacters.Count + 1; var player = await playerManager.CreatePlayer(user.UserId, user.UserName, index.ToString()); if (player == null) { result.ErrorMessage = "Failed to create a new character."; return(result); } var c = gameData.GetCharacter(player.Id); if (c == null) { result.ErrorMessage = "Okay. We don't know what went wrong here. Very sorry!"; return(result); } // We are just going to assume that it was successeful // since, if it "fails" as the character is already in game. well. Then what harm done? result.Success = true; result.Player = c.MapForWebsite(gameData, user); sessionInfoProvider.SetActiveCharacter(sessionInfo, c.Id); var gameEvent = gameData.CreateSessionEvent( GameEventType.PlayerAdd, activeSession, new PlayerAdd() { CharacterId = c.Id, Identifier = c.Identifier, UserId = sessionInfo.UserId, UserName = sessionInfo.UserName }); gameData.Add(gameEvent); } else { result.ErrorMessage = "You don't seem to be authenticated."; return(result); } return(result); }