Exemple #1
0
 public Pieza this[Casilla casilla]  // ok
 {
     get
     {
         return(this.tablero[casilla.Fila, casilla.Columna]);
     }
 }
Exemple #2
0
    public bool esSalto(Casilla casilla_destino)
    {
        int[] coord_provista = casilla_destino.getXY();
        int[] coord_destino  = pos_salto.Find(l => l.SequenceEqual(coord_provista));
        pos_relativa = pos_salto.FindIndex(l => l.SequenceEqual(coord_provista));

        if (coord_destino != null)
        {
            if (coord_provista.SequenceEqual(coord_destino))
            {
                Debug.Log("Coordenada provista " + coord_provista[0] + ", " + coord_provista[1]);
                Debug.Log("Posible coordenada contigua " + coord_destino[0] + ", " + coord_destino[1]);
                Debug.Log("ATENCION" + (casilla_destino.getXY())[0] + " " + (casilla_destino.getXY())[1]);
                return(true);
            }
            else
            {
                return(false);
            }
        }
        else
        {
            return(false);
        }
    }
Exemple #3
0
        public void CambiarTurnoTest3()
        {
            Service servicio = new Service(() => handler);

            Casilla[] casillas = new Casilla[100];
            for (int i = 0; i < 100; i++)
            {
                casillas[i] = servicio.CrearCasilla(i, i, i);
            }
            servicio.PartidasEnJuego.Add("1", new ServiceSYE.Partida {
                Nombre  = "prueba",
                Turno   = 2,
                Tablero = new Tablero {
                    Casillas = casillas,
                }
            });;;;
            Dictionary <IClientePartida, Jugador> jugadoresPartidas = new Dictionary <IClientePartida, Jugador>();

            jugadoresPartidas.Add(handler, new Jugador {
                NombreUsuario = "JosuePrueba",
                Turno         = new Turno {
                    NumeroTurno = 1,
                    Casilla     = new Casilla {
                        Numero    = 4,
                        Bonus     = false,
                        PosicionX = 0,
                        PosicionY = 0,
                    }
                }
            });;
            servicio.PartidasEnJuego["1"].JugadoresPartida = jugadoresPartidas;
            servicio.CambiarTurno("1", 4, 4);
            Assert.AreEqual(1, servicio.PartidasEnJuego["1"].Turno);
        }
        private static void swap(ref List <Casilla> casillas, int indexOne, int indexTwo)
        {
            Casilla log = casillas[indexOne];

            casillas[indexOne] = casillas[indexTwo];
            casillas[indexTwo] = log;
        }
Exemple #5
0
        static Tablero CargarEstado()
        {
            StreamReader leer = new StreamReader("guardar.txt");
            int          fils = int.Parse(leer.ReadLine());
            int          cols = int.Parse(leer.ReadLine());

            Casilla[,] casilleros = new Casilla[fils, cols];
            for (int a = 0; a < fils; a++)
            {
                for (int b = 0; b < cols; b++)
                {
                    casilleros [a, b].estado = (char)leer.Read();
                }
                leer.ReadLine();
            }
            for (int a = 0; a < fils; a++)
            {
                for (int b = 0; b < cols; b++)
                {
                    if ((char)leer.Read() == 'b')
                    {
                        casilleros [a, b].mina = true;
                    }
                }
            }
            leer.Close();
            Tablero tab = new Tablero {
                cas = casilleros, posX = 0, posY = 0
            };

            return(tab);
        }
