Пример #1
0
        public void Reset(GameManager gm, Map m)
        {
            if (gm == null)
            {
                throw new ArgumentNullException(nameof(gm));
            }
            if (m == null)
            {
                throw new ArgumentNullException(nameof(m));
            }

            gm_ = gm;



            DestroyCasillas();
            path.setWorking(false);
            destroyFlechas();
            path_ = null;

            casillas_            = new Casilla[m.rows, m.cols];
            transform.localScale = new Vector3(SCALE_FACTOR_C * casillas_.GetLength(1), transform.localScale.y, SCALE_FACTOR_R * casillas_.GetLength(0));

            rows_ = checked ((int)m.rows);
            cols_ = checked ((int)m.cols);

            GenerateCasillas(m);

            ResetTank();
        }
Пример #2
0
        public Tablero(int f, int c, int difficulty)
        {
            this.fils         = f + 2;
            this.cols         = c + 2;
            this.difficulty   = difficulty;
            this.numeroBombas = 0;
            casillas          = new Casilla[fils, cols];
            for (int i = 0; i < fils; i++)
            {
                for (int j = 0; j < cols; j++)
                {
                    this.casillas[i, j] = new Casilla();
                    this.casillas[i, j].sumaUno();
                }
            }
            for (int i = 1; i < fils - 1; i++)
            {
                for (int j = 1; j < cols - 1; j++)
                {
                    this.casillas[i, j] = new Casilla();
                }
            }

            initTablero();
        }
Пример #3
0
 // solo puede crearse una instancia de esta clase
 public Tablero()
 {
     this.casillas = new Casilla [MAXIMO_FILA, MAXIMO_COLUMNA];
     entidades = new List<Entidad>();
     this.InicializarCasillas();
     this.seAgregoLaSalida = false;
 }
Пример #4
0
 /* Genera un archivo con los datos del tablero de la partida que es serializable
  * a partir de un tablero no serializable.
  */
 private static void generarTableroSerializable(Casilla[,] tablero, ref CasillaSerializable[,] tableroSerializable)
 {
     tableroSerializable = new CasillaSerializable[tablero.GetLength(0), tablero.GetLength(1)];
     for (int i = 0; i < tablero.GetLength(0); i++)
     {
         for (int j = 0; j < tablero.GetLength(1); j++)
         {
             CasillaSerializable temp = new CasillaSerializable();
             temp.coordsTexX  = tablero[i, j].coordsTex.x;
             temp.coordsTexY  = tablero[i, j].coordsTex.y;
             temp.coordsVertX = tablero[i, j].coordsVert.x;
             temp.coordsVertY = tablero[i, j].coordsVert.y;
             temp.coordsVertZ = tablero[i, j].coordsVert.z;
             temp.elementos   = tablero[i, j].elementos;
             temp.habitat     = tablero[i, j].habitat;
             if (tablero[i, j].pinceladas != null)
             {
                 temp.pinceladas = new float[tablero[i, j].pinceladas.Length * 2];
                 for (int k = 0; k < tablero[i, j].pinceladas.Length; k++)
                 {
                     temp.pinceladas[k * 2]     = tablero[i, j].pinceladas[k].x;
                     temp.pinceladas[k * 2 + 1] = tablero[i, j].pinceladas[k].y;
                 }
             }
             tableroSerializable[i, j] = temp;
         }
     }
 }
Пример #5
0
        public void Initialize(TankPuzzle puzzle)
        {
            if (puzzle == null)
            {
                throw new ArgumentNullException(nameof(puzzle));
            }

            if (casillas == null)
            {
                casillas = new Casilla[puzzle.rows, puzzle.columns];

                transform.localScale = new Vector3(SCALE_FACTOR_C * casillas.GetLength(1),
                                                   transform.localScale.y, SCALE_FACTOR_R * casillas.GetLength(0));
            }
            else if (casillas.GetLength(0) != puzzle.rows || casillas.GetLength(1) != puzzle.columns)
            {
                DestroyCasillas();
                casillas = new Casilla[puzzle.rows, puzzle.columns];

                transform.localScale = new Vector3(SCALE_FACTOR_C * casillas.GetLength(1),
                                                   transform.localScale.y, SCALE_FACTOR_R * casillas.GetLength(0));
            }

            GenerateCasillas(puzzle);
        }
Пример #6
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);
     }
 }
