Ejemplo n.º 1
0
 // dependiendo de si la casilla destino está ocupada o no, y qué ficha la ocupa, pintaremos de verde o rojo la casilla
 void PintaCasilla(GameObject casilla)
 {
     if (casilla.GetComponent <numCasillaTablero>().GetEstaOcupada() == 0)
     {
         CambiaObjeto.PintaVerde(casilla);
         casilla.GetComponent <numCasillaTablero>().SetEstaIluminada(1);
     }
     if (casilla.GetComponent <numCasillaTablero>().GetEstaOcupada() == 1 && casilla.GetComponent <numCasillaTablero>().GetJugadorOcupa() == 0 && ControlTurno.GetTurnoJugador() == 1)
     {
         GameObject[] fichas = null;
         fichas = GameObject.FindGameObjectsWithTag("FichasJugador1");
         foreach (GameObject ficha in fichas)
         {
             if (PuedoTomar(this.gameObject, ficha) == 1 && ficha.GetComponent <MoverFicha>().GetCasillaFicha() == casilla.GetComponent <numCasillaTablero>().GetIdCasilla())
             {
                 CambiaObjeto.PintaRojo(casilla);
                 casilla.GetComponent <numCasillaTablero>().SetEstaIluminada(2);
             }
         }
     }
     if (casilla.GetComponent <numCasillaTablero>().GetEstaOcupada() == 1 && casilla.GetComponent <numCasillaTablero>().GetJugadorOcupa() == 1 && ControlTurno.GetTurnoJugador() == 0)
     {
         GameObject[] fichas = null;
         fichas = GameObject.FindGameObjectsWithTag("FichasJugador2");
         foreach (GameObject ficha in fichas)
         {
             if (PuedoTomar(this.gameObject, ficha) == 1 && ficha.GetComponent <MoverFicha>().GetCasillaFicha() == casilla.GetComponent <numCasillaTablero>().GetIdCasilla())
             {
                 CambiaObjeto.PintaRojo(casilla);
                 casilla.GetComponent <numCasillaTablero>().SetEstaIluminada(2);
             }
         }
     }
 }
Ejemplo n.º 2
0
 // Set Seleccionado
 public void SetSeleccionada(int valor)
 {
     this.seleccionada = valor;
     if (valor == 1)
     {
         CambiaObjeto.PintaVerde(this.gameObject);
     }
     if (valor == 0 && ControlTurno.GetTurnoJugador() == 0)
     {
         CambiaObjeto.PintaNegro(this.gameObject);
     }
     if (valor == 0 && ControlTurno.GetTurnoJugador() == 1)
     {
         CambiaObjeto.PintaBlanco(this.gameObject);
     }
 }
Ejemplo n.º 3
0
 // Al seleccionar una ficha, la iluminamos en verde, activamos el giro y pintamos las casillas donde se puede mover
 private void SeleccionFicha()
 {
     CambiaObjeto.PintaVerde(this.gameObject);
     this.SetSeleccionada(1);
     MoverFicha.ActivarGiro();
     if (this.GetTieneBandera() == 1)
     {
         // si la ficha seleccionada tiene la bandera se marcará solo la casilla frente a la ficha si está libre
         this.IluminarCasillasFichaBandera();
     }
     else
     {
         // si la ficha no tiene la bandera marcaremos los posibles destinos de la ficha distinguiendo si es solo moviemiento o si puede comer
         this.IluminarCasillas();
     }
 }