Exemple #6
0
    public int hayIndustriasAdyacentes(Casilla casilla)
    {
        int numeroIndustriasAdyacentes = 0;

        Vector2Int[] v = new Vector2Int[4];
        v[0] = new Vector2Int(casilla.getPosicionMatrizX(), casilla.getPosicionMatrizZ() + 1);
        v[1] = new Vector2Int(casilla.getPosicionMatrizX(), casilla.getPosicionMatrizZ() - 1);
        v[2] = new Vector2Int(casilla.getPosicionMatrizX() + 1, casilla.getPosicionMatrizZ());
        v[3] = new Vector2Int(casilla.getPosicionMatrizX() - 1, casilla.getPosicionMatrizZ());


        for (int i = 0; i < v.Length; i++)
        {
            if (v[i].x >= 0 && v[i].x < numCol && v[i].y < numFil && v[i].y >= 0)
            {
                Casilla cas = matrizCasillas[v[i].x, v[i].y];

                if (cas.getFicha() != null && cas.getFicha().tag == "Industria")
                {
                    numeroIndustriasAdyacentes++;
                }
            }
        }
        return(numeroIndustriasAdyacentes);
    }
Exemple #7
0
 public void Pintar_Casilla(int i, Casilla csl)
 {
     if (((Casilla)panel1.Controls[i]).Pieza.Color != csl.Pieza.Color)
     {
         panel1.Controls[i].BackColor = Color.FromArgb(60, 0, 0, 255);
     }
 }
Exemple #8
0
        public void crearTablero()
        {
            Size    _size = new Size(panel1.Width / 8, panel1.Height / 8);
            Point   p;
            Tablero tablero = new Tablero();

            for (int f = 0; f < 8; f++)
            {
                for (int c = 0; c < 8; c++)
                {
                    p                   = new Point(f, c);
                    csl[f, c]           = new Casilla();
                    csl[f, c].Pieza     = tablero.nuevaPieza[f, c];
                    csl[f, c].Size      = _size;
                    csl[f, c].Pos       = p;
                    csl[f, c].Location  = new Point(c * _size.Width, f * _size.Height);
                    csl[f, c].Clr       = (c + f) % 2 == 0 ? Color.Gray : Color.White;
                    csl[f, c].BackColor = csl[f, c].Clr;

                    csl[f, c].Click += new EventHandler(this.button_Click);
                    panel1.Controls.Add(csl[f, c]);


                    if (tablero.nuevaPieza[f, c] != null)
                    {
                        csl[f, c].BackgroundImage       = tablero.nuevaPieza[f, c].Img;
                        csl[f, c].BackgroundImageLayout = ImageLayout.Zoom;
                    }
                }
            }

            tableros.Add(tablero);
        }
Exemple #9
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     perdiste = 0;
     for (int f = 0; f < tablero.GetLength(0); f++)
     {
         for (int c = 0; c < tablero.GetLength(1); c++)
         {
             Casilla casilla = (Casilla)tablero[f, c].Tag;
             tablero[f, c].Image = casilla.Imagen;
         }
     }
     for (int f = 0; f < tablero.GetLength(0); f++)
     {
         for (int c = 0; c < tablero.GetLength(1); c++)
         {
             Casilla casilla = (Casilla)tablero[f, c].Tag;
             if (casilla.Valor != 0)
             {
                 perdiste++;
             }
         }
     }
     if (perdiste == 16)
     {
         o++;
     }
     if (o == 2)
     {
         MessageBox.Show("Perdiste", "Perdiste",
                         MessageBoxButtons.OK);
         timer1.Stop();
     }
 }