Пример #7
0
 /* Construye un tablero usable con los datos del tablero serializado.
  */
 private static void rehacerTablero(CasillaSerializable[,] tableroSerializable, ref Casilla[,] tablero)
 {
     tablero = new Casilla[tableroSerializable.GetLength(0), tableroSerializable.GetLength(1)];
     for (int i = 0; i < tablero.GetLength(0); i++)
     {
         for (int j = 0; j < tablero.GetLength(1); j++)
         {
             Casilla temp = new Casilla();
             Vector2 vect = new Vector2(tableroSerializable[i, j].coordsTexX, tableroSerializable[i, j].coordsTexY);
             temp.coordsTex = vect;
             Vector3 vect3 = new Vector3(tableroSerializable[i, j].coordsVertX, tableroSerializable[i, j].coordsVertY, tableroSerializable[i, j].coordsVertZ);
             temp.coordsVert = vect3;
             temp.elementos  = tableroSerializable[i, j].elementos;
             temp.habitat    = tableroSerializable[i, j].habitat;
             if (tableroSerializable[i, j].pinceladas != null)
             {
                 temp.pinceladas = new Vector2[tableroSerializable[i, j].pinceladas.Length / 2];
                 for (int k = 0; k < temp.pinceladas.Length; k++)
                 {
                     Vector2 vect2 = new Vector2(tableroSerializable[i, j].pinceladas[k * 2], tableroSerializable[i, j].pinceladas[k * 2 + 1]);
                     temp.pinceladas[k] = vect2;
                 }
             }
             tablero[i, j] = temp;
         }
     }
 }
Пример #8
0
    void Start()
    {
        List <int> posibles = new List <int>();

        tablero    = new Casilla[n, n];
        in_tablero = new Casilla[n, n];

        for (int i = 0; i < n * n; i++)
        {
            posibles.Add(i);
        }

        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                int rnd = Random.Range(0, posibles.Count);
                if (posibles[rnd] != 0)
                {
                    Casilla c = new Casilla(new Vector2(i, j));
                    tablero[i, j]    = c;
                    in_tablero[i, j] = c;
                    c.getCube().transform.position = new Vector3(i * distancia, j * distancia, 0);
                    c.setNum(posibles[rnd]);
                }
                else
                {
                    hueco    = new Vector2(i, j);
                    in_hueco = hueco;
                }
                posibles.Remove(posibles[rnd]);
            }
        }
    }
Пример #9
0
    private IEnumerator creacionParte3()
    {
        trabajando  = true;
        progreso    = 0.0f;
        GUI.enabled = false;
        Debug.Log(FuncTablero.formateaTiempo() + ": Iniciando creacionParte3().");
        Debug.Log(FuncTablero.formateaTiempo() + ": Creando el tablero...");
        yield return(new WaitForSeconds(0.1f));

        Casilla[,] tablero = FuncTablero.iniciaTablero(texturaBase, texHabitats, texHabitatsEstetica, texElems, rocaMesh, Vector3.zero);
        progreso           = 0.7f;
        Debug.Log(FuncTablero.formateaTiempo() + ": Creando la vida...");
        yield return(new WaitForSeconds(0.01f));

        vida     = new Vida(tablero);
        progreso = 1.0f;
        Debug.Log(FuncTablero.formateaTiempo() + ": Completado creacionParte3().");
        yield return(new WaitForSeconds(0.01f));

        progreso     = 0.0f;
        GUI.enabled  = true;
        trabajando   = false;
        faseCreacion = 0;
        estado       = 1;
    }
Пример #10
0
        // ----------------------------Public------------------------

        public void Init(GameManager gm, Map m)
        {
            if (gm == null)
            {
                throw new ArgumentNullException(nameof(gm));
            }
            if (m == null)
            {
                throw new ArgumentNullException(nameof(m));
            }

            gm_ = gm;

            // Inicializamos el vector de casillas
            casillas_            = new Casilla[m.rows, m.cols];
            transform.localScale = new Vector3(SCALE_FACTOR_C * casillas_.GetLength(1), transform.localScale.y, SCALE_FACTOR_R * casillas_.GetLength(0));


            rows_ = checked ((int)m.rows);
            cols_ = checked ((int)m.cols);

            GenerateCasillas(m);

            InitTank();
        }
Пример #11
0
        public void SalvarArchivos(Casilla[,] grid, String nombre)
        {
            String cad = nombre + "\n\r";

            foreach (Casilla c in grid)
            {
                if (c.okupada)
                {
                    if (c.actor != null)
                    {
                        if (c.roll == "sTree")
                        {
                            cad += "A," + c.x + "," + c.y + "\n\r";
                        }
                        if (c.roll == "sRock")
                        {
                            cad += "R," + c.x + "," + c.y + "\n\r";
                        }
                    }
                }
            }
            File.WriteAllText("Mapas\\" + nMapas.ToString() + ".txt", cad);
            nMapas++;
            if (AbrirArchivos())
            {
                SetupDataGridView();
                PopulateDataGridView();
            }
        }
