Exemple #1
0
    // Selección de la bandera
    private void MarcaBandera()
    {
        // Marcamos y pintamos la ficha como seleccionada
        this.SetSeleccionada(1);

        MoverFicha.DesactivarGiro();
        MoverFicha.DesmarcarCasillas(); // Para desmarcar las casillas que hubieran podido estar marcadas por una selección previa


        //Desmarcamos la fichas que pudieran haberse seleccionado previamente
        GameObject[] fichas = null;
        if (ControlTurno.GetTurnoJugador() == 0)
        {
            fichas = GameObject.FindGameObjectsWithTag("FichasJugador1");
        }
        if (ControlTurno.GetTurnoJugador() == 1)
        {
            fichas = GameObject.FindGameObjectsWithTag("FichasJugador2");
        }
        foreach (GameObject ficha in fichas)
        {
            if (ficha.GetComponent <MoverFicha>().GetSeleccionada() == 1)
            {
                if (ControlTurno.GetTurnoJugador() == 0)
                {
                    ficha.GetComponent <MoverFicha>().PonerElementoBlanco(ficha);
                }
                if (ControlTurno.GetTurnoJugador() == 1)
                {
                    ficha.GetComponent <MoverFicha>().PonerElementoNegro(ficha);
                }
                ficha.GetComponent <MoverFicha>().SetSeleccionada(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();
     }
 }
 // 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);
             }
         }
     }
 }