Ejemplo n.º 4
0
 // Indicamos las casillas a las que la ficha con la bandera se puede mover
 private void IluminarCasillasFichaBandera()
 {
     MoverFicha.DesmarcarCasillas();
     GameObject[] casillas = null;
     casillas = GameObject.FindGameObjectsWithTag("Casilla");
     foreach (GameObject casilla in casillas)
     {
         if ((this.GetCasillaFicha() + 3 == casilla.GetComponent <numCasillaTablero>().GetIdCasilla() && ControlTurno.GetTurnoJugador() == 0) ||
             (this.GetCasillaFicha() - 3 == casilla.GetComponent <numCasillaTablero>().GetIdCasilla() && ControlTurno.GetTurnoJugador() == 1))
         {
             if (casilla.GetComponent <numCasillaTablero>().GetEstaOcupada() == 0)
             {
                 CambiaObjeto.PintaVerde(casilla);
                 casilla.GetComponent <numCasillaTablero>().SetEstaIluminada(1);
             }
         }
     }
 }
Ejemplo n.º 5
0
    // Iluminamos las fichas a las que podemos pasar la bandera
    private void IluminarFichas()
    {
        int fila = 0;

        GameObject[] casillas = null;
        casillas = GameObject.FindGameObjectsWithTag("Casilla");
        foreach (GameObject casilla in casillas)
        {
            if (this.GetCasillaBandera() == casilla.GetComponent <numCasillaTablero>().GetIdCasilla())
            {
                fila = casilla.GetComponent <numCasillaTablero>().GetFilaCasilla();
            }
        }

        if (ControlTurno.GetTurnoJugador() == 0)
        {
            GameObject[] fichas = null;
            fichas = GameObject.FindGameObjectsWithTag("FichasJugador1");
            foreach (GameObject ficha in fichas)
            {
                if (fila == 1)
                {
                    if (this.GetCasillaBandera() + 3 == ficha.GetComponent <MoverFicha>().GetCasillaFicha() ||
                        this.GetCasillaBandera() + 4 == ficha.GetComponent <MoverFicha>().GetCasillaFicha() ||
                        this.GetCasillaBandera() + 1 == ficha.GetComponent <MoverFicha>().GetCasillaFicha())
                    {
                        CambiaObjeto.PintaVerde(ficha);
                        ficha.GetComponent <MoverFicha>().SetSeleccionada(1);
                    }
                }
                if (fila == 2)
                {
                    if (this.GetCasillaBandera() - 1 == ficha.GetComponent <MoverFicha>().GetCasillaFicha() ||
                        this.GetCasillaBandera() + 1 == ficha.GetComponent <MoverFicha>().GetCasillaFicha() ||
                        this.GetCasillaBandera() + 2 == ficha.GetComponent <MoverFicha>().GetCasillaFicha() ||
                        this.GetCasillaBandera() + 3 == ficha.GetComponent <MoverFicha>().GetCasillaFicha() ||
                        this.GetCasillaBandera() + 4 == ficha.GetComponent <MoverFicha>().GetCasillaFicha())
                    {
                        CambiaObjeto.PintaVerde(ficha);
                        ficha.GetComponent <MoverFicha>().SetSeleccionada(1);
                    }
                }
                if (fila == 3)
                {
                    if (this.GetCasillaBandera() - 1 == ficha.GetComponent <MoverFicha>().GetCasillaFicha() ||
                        this.GetCasillaBandera() + 2 == ficha.GetComponent <MoverFicha>().GetCasillaFicha() ||
                        this.GetCasillaBandera() + 3 == ficha.GetComponent <MoverFicha>().GetCasillaFicha())
                    {
                        CambiaObjeto.PintaVerde(ficha);
                        ficha.GetComponent <MoverFicha>().SetSeleccionada(1);
                    }
                }
            }
        }

        if (ControlTurno.GetTurnoJugador() == 1)
        {
            GameObject[] fichas = null;
            fichas = GameObject.FindGameObjectsWithTag("FichasJugador2");
            foreach (GameObject ficha in fichas)
            {
                if (fila == 1)
                {
                    if (this.GetCasillaBandera() + 1 == ficha.GetComponent <MoverFicha>().GetCasillaFicha() ||
                        this.GetCasillaBandera() - 2 == ficha.GetComponent <MoverFicha>().GetCasillaFicha() ||
                        this.GetCasillaBandera() - 3 == ficha.GetComponent <MoverFicha>().GetCasillaFicha())
                    {
                        ficha.GetComponent <MoverFicha>().PonerElementoBlanco(ficha);
                        CambiaObjeto.PintaVerde(ficha);
                        ficha.GetComponent <MoverFicha>().SetSeleccionada(1);
                    }
                }
                if (fila == 2)
                {
                    if (this.GetCasillaBandera() - 1 == ficha.GetComponent <MoverFicha>().GetCasillaFicha() ||
                        this.GetCasillaBandera() + 1 == ficha.GetComponent <MoverFicha>().GetCasillaFicha() ||
                        this.GetCasillaBandera() - 2 == ficha.GetComponent <MoverFicha>().GetCasillaFicha() ||
                        this.GetCasillaBandera() - 3 == ficha.GetComponent <MoverFicha>().GetCasillaFicha() ||
                        this.GetCasillaBandera() - 4 == ficha.GetComponent <MoverFicha>().GetCasillaFicha())
                    {
                        ficha.GetComponent <MoverFicha>().PonerElementoBlanco(ficha);
                        CambiaObjeto.PintaVerde(ficha);
                        ficha.GetComponent <MoverFicha>().SetSeleccionada(1);
                    }
                }
                if (fila == 3)
                {
                    if (this.GetCasillaBandera() - 3 == ficha.GetComponent <MoverFicha>().GetCasillaFicha() ||
                        this.GetCasillaBandera() - 4 == ficha.GetComponent <MoverFicha>().GetCasillaFicha() ||
                        this.GetCasillaBandera() - 1 == ficha.GetComponent <MoverFicha>().GetCasillaFicha())
                    {
                        ficha.GetComponent <MoverFicha>().PonerElementoBlanco(ficha);
                        CambiaObjeto.PintaVerde(ficha);
                        ficha.GetComponent <MoverFicha>().SetSeleccionada(1);
                    }
                }
            }
        }
    }