Пример #12
0
        //##########################################################################
        //########################     CONSTRUCTORES    ############################
        //##########################################################################

        public Escudo(int tamaniox, int tamanioy)
        {
            this.x      = tamaniox;
            this.y      = tamanioy;
            this.escudo = new Casilla[x, y];
            this.danio  = 0;
            this.sanos  = 64;
        }
Пример #13
0
 public void EstablecerTablero()
 {
     tablero = new Casilla[width, height];
     for (int y = 0; y < tablero.GetLength(0); y++)
     {
         for (int x = 0; x < tablero.GetLength(1); x++)
         {
             tablero[x, y] = new Casilla(new Casilla.Coords(x, y));
         }
     }
 }
Пример #14
0
 private void RellenaTablero()
 {
     casillas = new Casilla[FILASTABLERO, COLUMNASTABLERO];
     for (int i = 0; i < FILASTABLERO; i++)
     {
         for (int j = 0; j < COLUMNASTABLERO; j++)
         {
             casillas[i, j] = new Casilla(i + 1, j + 1);
         }
     }
 }
Пример #15
0
 // Use this for initialization
 void Start()
 {
     matriz = new Casilla[tam, tam];
     for (int i = 0; i < tam; i++)
     {
         for (int j = 0; j < tam; j++)
         {
             matriz[i, j] = new Casilla();
             matriz[i, j].Posicion.Set(i, j);
         }
     }
 }
Пример #16
0
 public void getMatriz(ref Casilla[,] m)
 {
     for (int i = 0; i < tam; i++)
     {
         for (int j = 0; j < tam; j++)
         {
             m[i, j].contenido = matriz[i, j].contenido;
             m[i, j].terreno   = matriz[i, j].terreno;
             m[i, j].Posicion  = matriz[i, j].Posicion;
         }
     }
 }
Пример #17
0
 public void ChangeColor(bool free, Casilla[,] c, int x, int y)
 {
     if (free)
     {
         //verde
         c[x, y].GetComponent <Renderer>().material.color = ConvertColorRGBA(51, 255, 51, 100);
     }
     else
     {
         //rojo
         c[x, y].GetComponent <Renderer>().material.color = ConvertColorRGBA(194, 8, 16, 100);
     }
 }
Пример #18
0
    private void creacionInicial()
    {
        Debug.Log(FuncTablero.formateaTiempo() + ": Iniciando la creacion desde cero...");
        //Trabajar con la textura Textura_Planeta y crear el mapa lógico a la vez
        Texture2D texturaBase = objetoRoca.renderer.sharedMaterial.mainTexture as Texture2D;

        Color[] pixels = new Color[texturaBase.width * texturaBase.height];
        FuncTablero.inicializa(texturaBase);
        Debug.Log(FuncTablero.formateaTiempo() + ": Creando ruido...");
        pixels = FuncTablero.ruidoTextura();                                                            //Se crea el ruido para la textura base y normales...
        Debug.Log(FuncTablero.formateaTiempo() + ": Completado. Suavizando polos y bordes...");
        pixels = FuncTablero.suavizaBordeTex(pixels, texturaBase.width / 20);                           //Se suaviza el borde lateral...
        pixels = FuncTablero.suavizaPoloTex(pixels);                                                    //Se suavizan los polos...
        Debug.Log(FuncTablero.formateaTiempo() + ": Completado. Aplicando cambios...");
        texturaBase.SetPixels(pixels);
        texturaBase.Apply();
        Debug.Log(FuncTablero.formateaTiempo() + ": Completado. Extruyendo vertices de la roca...");
        float      extrusion = 0.45f;
        MeshFilter Roca      = objetoRoca.GetComponent <MeshFilter>();
        Mesh       meshTemp  = Roca.mesh;

        meshTemp  = FuncTablero.extruyeVerticesTex(meshTemp, texturaBase, extrusion, objetoRoca.transform.position);
        Roca.mesh = meshTemp;
        Debug.Log(FuncTablero.formateaTiempo() + ": Completado. Construyendo collider...");
        //Se añade el collider aqui, para que directamente tenga la mesh adecuada
        objetoRoca.AddComponent <MeshCollider>();
        objetoRoca.GetComponent <MeshCollider>().sharedMesh = meshTemp;
        Debug.Log(FuncTablero.formateaTiempo() + ": Completado. Calculando y extruyendo vertices del oceano...");
        MeshFilter Agua     = objetoOceano.GetComponent <MeshFilter>();
        Mesh       meshAgua = Agua.mesh;

        meshAgua  = FuncTablero.extruyeVerticesValor(meshAgua, FuncTablero.getNivelAgua(), extrusion, objetoOceano.transform.position);
        Agua.mesh = meshAgua;
        Debug.Log(FuncTablero.formateaTiempo() + ": Completado. Rellenando detalles...");
        //se ajusta la propiedad de nivel de agua del shader
        objetoOceano.renderer.sharedMaterial.SetFloat("_nivelMar", FuncTablero.getNivelAgua());
        objetoOceano.renderer.sharedMaterial.SetFloat("_tamPlaya", FuncTablero.getTamanoPlaya());

        Debug.Log(FuncTablero.formateaTiempo() + ": Terminado. Cargando texturas de habitats...");
        //obtener la textura de habitats del array de materiales de roca. Habitats esta en la 1ª posicion.
        Texture2D texElems = objetoRoca.renderer.sharedMaterials[2].mainTexture as Texture2D;
        //Texture2D texPlantas = objetoRoca.renderer.sharedMaterials[2].mainTexture as Texture2D;
        Texture2D texHabitatsEstetica = objetoRoca.renderer.sharedMaterials[1].mainTexture as Texture2D;
        Texture2D texHabitats         = objetoRoca.renderer.sharedMaterials[1].GetTexture("_FiltroTex") as Texture2D;

        Debug.Log(FuncTablero.formateaTiempo() + ": Terminado. Creando el tablero...");
        Casilla[,] tablero = FuncTablero.iniciaTablero(texturaBase, texHabitats, texHabitatsEstetica, texElems, Roca.mesh, objetoRoca.transform.position);
        Debug.Log(FuncTablero.formateaTiempo() + ": Terminado. Creando Vida...");
        vida = new Vida(tablero, objetoRoca.transform);
        Debug.Log(FuncTablero.formateaTiempo() + ": Completada la creacion del planeta.");
    }
