/// <summary> /// Constructor de la ventana Espera. /// </summary> /// <param name="jugador"> /// Objeto jugador que se mandó desde el menú. /// </param> /// <param name="partida"> /// Objeto partida que se mandó desde el menú. /// </param> /// /// <param name="clientePartida"> /// Conexión con el servidor para acceder a los métodos que proporciona sobre las partidas. /// </param> /// /// <param name="clienteChat"> /// Conexión con el servidor para acceder a los métodos que proporciona sobre el chat. /// </param> /// /// <param name="partidas"> /// Objeto mensajes que implementa los métodos que reciben respuesta del servidor, sobre las partidas. /// </param> /// /// <param name="mensajes"> /// Objeto mensajes que implementa los métodos que reciben respuesta del servidor, sobre el chat. /// </param> public Partida(ServiceSYE.Jugador jugador, ServiceSYE.Partida partida, ServiceSYE.PartidaClient clientePartida, ServiceSYE.ChatClient clienteChat, Partidas partidas, Mensajes mensajes) { InitializeComponent(); this.Title = this.Title + " - " + jugador.NombreUsuario; partidas.Partida = this; mensajes.Partida = this; this.Jugador = jugador; this.clienteChat = clienteChat; this.clientePartida = clientePartida; this.clienteJugador = new ServiceSYE.JugadorClient(); try { this.PartidaEnJuego = clientePartida.ObtenerPartida(partida.Nombre); DispatcherTimer temporizadorInicio = new DispatcherTimer(); temporizadorInicio.Interval = new TimeSpan(0, 0, 5); temporizadorInicio.Tick += (a, b) => { temporizadorInicio.Stop(); if (PartidaEnJuego.JugadoresPartida.ElementAt(0).Value.NombreUsuario.Equals(jugador.NombreUsuario)) { try { clienteChat.EnviarMensajePartida("", PartidaEnJuego.Nombre, 1); } catch (CommunicationException) { EnviarMensajeError(); } } }; temporizadorInicio.Start(); CargarTablero(); CargarBonus(); this.Jugador = ObtenerTurno(PartidaEnJuego.JugadoresPartida, this.Jugador); EnviarMensajeTurnos(); ValidarConectado(); } catch (CommunicationException) { EnviarMensajeError(); } }
/// <summary> /// Constructor de la ventana Espera. /// </summary> /// <param name="jugador"> /// Objeto jugador que se mandó desde el menú. /// </param> /// <param name="partida"> /// Objeto partida que se mandó desde el menú. /// </param> public Espera(ServiceSYE.Jugador jugador, ServiceSYE.Partida partida) { InitializeComponent(); if (lb_Esperando.Content.ToString().Substring(0, 1).Equals("E")) { lb_Esperando.FontSize = 40; } this.Title = this.Title + " - " + jugador.NombreUsuario; this.Jugador = jugador; this.Partida = partida; this.Partidas = new Partidas(); InstanceContext contextoPartida = new InstanceContext(Partidas); this.ClientePartida = new ServiceSYE.PartidaClient(contextoPartida); this.Mensajes = new Mensajes(); this.Mensajes.Espera = this; InstanceContext contextoChat = new InstanceContext(Mensajes); this.ClienteChat = new ServiceSYE.ChatClient(contextoChat); this.clienteJugador = new ServiceSYE.JugadorClient(); try { ClientePartida.UnirsePartida(jugador, partida.Nombre); ClienteChat.UnirseChat(jugador.NombreUsuario, partida.Nombre); ValidarConectado(); ClienteChat.EnviarMensaje("", partida.Nombre); } catch (CommunicationException) { EnviarMensajeError(); } }
/// <summary> /// Método que valida que el jugador sigue conectado al servidor. /// </summary> private void ValidarConectado() { validarConectadoMenu.Interval = new TimeSpan(0, 0, 20); validarConectadoMenu.Tick += (a, b) => { try { clienteJugador.UnirseAlJuego(jugador); } catch (CommunicationException) { clienteJugador = new ServiceSYE.JugadorClient(); } }; validarConectadoMenu.Start(); }
/// <summary> /// Carga los jugadores ordenados por victorias. /// </summary> /// <returns></returns> private Boolean CargarJugadoresVictorias() { Boolean exito = true; ServiceSYE.JugadorClient cliente = new ServiceSYE.JugadorClient(); try { var jugadores = cliente.ObtenerJugadoresVictorias(); dg_Jugadores.ItemsSource = jugadores; if (!jugadores.Any()) { exito = false; } } catch (CommunicationException) { MessageBox.Show(Properties.Resources.mb_ConexionServidor, Properties.Resources.mb_Alerta); } return(exito); }
/// <summary> /// Constructor de la ventana MainWindow. /// </summary> public MainWindow() { InitializeComponent(); cliente = new ServiceSYE.JugadorClient(); }
/// <summary> /// Construtor de la ventana ValidarCuenta. /// </summary> public ValidarCuenta() { InitializeComponent(); this.cliente = new ServiceSYE.JugadorClient(); }
/// <summary> /// Construtor de la ventana ValidarCuenta. /// </summary> public Registrarse() { InitializeComponent(); this.cliente = new ServiceSYE.JugadorClient(); }