void Awake() { rutaArchivo = Application.persistentDataPath + "/datos.dat"; if(estadoJuego==null){ estadoJuego = this; DontDestroyOnLoad(gameObject); }else if(estadoJuego!=this){ Destroy(gameObject); } }
void Awake() { directorioArchivo = Application.persistentDataPath + "/datosJuego.dat"; //Impide que se destruya EstadoObjto al cambiar de escena if (estadoJuego == null) { estadoJuego = this; DontDestroyOnLoad (gameObject); objetos_guardados = Utilidad.crearDiccionarioPuntuacion(); } else if (estadoJuego != this) { Destroy(gameObject); } }
void Awake() { rutaArchivo = Application.persistentDataPath + "/datos.dat"; //carga la ruta de los puntos //condicion para saber si ya hay una instancia del objeto, si la hay //entonces la elimina, sino la crea, asi se pasa un objeto entre escenas if(estadoJuego==null){ estadoJuego = this; DontDestroyOnLoad(gameObject); }else if(estadoJuego!=this){ Destroy(gameObject); } }
public Logro ActualizarLogros(EstadoJuego e) { Logro logroDesbloqueado = null; for (int i = 0; i < logros.Length; i++) { if (!logros[i].desbloqueado) { logros[i].desbloqueado = logros[i].condicion(e); if (logros[i].desbloqueado) { logroDesbloqueado = logros[i]; break; } } } return logroDesbloqueado; }
public ArrayList logrosDesbloqueados(EstadoJuego e) {
// Use this for initialization void Start() { estadoJuego = GetComponent<EstadoJuego>(); }
// Use this for initialization void Start() { rotar = GetComponent<Rotar>(); estadoJuego = ControladorDelJuego.ObtenerComponente<EstadoJuego>("ControladorDelJuego"); }
/// <summary> /// Inicia un nuevo juego. /// </summary> public void IniciarJuego() { double pos = GenerarValor() * (int)JuegoAhorcadoConstantes.TotalPalabras; m_actual = (Palabra)m_diccionario[(int)pos]; m_intentosDisponibles = (int)JuegoAhorcadoConstantes.MaximoIntentos; // Vector de letras jugadas: m_jugadas = new ArrayList(); // Actualizaci[on del estado del juego: m_estado = EstadoJuego.Jugando; }
/// <summary> /// Juega una letra específica. /// </summary> /// <param name="letra">Letra a jugar.</param> /// <returns><em>true</em> si la letra pertenece a la palbra; <em>false</em> en caso contrario.</returns> public bool JugarLetra(Letra letra) { if (m_estado != EstadoJuego.Jugando) { return false; } m_jugadas.Add(letra); bool pertenece = m_actual.EstaLetra(letra); if (!pertenece) { --m_intentosDisponibles; if(m_intentosDisponibles == 0) { m_estado = EstadoJuego.Ahorcado; } } else { if (m_actual.EstaCompleta(m_jugadas)) { m_estado = EstadoJuego.Ganador; } } return pertenece; }
/// <summary> /// Inicializa una instancia de la clase JuegoAhorcado. /// </summary> public JuegoAhorcado() { m_diccionario = new Palabra[(int)JuegoAhorcadoConstantes.TotalPalabras]; m_diccionario[0] = new Palabra("algoritmo"); m_diccionario[1] = new Palabra("contenedora"); m_diccionario[2] = new Palabra("avance"); m_diccionario[3] = new Palabra("ciclo"); m_diccionario[4] = new Palabra("indice"); m_diccionario[5] = new Palabra("instrucciones"); m_diccionario[6] = new Palabra("arreglo"); m_diccionario[7] = new Palabra("vector"); m_diccionario[8] = new Palabra("inicio"); m_diccionario[9] = new Palabra("cuerpo"); m_diccionario[10] = new Palabra("recorrido"); m_diccionario[11] = new Palabra("patron"); m_intentosDisponibles = (int)JuegoAhorcadoConstantes.MaximoIntentos; m_estado = EstadoJuego.NoIniciado; }
// Use this for initialization void Start() { estadoJuego = ControladorDelJuego.ObtenerComponente<EstadoJuego>("ControladorDelJuego"); }
void Start() { // Fijamos el estado del juego estadoJuego = EstadoJuego.Jugando; // Obtenemos el componente Rigidbody2D rigidbodyPollo = GetComponent<Rigidbody2D>(); // Obtenemos el componente Animator animatorPollo = GetComponent<Animator>(); // Obtenemos el AudioSource audioSourcePollo = GetComponent<AudioSource>(); // Obtenemos el Transform del pollo transformPollo = GetComponent<Transform>(); }
void setEstado(EstadoJuego nuevoEstado) { estado = nuevoEstado; }
void moverFicha(int fichaX, int fichaY, int destinoX, int destinoY) { Vector3 posicion; // HACK Caso especial para una ficha que tiene un nombre que colisiona if (destinoX == 11 && destinoY == 0) { posicion = GameObject.Find(destinoX.ToString() + "-" + destinoY.ToString()).GetComponent<MeshCollider>().transform.position; } else { posicion = GameObject.Find(destinoX.ToString() + destinoY.ToString()).GetComponent<MeshCollider>().transform.position; } // Verifico si es un movimiento valido if (validarMovimiento(fichaX, fichaY, destinoX, destinoY, true)) { // Actualizar los valores de la matriz if (MenuController.screenValue == Constants.GAMEMP) { GetComponent<NetworkView>().RPC("setMatrix", RPCMode.All, fichaX, fichaY, destinoX, destinoY); } else if (MenuController.screenValue == Constants.GAMESP || MenuController.screenValue == Constants.GAMEMPOFFLINE) { setMatrix(fichaX, fichaY, destinoX, destinoY); } if (selected == ID_Pelota) { if (MenuController.screenValue == Constants.GAMEMP) { GetComponent<NetworkView>().RPC("moverPelotaEnServidorYCliente", RPCMode.All, destinoX, destinoY, posicion); } else if (MenuController.screenValue == Constants.GAMESP || MenuController.screenValue == Constants.GAMEMPOFFLINE) { moverPelotaEnServidorYCliente(destinoX, destinoY, posicion); } } else { // Mover la ficha GameObject.FindWithTag(selected).GetComponent<MatrixAttributes>().x = destinoX; GameObject.FindWithTag(selected).GetComponent<MatrixAttributes>().y = destinoY; GameObject.FindWithTag(selected).transform.position = posicion; } // Deseleccionar la ficha selectDeselectPiece(selected); // Actualizar la posicion de la pelota si se esta moviendo la pelota BoardCell pelota = obtenerPelotaAdyacente(board[destinoX, destinoY]); if (pelota != null && pelota.tieneInfluencia(turno, true)) { estado = EstadoJuego.Pase; selectDeselectPiece(ID_Pelota); } else { estado = EstadoJuego.Juego; bool especial = board[destinoX, destinoY].ficha == TipoFicha.Pelota && board[destinoX, destinoY].especial && board[destinoX, destinoY].equipo != turno; if (especial && !jugadaEspecial) { jugadaEspecial = true; jugadasAI = null; jugadaAI = -1; pases -= 1; } else { if (MenuController.screenValue == Constants.GAMEMP) { GetComponent<NetworkView>().RPC("cambiarTurno", RPCMode.All); } else if (MenuController.screenValue == Constants.GAMESP || MenuController.screenValue == Constants.GAMEMPOFFLINE) { cambiarTurno(); } } } } }