Пример #19
0
        public void InicializarTablero()
        {
            casillas = new Casilla[this.fils, this.cols];
            for (int f = 0; f < this.fils; f++)
            {
                for (int c = 0; c < this.cols; c++)
                {
                    casillas[f, c] = new Casilla();
                }
            }

            InicializarBombas();
            RellenarBorde();
        }
Пример #20
0
    // Use this for initialization
    void Start()
    {
        casillas = new Casilla[tamX, tamY];
        Vector3 pos;
        posIni = transform.position;
        for (int x = 0; x<tamX; x++) {
            for (int y = 0; y<tamY; y++) {
                pos = new Vector3 (posIni.x + (1.2f *x), posIni.y, posIni.z - (1.2f *y));
                GameObject casGO = Instantiate (casillaPrefab, pos, Quaternion.identity) as GameObject;
                casGO.name = "CASILLA "+x+","+y;
                casGO.transform.SetParent(transform);
                Casilla cas = casGO.GetComponent<Casilla>();
                cas.cont = controlador;
                cas.setXY(x,y);
                casillas[x,y] = cas;

            }
        }
         /// TEMPORAL: Poner peones
        for (int x = 0; x<tamX; x++) {
            Ficha fic = Instantiate(fichaEj, Vector3.zero,fichaEj.transform.rotation) as Ficha;
            fic.gameObject.name = "Peon Azul "+x;
            fic.setImage(controlador.imagenesFicha[0]);
            fic.setTurno(1);
            casillas[x,tamY-2].setFicha(fic);
        }
        for (int x = 0; x<tamX; x++) {
            Ficha fic = Instantiate(fichaEj, Vector3.zero,fichaEj.transform.rotation) as Ficha;
            fic.gameObject.name = "Peon Naranja "+x;
            fic.setImage(controlador.imagenesFicha[1]);
            fic.setTurno(0);
            casillas[x,1].setFicha(fic);
        }
        for (int x = 0; x<tamX; x++) {
            Ficha fic = Instantiate(fichaEj, Vector3.zero,fichaEj.transform.rotation) as Ficha;
            fic.gameObject.name = "Arquero Azul "+x;
            fic.setImage(controlador.imagenesFicha[2]);
            fic.setTurno(1);
            casillas[x,tamY-1].setFicha(fic);
        }
        for (int x = 0; x<tamX; x++) {
            Ficha fic = Instantiate(fichaEj, Vector3.zero,fichaEj.transform.rotation) as Ficha;
            fic.gameObject.name = "Arquero Naranja "+x;
            fic.setImage(controlador.imagenesFicha[3]);
            fic.setTurno(0);
            casillas[x,0].setFicha(fic);
        }

        /// FIN TEMPORAL
    }