Ejemplo n.º 6
0
    // Control de la seleccion de elementos
    private void OnMouseUp()
    {
        int numFichasSeleccionadas = FichaSeleccionada.GetTotalFichasSeleccionadas();

        ////foreach (int i in FichaSeleccionada.GetFichasSeleccionadas())
        // Sonido botón menú
        this.GetComponent <Elementos>().SonidoSeleccion();

        // si no hay fichas del jugador seleccionadas marcaremos y/o desmarcaremos el elemento seleccionado. solo puede haber uno
        if (numFichasSeleccionadas == 0)
        {
            if (elementoSeleccionado == this.GetComponent <Elementos>().idElemento)
            {
                CambiaObjeto.PintaBlanco(this.gameObject);
                ElementoSeleccionado.SetElementoSeleccionado(0);
            }
            else
            {
                if (elementoSeleccionado == 1)
                {
                    CambiaObjeto.PintaBlanco(fuego.gameObject);
                }
                if (elementoSeleccionado == 2)
                {
                    CambiaObjeto.PintaBlanco(agua.gameObject);
                }
                if (elementoSeleccionado == 3)
                {
                    CambiaObjeto.PintaBlanco(madera.gameObject);
                }
                CambiaObjeto.PintaVerde(this.gameObject);
                ElementoSeleccionado.SetElementoSeleccionado(this.GetComponent <Elementos>().idElemento);
            }
        }
        else
        // Si hay fichas del jugador seleccionadas, las pondremos del material correspondiente al elemento y quitaremos todas las selecciones
        {
            GameObject[] fichas = null;
            // Añadimos al array todas las fichas del jugador
            if (FichaSeleccionada.GetJugador() == 0)
            {
                fichas = GameObject.FindGameObjectsWithTag("FichasJugador1");
            }
            if (FichaSeleccionada.GetJugador() == 1)
            {
                fichas = GameObject.FindGameObjectsWithTag("FichasJugador2");
            }

            elementoSeleccionado = this.GetComponent <Elementos>().idElemento;
            foreach (GameObject ficha in fichas)
            {
                if (FichaSeleccionada.GetFichasSeleccionadas()[ficha.GetComponent <numFichaJugador>().idFicha - 1] == 1)
                {
                    // recorremos todas las fichas asignando el elemento y añadiendo a las fichs seleccionadas
                    if (FichaSeleccionada.GetJugador() == 0)
                    {
                        if (ElementoSeleccionado.GetElementoSeleccionado() == 1)
                        {
                            CambiaObjeto.AsignaFuegoBlanco(ficha);
                        }

                        if (ElementoSeleccionado.GetElementoSeleccionado() == 2)
                        {
                            CambiaObjeto.AsignaAguaBlanca(ficha);
                        }

                        if (ElementoSeleccionado.GetElementoSeleccionado() == 3)
                        {
                            CambiaObjeto.AsignaMaderaBlanca(ficha);
                        }
                    }
                    if (FichaSeleccionada.GetJugador() == 1)
                    {
                        if (ElementoSeleccionado.GetElementoSeleccionado() == 1)
                        {
                            CambiaObjeto.AsignaFuegoNegro(ficha);
                        }

                        if (ElementoSeleccionado.GetElementoSeleccionado() == 2)
                        {
                            CambiaObjeto.AsignaAguaNegra(ficha);
                        }

                        if (ElementoSeleccionado.GetElementoSeleccionado() == 3)
                        {
                            CambiaObjeto.AsignaMaderaNegra(ficha);
                        }
                    }
                    FichaSeleccionada.SetFichaJugador(ficha);
                }
            }
            ElementoSeleccionado.SetElementoSeleccionado(0);
            FichaSeleccionada.InicializaFichasSeleccionadas();
        }
    }