Exemple #10
0
 // Al dar click a la ficha, comprueba la casilla en donde esta e ilumina las casillas disponibles para moverse
 private void OnMouseDown()
 {
     if (control.ActualTurn == control.MyTurn)
     {
         Debug.Log("Click a ficha" + this.gameObject.name.ToString());
         if (control.SeleccionCasilla == false && control.Color == gameObject.tag)
         {
             control.FichaSeleccionada = this.gameObject;
             Casilla scriptCasilla = casilla.GetComponent <Casilla>();
             control.SeleccionCasilla = true;
             control.CasillasValidas  = scriptCasilla.obtenerCasillasDisponibles();
             if (Lobby.instance.Prediction)
             {
                 scriptCasilla.iluminarCasillasDisponibles();
             }
         }
         else
         {
             Debug.Log("Ficha no valida para movimiento");
             Debug.Log("Fase seleccion casilla: " + control.SeleccionCasilla);
             Debug.Log("Color jugador: " + control.Color + "  /  Color ficha: " + gameObject.tag);
         }
     }
     else
     {
         Debug.Log(control.ActualTurn + ": turno actual / turno jugador: " + control.MyTurn);
     }
 }
    private void moverPiezaTurnoNegro()
    {
        if (casillaEstaSelecionada == false)
        {
            //Se mira si hay pieza en la casilla y si esta es NEGRA, si es así se seleciona
            casillaOrigen = selecionarCasilla();
            if (casillaOrigen != null)
            {
                if (hayPieza() != null && hayPieza().GetComponent <Pieza>().getEsBlanca() == false)
                {
                    casillaOrigen.casillaSelecionada = true;
                    casillaOrigen.colorSelecion      = new Color(0, 1, 0);
                    casillaEstaSelecionada           = true;
                }
            }
            //Se coloca pieza, segundo disparo
        }
        else
        {
            if (hayPieza() == null)
            {
                casillaDestino = selecionarCasilla();
                Pieza pieza = casillaOrigen.getPieza();
                Debug.Log(pieza);
                //Colocar la pieza selecionada en su nuevo destino
                tablero.moverPieza(pieza, casillaDestino.getx(), casillaDestino.gety());
                casillaEstaSelecionada = false;

                tablero.turnoBlanco = true;
                //pintar la casilla como estaba originalmente
                casillaOrigen.casillaSelecionada = false;
                casillaOrigen.colorSelecion      = casillaOrigen.colorOriginal;
            }
        }
    }
    private Casilla crearCasillaArray(Vector3 posicion, int tipo)
    {
        GameObject go_casilla;
        Casilla    casilla;
        Vector3    temp;

        if (tipo == Constantes._ABIERTOS)
        {
            go_casilla = GameObject.Instantiate <GameObject> (casilla_abiertos);
        }
        else
        {
            go_casilla = GameObject.Instantiate <GameObject> (casilla_cerrados);
        }

        //La altura de la casilla independiente de la del vector posicion
        temp   = posicion;
        temp.y = 0.01f;
        go_casilla.transform.position = temp;

        //Hacemos la casilla visible poniendo y a 1
        temp   = go_casilla.transform.localScale;
        temp.y = 1;
        go_casilla.transform.localScale = temp;

        casilla = new Casilla(posicion, tipo, go_casilla);

        return(casilla);
    }
        private void SelectItem(Ficha itemToSelect)
        {
            //Se verifica si es el turno del jugador rojo para jugar

            itemToSelect.IsSelected = true;

            Vector2 posDestino = CurrentMousePosition;

            // Se crea un tablero para saber la posicion de la casilla en la que se dio click
            Tablero t1 = new Tablero(Game.Content, _spriteBatch, Game);
            Vector2 posFichaSeleccionada = itemToSelect.Position;

            for (int y = 0; y < t1.Casillas.GetLength(0); y++)
            {
                for (int x = 0; x < t1.Casillas.GetLength(1); x++)
                {
                    Casilla casillaEvaluada = t1.Casillas[x, y];

                    /*  Si el puntero esta dentro de una casilla, ponle la posicion de esa casilla
                     *  al objeto seleccionado.  */
                    if ((posDestino.X > casillaEvaluada.Posicion.X && posDestino.X <= casillaEvaluada.Posicion.X + 80) && (posDestino.Y > casillaEvaluada.Posicion.Y && posDestino.Y <= casillaEvaluada.Posicion.Y + 80))
                    {
                        // Se insertan las posibles posiciones para mover y capturar fichas.
                        itemToSelect.canMove(posFichaSeleccionada, casillaEvaluada.Posicion, _items);
                    }
                }
            }
            _selectedItems.Add(itemToSelect);
        }