Пример #21
0
        private void RellenaTablero()
        {
            casillas = new Casilla[fils, cols];
            for (int f = 0; f < fils; f++)
            {
                for (int c = 0; c < cols; c++)
                {
                    casillas[f, c] = new Casilla();
                }
            }

            PonBombas();
            PonUnosEnElBorde();
        }
Пример #22
0
 public void ChangeColor(bool free, Casilla[,] c, int x, int y)
 {
     if (free)
     {
         //verde
         c[x, y].GetComponent <Renderer>().material.color = ConvertColorRGBA(51, 255, 51, 150);
     }
     else
     {
         //rojo
         c[x, y].GetComponent <Renderer>().material.color = ConvertColorRGBA(255, 0, 0, 150);
     }
     GetComponent <Renderer>().enabled = false;
 }
Пример #23
0
        } //Constructora a partir de un archivo

        #region Código para tests de unidad

        /// <summary>
        /// Crea un nuevo tablero de casillas vacías de las dimensiones indicadas.
        /// Crea también el array de personajes (vacío)
        /// </summary>
        /// <param name="nFils">Número de filas del tablero</param>
        /// <param name="nCols">Número de columnas del tablero</param>
        public Tablero(int nFils, int nCols)
        {
            cas  = new Casilla[nFils, nCols];
            COLS = nCols;
            FILS = nFils;
            pers = new Personaje[5];
            for (int i = 0; i < nFils; i++)
            {
                for (int j = 0; j < nCols; j++)
                {
                    cas[i, j] = Casilla.Blanco;
                }
            }
        }
Пример #24
0
        public Tablero(int fils, int cols)
        {
            this.fils = fils + 2;
            this.cols = cols + 2;
            casillas  = new Casilla[this.fils, this.cols];
            for (int f = 0; f < this.fils; f++)
            {
                for (int c = 0; c < this.cols; c++)
                {
                    casillas[f, c] = new Casilla();
                }
            }

            InicializarBombas();
            RellenarBorde();
        }
Пример #25
0
    //genera el tablero y le asigna el tipo correspondiente a cada casilla
    void GenerateBoard()
    {
        tablero = new Casilla[rows * rows, cols *cols];

        for (int i = 0; i < tablero.GetLength(0); i++)
        {
            for (int j = 0; j < tablero.GetLength(1); j++)
            {
                Casilla cas = Instantiate(casillaPrefab, new Vector3(j * casillaPrefab.gameObject.transform.localScale.x * 1.1f, 0, -i * casillaPrefab.gameObject.transform.localScale.z * 1.1f), Quaternion.identity);
                tablero [i, j] = cas;
                cas.Initialize(this, new Position(i, j));
                cas.setOcupada(false);
                cas.setType(matriz[i / matriz.getRows(), j / matriz.getCols()]);
            }
        }
    }
Пример #26
0
 /// <summary>
 /// Crea un nuevo tablero de casillas vacías de las dimensiones indicadas.
 /// Crea también el array de personajes (vacío)
 /// </summary>
 /// <param name="nFils">Número de filas del tablero</param>
 /// <param name="nCols">Número de columnas del tablero</param>
 public Tablero(int nFils, int nCols)
 {
     cas    = new Casilla[nFils, nCols];
     COLS   = nCols;
     FILS   = nFils;
     pers   = new Personaje[5];
     rnd    = new Random();
     celdas = new ListaPares();
     for (int i = 0; i < nFils; i++)
     {
         for (int j = 0; j < nCols; j++)
         {
             cas[i, j] = Casilla.Blanco;
         }
     }
 }
Пример #27
0
 public Tablero(int n, int m)
 {
     this.fils           = n + 2;
     this.cols           = m + 2;
     this.cantidadBombas = 0;
     this.casillas       = new Casilla[this.fils, this.cols];
     for (int f = 0; f < this.fils; f++)
     {
         for (int c = 0; c < this.cols; c++)
         {
             this.casillas[f, c] = new Casilla();
         }
     }
     PonUnosEnElBorde();
     PonBombas();
 }
Пример #28
0
    public void reset()
    {
        tablero = (Casilla[, ])in_tablero.Clone();
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                if (tablero[i, j] != null)
                {
                    tablero[i, j].getCube().transform.position = new Vector3(i * distancia, j * distancia, 0);
                }
            }
        }

        hueco = in_hueco;
    }