Exemple #4
0
    // Al iniciar pone las fichas y banderas con los elementos correspondientes si ya se habían seleccionado
    void Start()
    {
        // Desactivamos el panel de victoria
        IniciaPartida.panelVictoria = GameObject.Find("Fondo");
        IniciaPartida.panelVictoria.SetActive(false);
        IniciaPartida.estaPausado = 0;

        // Desactivamos el panel de Salir
        IniciaPartida.panelSalir = GameObject.Find("FondoSalir");
        IniciaPartida.panelSalir.SetActive(false);

        GameObject bandera = null;

        GameObject[] fichas = null;
        int[,,] datosFichas = new int[2, 9, 2];
        // Añadimos al array todas las fichas y la bandera del jugador 1

        datosFichas = FichaSeleccionada.GetFichasJugadores();
        FichaSeleccionada.SetCara(0);
        ControlTurno.SetTurnoJugador(0);
        fichas = GameObject.FindGameObjectsWithTag("FichasJugador1");
        foreach (GameObject ficha in fichas)
        {
            // recorremos todas las fichas asignando el elemento y añadiendo a las fichas seleccionadas
            if (datosFichas[ControlTurno.GetTurnoJugador(), (ficha.GetComponent <numFichaJugador>().idFicha) - 1, FichaSeleccionada.GetCara()] == 1)
            {
                CambiaObjeto.AsignaFuegoBlanco(ficha);
            }

            if (datosFichas[ControlTurno.GetTurnoJugador(), (ficha.GetComponent <numFichaJugador>().idFicha) - 1, FichaSeleccionada.GetCara()] == 2)
            {
                CambiaObjeto.AsignaAguaBlanca(ficha);
            }

            if (datosFichas[ControlTurno.GetTurnoJugador(), (ficha.GetComponent <numFichaJugador>().idFicha) - 1, FichaSeleccionada.GetCara()] == 3)
            {
                CambiaObjeto.AsignaMaderaBlanca(ficha);
            }
            this.InicializaFicha(ficha, datosFichas);
        }
        bandera = GameObject.FindGameObjectWithTag("BanderaJugador1");
        bandera.GetComponent <MoverBandera>().SetCasillaBandera(5);

        // Añadimos al array todas las fichas y la bandera del jugador 2
        ControlTurno.SetTurnoJugador(1);
        fichas = GameObject.FindGameObjectsWithTag("FichasJugador2");
        //datosFichas = FichaSeleccionada.GetFichasJugadores();
        foreach (GameObject ficha in fichas)
        {
            // recorremos todas las fichas asignando el elemento y añadiendo a las fichas seleccionadas
            if (datosFichas[ControlTurno.GetTurnoJugador(), (ficha.GetComponent <numFichaJugador>().idFicha) - 1, FichaSeleccionada.GetCara()] == 1)
            {
                CambiaObjeto.AsignaFuegoNegro(ficha);
            }

            if (datosFichas[ControlTurno.GetTurnoJugador(), (ficha.GetComponent <numFichaJugador>().idFicha) - 1, FichaSeleccionada.GetCara()] == 2)
            {
                CambiaObjeto.AsignaAguaNegra(ficha);
            }

            if (datosFichas[ControlTurno.GetTurnoJugador(), (ficha.GetComponent <numFichaJugador>().idFicha) - 1, FichaSeleccionada.GetCara()] == 3)
            {
                CambiaObjeto.AsignaMaderaNegra(ficha);
            }
            this.InicializaFicha(ficha, datosFichas);
        }
        bandera = GameObject.FindGameObjectWithTag("BanderaJugador2");
        bandera.GetComponent <MoverBandera>().SetCasillaBandera(20);

        // Preparamos el tueno y el botón de giro
        ControlTurno.SetTurnoJugador(0);
        MoverFicha.DesactivarGiro();
    }
 // Cambiamos el turno del jugador
 public void CambioTurno()
 {
     MoverFicha.DesactivarGiro();
     MoverFicha.DesmarcarCasillas();
     StartCoroutine(Pausa());
 }
    // Recorremos las casillas a pintar según el jugador y la ficha en la que está la ficha
    private void IluminarCasillas()
    {
        MoverFicha.DesmarcarCasillas();
        int fila = 0;

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

        if (fila == 1 && ControlTurno.GetTurnoJugador() == 0)
        {
            foreach (GameObject casilla in casillas)
            {
                if (this.GetCasillaFicha() + 3 == casilla.GetComponent <numCasillaTablero>().GetIdCasilla() ||
                    this.GetCasillaFicha() + 4 == casilla.GetComponent <numCasillaTablero>().GetIdCasilla() ||
                    this.GetCasillaFicha() + 1 == casilla.GetComponent <numCasillaTablero>().GetIdCasilla())
                {
                    this.PintaCasilla(casilla);
                }
            }
        }
        if (fila == 2 && ControlTurno.GetTurnoJugador() == 0)
        {
            foreach (GameObject casilla in casillas)
            {
                if (this.GetCasillaFicha() - 1 == casilla.GetComponent <numCasillaTablero>().GetIdCasilla() ||
                    this.GetCasillaFicha() + 1 == casilla.GetComponent <numCasillaTablero>().GetIdCasilla() ||
                    this.GetCasillaFicha() + 2 == casilla.GetComponent <numCasillaTablero>().GetIdCasilla() ||
                    this.GetCasillaFicha() + 3 == casilla.GetComponent <numCasillaTablero>().GetIdCasilla() ||
                    this.GetCasillaFicha() + 4 == casilla.GetComponent <numCasillaTablero>().GetIdCasilla())
                {
                    this.PintaCasilla(casilla);
                }
            }
        }
        if (fila == 3 && ControlTurno.GetTurnoJugador() == 0)
        {
            foreach (GameObject casilla in casillas)
            {
                if (this.GetCasillaFicha() - 1 == casilla.GetComponent <numCasillaTablero>().GetIdCasilla() ||
                    this.GetCasillaFicha() + 2 == casilla.GetComponent <numCasillaTablero>().GetIdCasilla() ||
                    this.GetCasillaFicha() + 3 == casilla.GetComponent <numCasillaTablero>().GetIdCasilla())
                {
                    this.PintaCasilla(casilla);
                }
            }
        }

        if (fila == 1 && ControlTurno.GetTurnoJugador() == 1)
        {
            foreach (GameObject casilla in casillas)
            {
                if (this.GetCasillaFicha() - 2 == casilla.GetComponent <numCasillaTablero>().GetIdCasilla() ||
                    this.GetCasillaFicha() - 3 == casilla.GetComponent <numCasillaTablero>().GetIdCasilla() ||
                    this.GetCasillaFicha() + 1 == casilla.GetComponent <numCasillaTablero>().GetIdCasilla())
                {
                    this.PintaCasilla(casilla);
                }
            }
        }
        if (fila == 2 && ControlTurno.GetTurnoJugador() == 1)
        {
            foreach (GameObject casilla in casillas)
            {
                if (this.GetCasillaFicha() - 1 == casilla.GetComponent <numCasillaTablero>().GetIdCasilla() ||
                    this.GetCasillaFicha() + 1 == casilla.GetComponent <numCasillaTablero>().GetIdCasilla() ||
                    this.GetCasillaFicha() - 2 == casilla.GetComponent <numCasillaTablero>().GetIdCasilla() ||
                    this.GetCasillaFicha() - 3 == casilla.GetComponent <numCasillaTablero>().GetIdCasilla() ||
                    this.GetCasillaFicha() - 4 == casilla.GetComponent <numCasillaTablero>().GetIdCasilla())
                {
                    this.PintaCasilla(casilla);
                }
            }
        }
        if (fila == 3 && ControlTurno.GetTurnoJugador() == 1)
        {
            foreach (GameObject casilla in casillas)
            {
                if (this.GetCasillaFicha() - 1 == casilla.GetComponent <numCasillaTablero>().GetIdCasilla() ||
                    this.GetCasillaFicha() - 4 == casilla.GetComponent <numCasillaTablero>().GetIdCasilla() ||
                    this.GetCasillaFicha() - 3 == casilla.GetComponent <numCasillaTablero>().GetIdCasilla())
                {
                    this.PintaCasilla(casilla);
                }
            }
        }
    }