Ejemplo n.º 7
0
    static protected int jugador;                                // 0 o 1

    // Comportamiento al pinchar
    private void OnMouseUp()
    {
        this.GetComponent <numFichaJugador>().SonidoSeleccion();
        // Si no hay elemento seleccionado permitiremos ir seleccionando o deseleccinando varias fichas del jugador1
        if (ElementoSeleccionado.GetElementoSeleccionado() == 0)
        {
            // Si la ficha no estaba seleccionada la marcamos de verde, si ya estaba seleccionada la ponemos blanca
            if (fichasSeleccionadas[this.GetComponent <numFichaJugador>().idFicha - 1] == 0)
            {
                if (FichaSeleccionada.GetJugador() == 1 && FichaSeleccionada.fichasJugadores[FichaSeleccionada.GetJugador(), this.GetComponent <numFichaJugador>().idFicha - 1, FichaSeleccionada.GetCara()] > 0)
                {
                    if (FichaSeleccionada.fichasJugadores[FichaSeleccionada.GetJugador(), this.GetComponent <numFichaJugador>().idFicha - 1, FichaSeleccionada.GetCara()] == 1)
                    {
                        CambiaObjeto.AsignaFuegoBlanco(this.gameObject);
                    }

                    if (FichaSeleccionada.fichasJugadores[FichaSeleccionada.GetJugador(), this.GetComponent <numFichaJugador>().idFicha - 1, FichaSeleccionada.GetCara()] == 2)
                    {
                        CambiaObjeto.AsignaAguaBlanca(this.gameObject);
                    }

                    if (FichaSeleccionada.fichasJugadores[FichaSeleccionada.GetJugador(), this.GetComponent <numFichaJugador>().idFicha - 1, FichaSeleccionada.GetCara()] == 3)
                    {
                        CambiaObjeto.AsignaMaderaBlanca(this.gameObject);
                    }
                }

                CambiaObjeto.PintaVerde(this.gameObject);
                fichasSeleccionadas[this.GetComponent <numFichaJugador>().idFicha - 1] = 1;
                totalFichasSeleccionadas++;
            }
            else
            {
                if (FichaSeleccionada.GetJugador() == 0)
                {
                    CambiaObjeto.PintaBlanco(this.gameObject);
                }
                if (FichaSeleccionada.GetJugador() == 1 && FichaSeleccionada.fichasJugadores[FichaSeleccionada.GetJugador(), this.GetComponent <numFichaJugador>().idFicha - 1, FichaSeleccionada.cara] == 0)
                {
                    CambiaObjeto.PintaGris(this.gameObject);
                }
                if (FichaSeleccionada.GetJugador() == 1 && FichaSeleccionada.fichasJugadores[FichaSeleccionada.GetJugador(), this.GetComponent <numFichaJugador>().idFicha - 1, FichaSeleccionada.cara] > 0)
                {
                    if (FichaSeleccionada.fichasJugadores[FichaSeleccionada.GetJugador(), this.GetComponent <numFichaJugador>().idFicha - 1, FichaSeleccionada.GetCara()] == 1)
                    {
                        CambiaObjeto.AsignaFuegoNegro(this.gameObject);
                    }

                    if (FichaSeleccionada.fichasJugadores[FichaSeleccionada.GetJugador(), this.GetComponent <numFichaJugador>().idFicha - 1, FichaSeleccionada.GetCara()] == 2)
                    {
                        CambiaObjeto.AsignaAguaNegra(this.gameObject);
                    }

                    if (FichaSeleccionada.fichasJugadores[FichaSeleccionada.GetJugador(), this.GetComponent <numFichaJugador>().idFicha - 1, FichaSeleccionada.GetCara()] == 3)
                    {
                        CambiaObjeto.AsignaMaderaNegra(this.gameObject);
                    }
                }

                fichasSeleccionadas[this.GetComponent <numFichaJugador>().idFicha - 1] = 0;
                totalFichasSeleccionadas--;
            }
        }
        else
        // Si hay un elemento seleccionado, cambiaremos el material de la ficha
        {
            // Si la ficha ya tiene ese elemento se lo quitaremos
            if (ElementoSeleccionado.GetElementoSeleccionado() == fichasJugadores[FichaSeleccionada.GetJugador(), this.GetComponent <numFichaJugador>().idFicha - 1, FichaSeleccionada.GetCara()])
            {
                CambiaObjeto.QuitaMaterial(this.gameObject);
                fichasJugadores[FichaSeleccionada.GetJugador(), this.GetComponent <numFichaJugador>().idFicha - 1, FichaSeleccionada.GetCara()] = 0;
            }
            else // Si la ficha no tiene ese elemento, le asignaremos el elemento seleccionado independientemente del elemento que tuviera la ficha anteriormente
            {
                if (FichaSeleccionada.GetJugador() == 0)
                {
                    if (ElementoSeleccionado.GetElementoSeleccionado() == 1)
                    {
                        CambiaObjeto.AsignaFuegoBlanco(this.gameObject);
                    }

                    if (ElementoSeleccionado.GetElementoSeleccionado() == 2)
                    {
                        CambiaObjeto.AsignaAguaBlanca(this.gameObject);
                    }

                    if (ElementoSeleccionado.GetElementoSeleccionado() == 3)
                    {
                        CambiaObjeto.AsignaMaderaBlanca(this.gameObject);
                    }
                }
                if (FichaSeleccionada.GetJugador() == 1)
                {
                    if (ElementoSeleccionado.GetElementoSeleccionado() == 1)
                    {
                        CambiaObjeto.AsignaFuegoNegro(this.gameObject);
                    }

                    if (ElementoSeleccionado.GetElementoSeleccionado() == 2)
                    {
                        CambiaObjeto.AsignaAguaNegra(this.gameObject);
                    }

                    if (ElementoSeleccionado.GetElementoSeleccionado() == 3)
                    {
                        CambiaObjeto.AsignaMaderaNegra(this.gameObject);
                    }
                }
                FichaSeleccionada.SetFichaJugador(this.gameObject);
            }
        }
    }