Пример #29
0
 private static void recolocarSeresTablero(List <Ser> seresIn, ref Casilla[,] tableroIn)
 {
     for (int i = 0; i < seresIn.Count; i++)
     {
         if (seresIn[i] is Animal)
         {
             tableroIn[seresIn[i].posX, seresIn[i].posY].animal = seresIn[i] as Animal;
         }
         else if (seresIn[i] is Vegetal)
         {
             tableroIn[seresIn[i].posX, seresIn[i].posY].vegetal = seresIn[i] as Vegetal;
         }
         else if (seresIn[i] is Edificio)
         {
             tableroIn[seresIn[i].posX, seresIn[i].posY].edificio = seresIn[i] as Edificio;
         }
     }
 }
Пример #30
0
        internal bool movin = false;//Determina si lo estoy moviendo kon el teclado

        internal kibus(int x, int y, Kibus j)
        {
            juego                = j;
            grid                 = j.grid;
            p.X                  = x * 50 + 205;
            p.Y                  = y * 50 + 15;
            mono                 = new PictureBox();
            mono.Location        = p;
            mono.Size            = new Size(50, 50);
            mono.Image           = Image.FromFile("Resources\\Moves\\F1link.png");
            mono.BackgroundImage = grid[x, y].pic.Image;
            mono.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(PreviewKeyDown);
            mono.Tag             = "F1link";
            dir                  = "F";
            Moves move = new Moves(p, oposite(dir));

            pila.Push(move);
        }
Пример #31
0
        public Tablero(int fils, int cols)
        {
            filas               = fils + 2;
            columnas            = cols + 2;
            nCasillasNoPulsadas = fils * cols;
            fils += 2;
            cols += 2;

            casillas = new Casilla[fils, cols];

            for (int i = 0; i < fils; i++)
            {
                for (int j = 0; j < cols; j++)
                {
                    casillas[i, j] = new Casilla();
                }
            }
            inicializa();
        }
Пример #32
0
        public Tablero(int f, int c)
        {
            //Creamos el tablero con un borde
            casillas      = new Casilla[f + 2, c + 2];
            this.filas    = f + 2;
            this.columnas = c + 2;

            //Rellenamos el tablero con objetos casilla
            for (int i = 0; i < filas; i++)
            {
                for (int j = 0; j < columnas; j++)
                {
                    casillas[i, j] = new Casilla();
                }
            }

            //Inicializar el tablero
            initTablero();
        }
Пример #33
0
 // solo puede crearse una instancia de esta clase
 private Tablero()
 {
     this.casillas = new Casilla [MAXIMO_FILA, MAXIMO_COLUMNA];
     this.InicializarCasillas();
     this.seAgregoLaSalida = false;
 }
