Пример #1
0
        /*Funcion que se encara de crear la matriz que se ocupara dentro del juego.
         * Recibe como parametro:
         * Terreno: Es donde se guardara la matri del juego.
         * Vt: Es la vista donde se encuentra el panel donde se ubicara la matriz de juego.*/

        public Terreno createBoard(Terreno terreno, VistaTerreno vt)
        {
            this.vt = vt;
            Random r = new Random();

            this.terreno = terreno;
            int x = 25;
            int y = 25;

            for (int i = 0; i < terreno.InfoTablero[0]; i++)
            {
                for (int j = 0; j < terreno.InfoTablero[1]; j++)
                {
                    Casilla casilla = new Casilla(i, j, false, null);
                    casilla.Location      = new Point(x, y);
                    casilla.Click        += new EventHandler(vt.acciones);
                    terreno.Casilla[i, j] = casilla;
                    vt.panelTablero.Controls.Add(casilla);
                    x += 35;
                }
                x  = 25;
                y += 35;
            }
            return(terreno);
        }
Пример #2
0
 /* Se declara un contructor que contiene todo los datos que ingresa el usuario, al momento de pasar la vista
  * que solicta la totalidad de los datos.*/
 public Terreno(Jugador jugador, int fila, int columna, int numBarcoUsuario, int numBarcoEnemigo, String nivel, string equipoPreferido, Pnj computador, int tiempoo, VistaTerreno vt)
 {
     this.vt                = vt;
     this.jugador           = jugador;
     this.comp              = computador;
     this.time              = tiempoo;
     this.infoTablero       = new int[4];
     this.infoTablero[0]    = fila;
     this.infoTablero[1]    = columna;
     this.infoTablero[2]    = numBarcoUsuario;
     this.infoTablero[3]    = numBarcoEnemigo;
     this.cantBarcosTerreno = numBarcoUsuario;
     this.nivel             = nivel;
     this.equipoPreferido   = equipoPreferido;
     casilla                = new Casilla[fila, columna];
     listaGeneral           = new List <Barco>();
     jefeUsuario            = barco.jefeBarco(0, this.EquipoPreferido);
     jugador.Barcos[0]      = jefeUsuario;
     listaGeneral.Add(jugador.Barcos[0]);
     for (int i = 0; i < 3; i++)
     {
         Barco aux  = barco.barcoDebil(i);
         Barco aux1 = barco.barcoNormales(i);
         listaGeneral.Add(aux);
         listaGeneral.Add(aux1);
     }
 }