Exemple #14
0
        static Tablero creaTablero(int fils, int cols, int numMinas)
        {
            Random rand = new Random();

            Casilla[,] casilleros = new Casilla[fils, cols];
            for (int a = 0; a < fils; a++)
            {
                for (int b = 0; b < cols; b++)
                {
                    casilleros [a, b].estado = 'o';
                }
            }

            Tablero tab = new Tablero {
                cas = casilleros, posX = 0, posY = 0
            };

            int fila, columna, i = 0;

            while (i < numMinas)
            {
                fila    = rand.Next(0, fils);
                columna = rand.Next(0, cols);
                if (!tab.cas [fila, columna].mina)
                {
                    tab.cas [fila, columna].mina = true;
                    i++;
                }
            }
            return(tab);
        }
Exemple #15
0
 public void GetCurrentCasilla()
 {
     //Debug.Log ("Hola1");
     casillaActual        = GetTargetCasilla(gameObject);
     casillaActual.actual = true;
     Debug.Log("Actual : " + casillaActual);
 }
Exemple #16
0
    public void FindCasillasSeleccionables()
    {
        listaCasillasAdjuntas();
        GetCurrentCasilla();
        int             count   = 0;
        Queue <Casilla> proceso = new Queue <Casilla>();

        proceso.Enqueue(casillaActual);
        casillaActual.visited = true;
        while (proceso.Count > 0)
        {
            Casilla c = proceso.Dequeue();
            casillasSeleccionables.Add(c);
            c.seleccionable = true;

            if (c.distance < movimiento)
            {
                foreach (Casilla casilla in c.adyacentes)
                {
                    if (!casilla.visited)
                    {
                        casilla.parent   = c;
                        casilla.visited  = true;
                        casilla.distance = 1 + c.distance;
                        proceso.Enqueue(casilla);
                        count++;
                    }
                }
                //Debug.Log ("Contador2 :" + count);
            }
        }
    }
Exemple #17
0
 public Casilla(Casilla ligaConsecutiva, GameObject bloque)
 {
     indicador            = null;
     ligaIndicadora       = null;
     this.ligaConsecutiva = ligaConsecutiva;
     this.bloque          = bloque;
 }
Exemple #18
0
    //se mueve a una casilla si puede. Si la sala esta vacia, pasa turno
    public bool Move(Position p)
    {
        Casilla cas = GameManager.instance.getCasilla(p);

        if (myTurn && !cas.getOcupada() && currNumActions < numMaxActions)
        {
            print("dandole wey");
            GameManager.instance.MoveTo(this.gameObject, actualCas, cas);
            actualCas = cas;

            print("Hay " + suspInPlace.Count + " sospechosos conmigo");

            //comprobar cosas......
            if (suspInPlace.Count == 0)   //testeo
            {
                GameManager.instance.changeTurn(this.order);
            }
            else
            {
                currNumActions++;
            }
        }

        return(cas.getOcupada());
    }
Exemple #19
0
    public void matar()
    {
        int     distancia     = 100;
        Pos     posZombie     = new Pos();
        Casilla zombieCercano = new Casilla();

        //BUSCO SOLDADO CERCANO
        foreach (TilePR3 zom in zombies)
        {
            posZombie = zom.estado.Posicion;
            int distAux = costManhatan(posZombie, heroe);
            if (distancia > distAux)
            {
                zombieCercano = zom.estado;
                distancia     = distAux;
            }
        }
        //AVANZO Y COMPRUEBO SI LUCHA
        Pair <int, int> movNecesario = new Pair <int, int>(zombieCercano.Posicion.i - heroe.i, zombieCercano.Posicion.j - heroe.j);

        if (mueveHeroe(movNecesario))
        {
            actualizaTablero();
        }
    }
