private void Conn_OnMessage(object sender, PlayerIOClient.Message e) { switch (e.Type) { case "init": chatQueue = new ChatQueue(); var initEvent = new EEBLInitEvent(chatQueue); Bots.ForEach(bot => bot.OnInit(initEvent)); conn.Send("init2"); break; case "add": NamedMessageAdd message = new NamedMessageAdd(new MessageAdd(e)); EEBLAPI.Player.Player player = new EEBLAPI.Player.Player(message.UniqueUserId); player.Id = message.Id; player.Username = message.Username; playerHandler.AddPlayer(player); playerHandler.PlayerJoin(player, message.SourceMessage); break; case "left": playerHandler.RemovePlayer( playerHandler.GetPlayer(e.GetInt(0)) ); break; } }
private void onClickValidate(object sender, RoutedEventArgs e) { try { int numberOfPlayerInGame = _PlayerHandler.GetNumberOfPlayer(); int nbBot = Convert.ToInt32(cbNbBot.SelectedItem.ToString()); if (PlayerName == placeholder) { throw new InvalidePlayerNameException(); } else { _PlayerHandler.AddPlayer(new Player(PlayerName, new Pawn(PlayerColor), Player.TypeOfPlayer.USER)); _GameManager.GeneratedBot(nbBot); } _GameManager.IntialiseGame(); ((MainWindow)Window.GetWindow(this)).MainContent.Content = PageBoard.Instance; ((MainWindow)Window.GetWindow(this)).MenuContent.Visibility = Visibility.Hidden; } catch (Exception exp) { AlertNotification.Visibility = Visibility.Visible; AlertNotification.Content = new AlertDialog(exp, AlertDialog.TypeOfAlert.ERROR); } }
private void onClickPlay(object sender, RoutedEventArgs e) { foreach (Player p in ListOfPlayers) { _PlayerHandler.AddPlayer(p); } _GameManager.IntialiseGame(); ((MainWindow)Window.GetWindow(this)).MainContent.Content = PageBoard.Instance; ((MainWindow)Window.GetWindow(this)).MenuContent.Visibility = Visibility.Hidden; }
private static Player GetOrCreatePlayer(string name) { var player = PlayerHandler.GetPlayerByName(name); if (player == null) { player = PlayerHandler.AddPlayer(new Player { Name = name }); } return(player); }
public static void ProcessData(Connection conn, DataTransfer transfer) { if (conn == null || transfer == null) { return; } if (transfer is AuthenticationRequest) { AuthenticationRequest authenticationRequest = (AuthenticationRequest)transfer; PlayerAccount player = new PlayerAccount(authenticationRequest.Username, authenticationRequest.Password); string authenticationResponseMessage = AccountFileHandler.ReadAccount(player); if (authenticationResponseMessage == null) { PlayerHandler.AddPlayer(player); } conn.SendData(new AuthenticationResponse(authenticationResponseMessage)); } }
public void AddPlayer(string playerName) { playerHandler.AddPlayer(playerName); UpdateUI(); }