Пример #34
0
 public Vida(Casilla[,] tablero, Transform objeto)
 {
     this.tablero = tablero;
     especies = new List<Especie>();
     especiesVegetales = new List<EspecieVegetal>();
     especiesAnimales = new List<EspecieAnimal>();
     tiposEdificios = new List<TipoEdificio>();
     seres = new List<Ser>();
     vegetales = new List<Vegetal>();
     animales = new List<Animal>();
     edificios = new List<Edificio>();
     //numMaxTurnos = 0;
     //turnoActual = 0;
     //listadoSeresTurnos = new List<Ser>[numMaxTurnos];
     idActualVegetal = 0;
     idActualAnimal = 0;
     idActualEdificio = 0;
     objetoRoca = objeto;
     posicionesColindantes = FuncTablero.calculaPosicionesColindantes();
 }
    private void generateMazePrimThread()
    {
        estadoConstruccion = MazeState.THREAD;
        tablero = new Casilla[height, width];

        //inizialization to all walls and no visited
        for (int i = 0; i < height; i++)
        {
            for (int j = 0; j < width; j++)
            {
                tablero[i, j].wallDown = true;
                tablero[i, j].wallUp = true;
                tablero[i, j].wallLeft= true;
                tablero[i, j].wallRight = true;
                tablero[i, j].visited = false;
                tablero[i, j].trampas = false;
            }
        }

        pendientesDeAnalizar = new List<Vector4>();

        pendientesDeAnalizar.Add(new Vector4(casillaComienzo.x-1,casillaComienzo.y,casillaComienzo.x,casillaComienzo.y));

        GestorRandom gr = GestorRandom.getInstance();

        while (pendientesDeAnalizar.Count != 0)
        {
            //we take one randomally
            int index = gr.getNumeroAleatorio(0, pendientesDeAnalizar.Count);
            Vector4 elemSelected = pendientesDeAnalizar[index];
            pendientesDeAnalizar.RemoveAt(index);

            Vector2 origin= new Vector2(elemSelected.x,elemSelected.y);
            Vector2 destiny= new Vector2(elemSelected.z,elemSelected.w);

            if(!tablero[(int)destiny.x, (int)destiny.y].visited)
            {
                tablero[(int)destiny.x, (int)destiny.y].visited = true;
                //if the destiny isn't visited yet
                //remove the wall(carefully with the first case
                //add the destiny 4 wall to the list if they dont go outside the maze
                if(origin.x>=0 &&  origin.y>= 0 && origin.x< height && origin.y< width)
                {
                   if(origin.x == destiny.x)
                   {//left or right
                       if(origin.y> destiny.y)
                       {
                           //left
                           tablero[(int)origin.x, (int)origin.y].wallLeft=false;
                       }
                       else
                       {
                           //right
                           tablero[(int)origin.x, (int)origin.y].wallRight=false;
                       }
                   }
                   else
                   {//up or down
                       if(origin.x> destiny.x)
                       {
                           //up
                           tablero[(int)origin.x, (int)origin.y].wallUp=false;
                       }
                       else
                       {
                           //down
                           tablero[(int)origin.x, (int)origin.y].wallDown=false;
                       }
                   }

                   //remove wall from destiny to origin
                   //caution-> when left-> right, and when up->down
                   if (origin.x == destiny.x)
                   {//left or right
                       if (origin.y > destiny.y)
                       {
                           //right
                           tablero[(int)destiny.x, (int)destiny.y].wallRight = false;
                       }
                       else
                       {
                           //left
                           tablero[(int)destiny.x, (int)destiny.y].wallLeft = false;
                       }
                   }
                   else
                   {//up or down
                       if (origin.x > destiny.x)
                       {
                           //down
                           tablero[(int)destiny.x, (int)destiny.y].wallDown = false;
                       }
                       else
                       {
                           //up
                           tablero[(int)destiny.x, (int)destiny.y].wallUp = false;
                       }
                   }

                }

                //add up
                if(destiny.x-1 >= 0)
                {
                    Vector4 add= new Vector4(destiny.x,destiny.y,destiny.x-1,destiny.y);
                    pendientesDeAnalizar.Add(add);
                }

                //add down
                if(destiny.x+1 < height)
                {
                    Vector4 add= new Vector4(destiny.x,destiny.y,destiny.x+1,destiny.y);
                    pendientesDeAnalizar.Add(add);
                }
                //add left
                if(destiny.y-1 >= 0)
                {
                    Vector4 add= new Vector4(destiny.x,destiny.y,destiny.x,destiny.y-1);
                    pendientesDeAnalizar.Add(add);
                }

                //add right
                if(destiny.y+1 < width)
                {
                    Vector4 add= new Vector4(destiny.x,destiny.y,destiny.x,destiny.y+1);
                    pendientesDeAnalizar.Add(add);
                }

            }

        }
        estadoConstruccion = MazeState.INSTANCIANDO;
    }
    private void generateMazeKruskalThread()
    {
        estadoConstruccion = MazeState.THREAD;
        tablero = new Casilla[height, width];
        List<Vector4> listaParedes = new List<Vector4>();
        List<HashSet<int>> arraySet = new List<HashSet<int>>();
        int cuenta = 0;
        for (int i = 0; i < height; i++)
        {
            for (int j = 0; j < width; j++)
            {
                tablero[i, j].wallDown = true;
                tablero[i, j].wallUp = true;
                tablero[i, j].wallLeft = true;
                tablero[i, j].wallRight = true;
                tablero[i, j].visited = false;
                tablero[i, j].trampas = false;

                HashSet<int> aux = new HashSet<int>();
                aux.Add(cuenta);
                arraySet.Add(aux);
                cuenta++;
                if (i - 1 >= 0)
                {
                    //up
                    listaParedes.Add(new Vector4(i, j, i - 1, j));
                }
                if (j - 1 >= 0)
                {
                    //left
                    listaParedes.Add(new Vector4(i, j, i, j-1));
                }
                if (i + 1 < height)
                {
                    //down
                    listaParedes.Add(new Vector4(i, j, i + 1, j));
                }
                if (j + 1 < width)
                {
                    //right
                    listaParedes.Add(new Vector4(i, j, i,j + 1));
                }

            }
        }
        GestorRandom gr = GestorRandom.getInstance();
        while (listaParedes.Count != 0)
        {
            int paredAEliminarIndex = gr.getNumeroAleatorio(0, listaParedes.Count);
            Vector4 paredAEliminar = listaParedes[paredAEliminarIndex];
            Vector4 popuesta = new Vector4(paredAEliminar.z, paredAEliminar.w, paredAEliminar.x, paredAEliminar.y);
            listaParedes.RemoveAt(paredAEliminarIndex);
            listaParedes.Remove(popuesta);

            int idOrigen = (int)(paredAEliminar.x * width + paredAEliminar.y);
            int idDestino = (int)(paredAEliminar.z * width + paredAEliminar.w);

            int idSetOrigen = findInSet(idOrigen, arraySet);
            int idSetDestino = findInSet(idDestino, arraySet);

            if (idSetDestino!= idSetOrigen)
            {
                HashSet<int> setDestino = arraySet[idSetDestino];
                arraySet[idSetOrigen].UnionWith(setDestino);
                arraySet.RemoveAt(idSetDestino);

                Vector2 origin = new Vector2(paredAEliminar.x , paredAEliminar.y);
                Vector2 destiny = new Vector2(paredAEliminar.z, paredAEliminar.w);

                //eliminar la pared
                if (origin.x == destiny.x)
                {//left or right
                    if (origin.y > destiny.y)
                    {
                        //left
                        tablero[(int)origin.x, (int)origin.y].wallLeft = false;
                    }
                    else
                    {
                        //right
                        tablero[(int)origin.x, (int)origin.y].wallRight = false;
                    }
                }
                else
                {//up or down
                    if (origin.x > destiny.x)
                    {
                        //up
                        tablero[(int)origin.x, (int)origin.y].wallUp = false;
                    }
                    else
                    {
                        //down
                        tablero[(int)origin.x, (int)origin.y].wallDown = false;
                    }
                }

                //remove wall from destiny to origin
                //caution-> when left-> right, and when up->down
                if (origin.x == destiny.x)
                {//left or right
                    if (origin.y > destiny.y)
                    {
                        //right
                        tablero[(int)destiny.x, (int)destiny.y].wallRight = false;
                    }
                    else
                    {
                        //left
                        tablero[(int)destiny.x, (int)destiny.y].wallLeft = false;
                    }
                }
                else
                {//up or down
                    if (origin.x > destiny.x)
                    {
                        //down
                        tablero[(int)destiny.x, (int)destiny.y].wallDown = false;
                    }
                    else
                    {
                        //up
                        tablero[(int)destiny.x, (int)destiny.y].wallUp = false;
                    }
                }

            }
        }

        estadoConstruccion = MazeState.INSTANCIANDO;
    }
    private void noWallThread()
    {
        estadoConstruccion = MazeState.THREAD;
        tablero = new Casilla[height, width];

        //inizialization to all walls and no visited
        for (int i = 0; i < height; i++)
        {
            for (int j = 0; j < width; j++)
            {
                tablero[i, j].wallDown = false;
                tablero[i, j].wallUp = false;
                tablero[i, j].wallLeft = false;
                tablero[i, j].wallRight = false;
                tablero[i, j].visited = false;
            }
        }
        estadoConstruccion = MazeState.INSTANCIANDO;
    }