Exemple #20
0
 public Nodo()
 {
     casilla  = new Casilla();
     coste    = 1;
     conocida = false;
     segura   = false;
 }
Exemple #21
0
        public void CrearTablero()
        {
            for (int f = 0; f < tablero.GetLength(0); f++)
            {
                for (int c = 0; c < tablero.GetLength(1); c++)
                {
                    PictureBox pbx = new PictureBox();
                    pbx.Size        = new Size(100, 100);
                    pbx.BackColor   = Color.White;
                    pbx.BorderStyle = BorderStyle.Fixed3D;
                    pbx.SizeMode    = PictureBoxSizeMode.StretchImage;
                    Casilla casilla = new Casilla();
                    casilla.Imagen = null;
                    casilla.Valor  = 0;
                    pbx.Tag        = casilla;
                    tablero[f, c]  = pbx;
                }
            }

            for (int f = 0; f < tablero.GetLength(0); f++)
            {
                for (int c = 0; c < tablero.GetLength(1); c++)
                {
                    tablero[f, c].Location = new Point(posX, posY);
                    panel1.Controls.Add(tablero[f, c]);
                    posX += 100;
                }
                posY += 100;
                posX  = 0;
            }
        }
Exemple #22
0
 public IArmadura(double precio, Casilla c, String nombre, Rareza rareza, int bonificador, int durabilidad, int armadura) : base(precio, c, nombre, rareza, bonificador)
 {
     this.durabilidad       = durabilidad;
     this.durabilidadMaxima = durabilidad;
     this.armadura          = armadura + this.bonificador;
     this.roto = false;
 }
Exemple #23
0
    //se mueve a una casilla random de la sala en la que se encuentra el jugador que le llama.
    public void CallSuspect()
    {
        if (GameManager.instance.CanInteract())
        {
            Player playerActive = GameManager.instance.getPlayerActive();

            if (playerActive.getCurrNumAct() < playerActive.numMaxActions && playerActive.GetPlace() != (GameManager.Place) this.getActualCas().getType())                 //si no es la misma instancia...
            //move to a random block
            {
                List <Casilla> l = GameManager.instance.getCasillasInPlace((GameManager.Place)playerActive.GetPlace());

                System.Random rnd = GameManager.instance.getRandomSeed();

                int     c   = 0;
                Casilla cas = null;

                do
                {
                    c   = rnd.Next(0, l.Count);
                    cas = l[c];
                } while (cas.getOcupada());
                Casilla prevCas = this.getActualCas();
                setActualCas(cas);
                GameManager.instance.MoveTo(this.gameObject, prevCas, cas);
                this.Accuse();
                playerActive.increaseCount();
            }
        }
    }
Exemple #24
0
 public bool AgregarObjeto(Item item, int cantidad)
 {
     DeterminarSiguienteCasillaVacia();
     //El inventario está lleno? El objeto a agregar es apilable? Si es apilable, tengo una copia de este en mi inventario?
     if ((item.apilable && !objetos.Contains(item) && !inventarioLleno) || (!item.apilable && !inventarioLleno))
     {
         //Nuestro item es apilable y no tenemos copia de el o nuestro objeto no es apilable  (tenemo espacio en el inventario)
         Casilla casillaAñadir = casillas[casillaVacia];
         objetos.Add(item);
         casillaAñadir.AgregarObjeto(item, cantidad);
         return(true);
     }
     else if (item.apilable == true && objetos.Contains(item))
     {
         //Nuestro objeto es apilable y tenemos una copia de el en alguna casilla
         for (int i = 0; i < casillas.Length; i++)
         {
             if (item == casillas[i].itemAlmacenado)
             {
                 casillas[i].cantidadStock += cantidad;
                 break;
             }
         }
         return(true);
     }
     else
     {
         Debug.Log("InventarioLleno");
         return(false);
     }
 }
