/// <summary>
    /// Comprueba si se ha subido de nivel en alguno de los logros de la lista "_listaLogros" con respecto a lo que hay almacenado en las preferencias
    /// </summary>
    /// <param name="_listaLogros"></param>
    /// <param name="_playerPrefKey"></param>
    /// <param name="_recompensaAcumulada"></param>
    /// <param name="_listIdLogros">Lista a la que se añaden los identificadores de los logros que han subido de nivel recientemente</param>
    /// <returns></returns>
    private bool CheckHayLogrosSinRecompensarEnLista(List <GrupoLogros> _listaLogros, string _playerPrefKey, ref int _recompensaAcumulada, ref List <string> _listIdLogros)
    {
        bool hayLogrosNuevos = false;

        if (EncryptedPlayerPrefs.HasKey(_playerPrefKey) && _listaLogros != null)
        {
            string strLogros = EncryptedPlayerPrefs.GetString(_playerPrefKey);
            if (strLogros != null)
            {
                string[] logros = strLogros.Split(separadores);
                if (logros != null)
                {
                    for (int i = 0; i < logros.Length; ++i)
                    {
                        string[] infoLogro = logros[i].Split(separadoresIgual);
                        if (infoLogro != null && infoLogro.Length == 2)
                        {
                            bool logroEncontrado = false;
                            for (int j = 0; (j < _listaLogros.Count) && (!logroEncontrado); ++j)
                            {
                                if (_listaLogros[j].prefijoComunIdLogros == infoLogro[0])
                                {
                                    logroEncontrado = true;
                                    int nivelAlmacenado = int.Parse(infoLogro[1]);
                                    if (_listaLogros[j].nivelAlcanzado > nivelAlmacenado)
                                    {
                                        // indicar que hay nuevos logros en la lista
                                        hayLogrosNuevos = true;

                                        // acumular la recompensa
                                        _recompensaAcumulada += _listaLogros[j].GetRecompensaAcumulada(nivelAlmacenado, _listaLogros[j].nivelAlcanzado);

                                        // meter en la lista de dialogos los dialogos conseguidos
                                        for (int k = nivelAlmacenado; k < _listaLogros[j].nivelAlcanzado; k++)
                                        {
                                            _listIdLogros.Add(_listaLogros[j].GetLogro(k).id);
                                        }

                                        _listaLogros[j].subidaNivelReciente = true; // <= indicar que en este grupo de logros ha habido una subida de nivel
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        return(hayLogrosNuevos);
    }
Exemple #2
0
    private void Awake()
    {
        Screen.SetResolution(1920, 1080, true, 0);
        EncryptedPlayerPrefs.keys    = new string[5];
        EncryptedPlayerPrefs.keys[0] = "fgfkjldjds";
        EncryptedPlayerPrefs.keys[1] = "tu849tu24";
        EncryptedPlayerPrefs.keys[2] = "40kf0rk";
        EncryptedPlayerPrefs.keys[3] = "jg05ji";
        EncryptedPlayerPrefs.keys[4] = "erjeioj";

        if (!EncryptedPlayerPrefs.HasKey("Ending1"))
        {
            for (int i = 1; i <= 20; i++)
            {
                EncryptedPlayerPrefs.SetInt("Ending" + i, 0);
                EncryptedPlayerPrefs.SaveEncryption("Ending" + i, "int", "littlebrother");
            }
        }
    }
    // ------------------------------------------------------------------------------
    // ---  METODOS  ----------------------------------------------------------------
    // ------------------------------------------------------------------------------


    /// <summary>
    /// Carga la informacion almacenada en la preferencias del juego (si no se ha cargado ya antes)
    /// </summary>
    /// <param name="_forzarCarga">Fuerza la carga de las preferencias aunque ya se haya realizado antes</param>
    public void LoadAllData(bool _forzarCarga = false)
    {
        if (_forzarCarga || !m_cargaDatosRealizada)
        {
            Debug.LogWarning(">>> Recupero informacion de las preferencias");

            // comprobar si existen las claves asociadas a los logros (es caso de que no crearlas)
            if (!EncryptedPlayerPrefs.HasKey("logrosLanzador"))
            {
                CreateListaLogrosPlayerPrefs(LogrosManager.logrosLanzador, "logrosLanzador");
                PlayerPrefs.Save();
            }
            if (!EncryptedPlayerPrefs.HasKey("logrosPortero"))
            {
                CreateListaLogrosPlayerPrefs(LogrosManager.logrosPortero, "logrosPortero");
                PlayerPrefs.Save();
            }
            if (!EncryptedPlayerPrefs.HasKey("logrosDuelo"))
            {
                CreateListaLogrosPlayerPrefs(LogrosManager.logrosDuelo, "logrosDuelo");
                PlayerPrefs.Save();
            }

            // obtener el dinero del juego y actualizar el dinero en la barra superior
            Interfaz.SetMonedaSoft_SinPersistencia(EncryptedPlayerPrefs.HasKey("softCurrency") ? EncryptedPlayerPrefs.GetInt("softCurrency") : 0);
            Interfaz.SetMonedaHard_SinPersistencia(EncryptedPlayerPrefs.GetInt("hardCurrency", 0));
            cntBarraSuperior.instance.ActualizarDinero();

            // obtener las mejores puntuaciones
            //Player.record_keeper = (PlayerPrefs.HasKey("goalkeeperRecord")) ? PlayerPrefs.GetInt("goalkeeperRecord") : 0;
            //Player.record_thrower = (PlayerPrefs.HasKey("shooterRecord")) ? PlayerPrefs.GetInt("shooterRecord") : 0;
            Interfaz.m_uname = EncryptedPlayerPrefs.GetString("alias", "");

            // obtener el tiempo de juego
            Interfaz.m_nextTryTime = (EncryptedPlayerPrefs.HasKey("nextTryTime")) ? EncryptedPlayerPrefs.GetInt("nextTryTime") : 0;

            // obtener el avance como portero
            Interfaz.m_asKeeper.record       = EncryptedPlayerPrefs.GetInt("goalkeeperRecord", 0);
            Interfaz.m_asKeeper.targets      = EncryptedPlayerPrefs.GetInt("goalkeeperTargets", 0);
            Interfaz.m_asKeeper.goals        = EncryptedPlayerPrefs.GetInt("goalkeeperGoals", 0);
            Interfaz.m_asKeeper.goalsStopped = EncryptedPlayerPrefs.GetInt("goalkeeperGoalsStopped", 0);
            Interfaz.m_asKeeper.throwOut     = EncryptedPlayerPrefs.GetInt("goalkeeperThrowOut", 0);
            Interfaz.m_asKeeper.totalPoints  = EncryptedPlayerPrefs.GetInt("goalkeeperTotalPoints", 0);
            Interfaz.m_asKeeper.deflected    = EncryptedPlayerPrefs.GetInt("goalkeeperDeflected", 0);
            Interfaz.m_asKeeper.perfects     = EncryptedPlayerPrefs.GetInt("goalkeeperPerfects", 0);

            // obtener el avance como lanzador
            Interfaz.m_asThrower.record       = EncryptedPlayerPrefs.GetInt("shooterRecord", 0);
            Interfaz.m_asThrower.targets      = EncryptedPlayerPrefs.GetInt("shooterTargets", 0);
            Interfaz.m_asThrower.goals        = EncryptedPlayerPrefs.GetInt("shooterGoals", 0);
            Interfaz.m_asThrower.goalsStopped = EncryptedPlayerPrefs.GetInt("shooterGoalsStopped", 0);
            Interfaz.m_asThrower.throwOut     = EncryptedPlayerPrefs.GetInt("shooterThrowOut", 0);
            Interfaz.m_asThrower.totalPoints  = EncryptedPlayerPrefs.GetInt("shooterTotalPoints", 0);
            Interfaz.m_asThrower.deflected    = EncryptedPlayerPrefs.GetInt("shooterDeflected", 0);
            Interfaz.m_asThrower.perfects     = EncryptedPlayerPrefs.GetInt("shooterPerfects", 0);

            // obtener el avance en duelos
            Interfaz.m_duelsPlayed  = EncryptedPlayerPrefs.GetInt("duelsPlayed", 0);
            Interfaz.m_duelsWon     = EncryptedPlayerPrefs.GetInt("duelsWon", 0);
            Interfaz.m_perfectDuels = EncryptedPlayerPrefs.GetInt("perfectDuels", 0);

            // obtener la ultima mision desbloqueada
            Interfaz.ultimaMisionDesbloqueada = EncryptedPlayerPrefs.GetInt("ultimaMisionDesbloqueada", 0);

            // actualizar el estado de desbloqueo de los escudos en funcion de la ultima fase desbloqueada
            EscudosManager.instance.ActualizarEstadoDesbloqueoEscudos(Interfaz.ultimaMisionDesbloqueada);

            // obtener los lanzadores comprados
            if (PlayerPrefs.HasKey("shootersComprados"))
            {
                string strShootersComprados = EncryptedPlayerPrefs.GetString("shootersComprados");
                if (strShootersComprados != null)
                {
                    string[] shootersComprados = strShootersComprados.Split(separadores);
                    if (shootersComprados != null)
                    {
                        for (int i = 0; i < shootersComprados.Length; ++i)
                        {
                            Jugador jugador = InfoJugadores.instance.GetJugador(shootersComprados[i]);
                            if (jugador != null)
                            {
                                jugador.estado = Jugador.Estado.ADQUIRIDO;
                            }
                        }
                    }
                }
            }

            // obtener los porteros comprados
            if (PlayerPrefs.HasKey("goalkeepersComprados"))
            {
                string strGoalkeepersComprados = EncryptedPlayerPrefs.GetString("goalkeepersComprados");
                if (strGoalkeepersComprados != null)
                {
                    string[] goalkeepersComprados = strGoalkeepersComprados.Split(separadores);
                    if (goalkeepersComprados != null)
                    {
                        for (int i = 0; i < goalkeepersComprados.Length; ++i)
                        {
                            Jugador jugador = InfoJugadores.instance.GetJugador(goalkeepersComprados[i]);
                            if (jugador != null)
                            {
                                jugador.estado = Jugador.Estado.ADQUIRIDO;
                                Debug.LogWarning(">>> El jugador " + jugador.nombre + " pasa a estar ADQUIRIDO");
                            }
                        }
                    }
                }
            }

            // obtener equipaciones de lanzador compradas
            if (PlayerPrefs.HasKey("shooterEquipaciones"))
            {
                string strEquipacionesLanzador = EncryptedPlayerPrefs.GetString("shooterEquipaciones");
                if (strEquipacionesLanzador != null)
                {
                    string[] equipacionesLanzador = strEquipacionesLanzador.Split(separadores);
                    if (equipacionesLanzador != null)
                    {
                        for (int i = 0; i < equipacionesLanzador.Length; ++i)
                        {
                            Equipacion equipacion = EquipacionManager.instance.GetEquipacion(equipacionesLanzador[i]);
                            if (equipacion != null)
                            {
                                equipacion.estado = Equipacion.Estado.ADQUIRIDA;
                            }
                        }
                    }
                }
            }

            // obtener equipaciones de portero compradas
            if (PlayerPrefs.HasKey("goalkeeperEquipaciones"))
            {
                string strEquipacionesPortero = EncryptedPlayerPrefs.GetString("goalkeeperEquipaciones");
                if (strEquipacionesPortero != null)
                {
                    string[] equipacionesPortero = strEquipacionesPortero.Split(separadores);
                    if (equipacionesPortero != null)
                    {
                        for (int i = 0; i < equipacionesPortero.Length; ++i)
                        {
                            Equipacion equipacion = EquipacionManager.instance.GetEquipacion(equipacionesPortero[i]);
                            if (equipacion != null)
                            {
                                equipacion.estado = Equipacion.Estado.ADQUIRIDA;
                            }
                        }
                    }
                }
            }

            // obtener los powerups de lanzador comprados
            if (PlayerPrefs.HasKey("pwrUpsLanzador"))
            {
                string strPowerUpsLanzador = EncryptedPlayerPrefs.GetString("pwrUpsLanzador");
                if (strPowerUpsLanzador != null)
                {
                    string[] powerUps = strPowerUpsLanzador.Split(separadores);
                    if (powerUps != null)
                    {
                        for (int i = 0; i < powerUps.Length; ++i)
                        {
                            string[] infoPowerUp = powerUps[i].Split(separadoresIgual);
                            if (infoPowerUp != null && infoPowerUp.Length == 2)
                            {
                                PowerupService.ownInventory.SetCantidadPowerUp(infoPowerUp[0], int.Parse(infoPowerUp[1]));
                            }
                        }
                    }
                }
            }

            // obtener los powerups de portero comprados
            if (PlayerPrefs.HasKey("pwrUpsPortero"))
            {
                string strPowerUpsPortero = EncryptedPlayerPrefs.GetString("pwrUpsPortero");
                if (strPowerUpsPortero != null)
                {
                    string[] powerUps = strPowerUpsPortero.Split(separadores);
                    if (powerUps != null)
                    {
                        for (int i = 0; i < powerUps.Length; ++i)
                        {
                            string[] infoPowerUp = powerUps[i].Split(separadoresIgual);
                            if (infoPowerUp != null && infoPowerUp.Length == 2)
                            {
                                PowerupService.ownInventory.SetCantidadPowerUp(infoPowerUp[0], int.Parse(infoPowerUp[1]));
                            }
                        }
                    }
                }
            }

            // obtener los escudos comprados
            if (PlayerPrefs.HasKey("escudos"))
            {
                string strEscudos = EncryptedPlayerPrefs.GetString("escudos");
                if (strEscudos != null)
                {
                    string[] escudos = strEscudos.Split(separadores);
                    if (escudos != null)
                    {
                        for (int i = 0; i < escudos.Length; ++i)
                        {
                            string[] infoEscudo = escudos[i].Split(separadoresIgual);
                            if (infoEscudo != null && infoEscudo.Length == 2)
                            {
                                Escudo escudo = EscudosManager.instance.GetEscudo(infoEscudo[0]);
                                if (escudo != null)
                                {
                                    escudo.numUnidades = int.Parse(infoEscudo[1]);
                                }
                            }
                        }
                    }
                }
            }

            // fuerza a que si los jugadores y equipaciones seleccionadas actualmente no estan ADQUIRIDOS, sean substidos por unos que si
            ifcVestuario.instance.ComprobarJugadoresYEquipacionesAdquiridos(true);

            // cargar el avance del jugador
            CargarObjetivosMision();



            // actualizar el estado de los jugadores
            InfoJugadores.instance.RefreshJugadoresDesbloqueados(Interfaz.ultimaMisionDesbloqueada);
            EquipacionManager.instance.RefreshEquipacionesDesbloqueadas(Interfaz.ultimaMisionDesbloqueada);

            // indicar que la carga de datos ya se ha realizado una vez
            m_cargaDatosRealizada = true;
        }
        // comprobar si existen logros que aun no han sido registrados
        int           recompensaPendiente = 0;
        List <string> idsLogros           = new List <string>();

        if (PersistenciaManager.instance.CheckHayLogrosSinRecompensar(ref recompensaPendiente, ref idsLogros))
        {
            // mostrar en la barra de opciones una "exclamacion"
            if (cntBarraSuperior.instance != null)
            {
                cntBarraSuperior.instance.MostrarQueHayNuevosLogros();
            }

            // actualizar el dinero
            Interfaz.MonedasHard += recompensaPendiente;

            // actualizar el progreso de los logros para que esta alerta no se dispare mas
            SaveLogros();

            // crear los dialogos para mostrar cada uno de los logros desbloqueados
            for (int i = 0; i < idsLogros.Count; ++i)
            {
                DialogManager.instance.RegistrarDialogo(new DialogDefinition(DialogDefinition.TipoDialogo.LOGRO_DESBLOQUEADO, idsLogros[i]));
            }
        }
    }
Exemple #4
0
 public bool IsUserIdSaved()
 {
     return(EncryptedPlayerPrefs.HasKey(SavedUseridString));
 }