Пример #38
0
 public Vida(Casilla[,] tablero)
 {
     this.tablero = tablero;
     especies = new List<Especie>();
     especiesVegetales = new List<EspecieVegetal>();
     especiesAnimales = new List<EspecieAnimal>();
     tiposEdificios = new List<TipoEdificio>();
     seres = new List<Ser>();
     vegetales = new List<Vegetal>();
     animales = new List<Animal>();
     edificios = new List<Edificio>();
     idActualVegetal = 0;
     idActualAnimal = 0;
     idActualEdificio = 0;
     posicionesColindantes = FuncTablero.calculaPosicionesColindantes();
 }
Пример #39
0
 public Vida(Vida vida)
 {
     objetoRoca = vida.objetoRoca;
     tablero = vida.tablero;
     especies = vida.especies;
     especiesVegetales = vida.especiesVegetales;
     especiesAnimales = vida.especiesAnimales;
     tiposEdificios = vida.tiposEdificios;
     seres = vida.seres;
     vegetales = vida.vegetales;
     animales = vida.animales;
     edificios = vida.edificios;
     //numMaxTurnos = vida.numMaxTurnos;
     //turnoActual = vida.turnoActual;
     //listadoSeresTurnos = vida.listadoSeresTurnos;
     idActualVegetal = vida.idActualVegetal;
     idActualAnimal = vida.idActualAnimal;
     idActualEdificio = vida.idActualEdificio;
     posicionesColindantes = FuncTablero.calculaPosicionesColindantes();
 }