Exemple #25
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]);
            }
        }
    }
    void BuildMatrix()
    {
        //matrixCasillas = new Casilla[filas, columnas];
        for (var x = 0; x < filas; x++)
        {
            for (var y = 0; y < columnas; y++)
            {
                Vector2    v       = new Vector2(x, y); //Position on the "matrix"
                Candy      myCandy = RandomCandy();
                GameObject go      = Instantiate(btn_prefab);
                go.name = x + "," + y;
                go.transform.SetParent(canvas_parent, false);
                go.transform.localPosition = new Vector3(x * 100, y * 100, 0);
                go.transform.localScale    = Vector3.one;

                matrixCasillas[v] = new Casilla
                {
                    candy          = myCandy,
                    on             = true,
                    myTransform    = go.transform,
                    myImage        = go.transform.GetChild(0).GetComponent <Image>(),
                    matrixPosition = new Vector2(x, y)
                };
                matrixCasillas[v].myImage.sprite = SpriteByCandy(myCandy);
            }
        }
        workingPhase = false;
    }
Exemple #27
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;
         }
     }
 }
Exemple #28
0
        static void Mueve(ref Tablero tab, char dir)
        {
            int a1 = 0;
            int a2 = 0;
            int b1 = 0;
            int b2 = 0;

            if (Siguiente(tab.jugX, tab.jugY, dir, tab, out a1, out a2))
            {
                Casilla c1 = tab.fijas[a1, a2];
                if (c1 == Casilla.Libre || c1 == Casilla.Destino)
                {
                    if (tab.cajas[a1, a2])
                    {
                        if (Siguiente(a1, a2, dir, tab, out b1, out b2))
                        {
                            Casilla c2 = tab.fijas[b1, b2];
                            if ((c2 == Casilla.Libre || c2 == Casilla.Destino) && !tab.cajas[b1, b2])
                            {
                                tab.jugX          = a1;
                                tab.jugY          = a2;
                                tab.cajas[a1, a2] = false;
                                tab.cajas[b1, b2] = true;
                            }
                        }
                    }
                    else
                    {
                        tab.jugX = a1;
                        tab.jugY = a2;
                    }
                }
            }
        }
Exemple #29
0
        public void Debe_UltimaCasillaDeTerceraFila_SerH3Negro()
        {
            Casilla casilla = _tablero.Casillas[23];

            Assert.AreEqual(Columna.H, casilla.Columna);
            Assert.AreEqual(3, casilla.Fila);
            Assert.AreEqual(Color.NEGRO, casilla.Color);
        }
Exemple #30
0
        public void Debe_PrimeraCasillaDeTerceraFila_SerA3Blanco()
        {
            Casilla casilla = _tablero.Casillas[16];

            Assert.AreEqual(Columna.A, casilla.Columna);
            Assert.AreEqual(3, casilla.Fila);
            Assert.AreEqual(Color.BLANCO, casilla.Color);
        }
    public void seleccionarCasilla(Casilla c)
    {
        if (hayFichaSeleccionada) {
            if (c != null) {
                if (hayCasSeleccionada){
                    casSeleccionada.seleccionada = false;
                }

                casSeleccionada = c;
                if (hayFichaSeleccionada && c.GetComponent<Renderer>().material.color == Color.green){
                    fichaSeleccionada.sobre= c;
                    c.setFicha(fichaSeleccionada);
                    fichaSeleccionada.clicar();
                }
                Debug.Log ("Casilla seleccionada: " + c.x + "," + c.y);
                hayCasSeleccionada = true;
            } else {
                Debug.Log ("Casilla deseleccionada");
                hayCasSeleccionada = false;
            }
            turno = (turno+1)%2;
            textoTurno.text = "Turno del jugador: "+(turno+1);
        }
    }
Exemple #32
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();
 }
 /* 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;
         }
     }
 }
Exemple #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 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;
         }
     }
 }
 /* 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;
         }
     }
 }