Пример #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        public Board()
        {
            InitializeComponent();

            screen = new PictureBox();

            Controls.AddRange(new Control[] {screen});
            levelSet = new LevelSet();

            // Load the levels in the LevelSet object and set the current level
            String s;
            bool opcionValida = false;
            do
            {
                Console.Write("\n[I]dentificate o [R]egistrate: "); s = Console.ReadLine();

                if (s == "i") // Caso en el que nos estemos identificando como un usuario ya existente.
                {
                    Console.WriteLine("\nIdentificate:\n");
                    Console.Write("Nombre de usuario: "); usuario = Console.ReadLine();
                    Console.Write("Contraseña: "); password = pedirPassword(); // Console.ReadLine();

                    //fichaUsuario = ProxyServJugadores.obtenerFichaJugador(usuario);
                    fichaUsuario = ProxyServJugadores.recuperarJugadorSQL(usuario, password).Split('&');

                    if ((fichaUsuario.Length != 3) || (fichaUsuario[1] != password))
                    {
                        Console.WriteLine("\nContraseña o usuario incorrectos");
                        opcionValida = false;
                    }
                    else
                    {
                        Console.WriteLine("\n\nTe has identificado como: " + fichaUsuario[0]);
                        //Console.WriteLine("Tu contrasena es: " + fichaUsuario[1]);
                        Console.WriteLine("El ultimo nivel al que jugaste fue: " + fichaUsuario[2]);

                        opcionValida = true;
                    }
                }

                else if (s == "r") // Caso en el que nos estemos registrando como usuario nuevo.
                {
                    Console.Write("\n\nTu nombre de usuario: "); fichaUsuario[0] = Console.ReadLine();
                    Console.Write("Tu contrasena: "); fichaUsuario[1] = pedirPassword(); // Console.ReadLine();
                    fichaUsuario[2] = "0.1";

                    ProxyServJugadores.crearJugadorSQL(fichaUsuario[0], fichaUsuario[1]);

                    Console.WriteLine("\nNuevo usuario creado.");

                    opcionValida = true;
                }
            }
            while (opcionValida == false);

            niveles = fichaUsuario[2].Split('.');
            int indiceColeccionNiveles = Convert.ToInt32(niveles[0]);
            int nivel = Convert.ToInt32(niveles[1]);
            String coleccion = coleccionNiveles.arrayNombresNiveles[indiceColeccionNiveles];
            levelSet.SetLevelsInLevelSet(indiceColeccionNiveles);

            // Cargar niveles de juego y empezar:
            Console.WriteLine("\nIniciando juego.");
            InitializeGame(nivel);
        }
Пример #2
0
        static void Main()
        {
            Console.WriteLine("CLIENTE DE SOKOBANURJC");

            // Recuperar tabla de nombres remota:
            RemotingConfiguration.RegisterWellKnownClientType(typeof(SokobanURJC.TablaNombres), "http://localhost:1232/TablaNombres.remoto");
            TablaNombres tablaNombres = (TablaNombres)Activator.GetObject(typeof(SokobanURJC.TablaNombres), "http://localhost:1232/TablaNombres.remoto");

            int puertoLogica = tablaNombres.puertoLogica;
            int puertoNiveles = tablaNombres.puertoNiveles;

            RemotingConfiguration.RegisterWellKnownClientType(typeof(SokobanURJC.Level), "http" + "://localhost:" + puertoLogica + "/Level.remoto");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(SokobanURJC.LevelSet), "http" + "://localhost:" + puertoLogica + "/LevelSet.remoto");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(SokobanURJC.ColeccionNiveles), "http" + "://localhost:" + puertoNiveles + "/ColeccionNiveles.remoto");

            levelSet = (LevelSet)Activator.GetObject(typeof(LevelSet), "http" + "://localhost:" + puertoLogica + "/LevelSet.remoto");
            level = (Level)Activator.GetObject(typeof(Level), "http" + "://localhost:" + puertoLogica + "/Level.remoto");
            coleccionNiveles = (ColeccionNiveles)Activator.GetObject(typeof(SokobanURJC.ColeccionNiveles), "http" + "://localhost:" + puertoNiveles + "/ColeccionNiveles.remoto");

            // Lanzar juego:
            Application.Run(new Board());
        }