Ejemplo n.º 1
0
    public static string GetStringAsSetUsingDelimiter(string key, char separator, string defaultValue)
    {
        string list = EncryptedPlayerPrefs.GetString(key, "");

        if (list.Equals(""))
        {
            return(defaultValue);
        }

        string[] entries = list.Split(separator);

        System.Collections.ArrayList newList = new System.Collections.ArrayList();

        foreach (string str in entries)
        {
            if (!newList.Contains(str))
            {
                newList.Add(str);
            }
        }

        string result = "";

        foreach (string entry in newList)
        {
            result = result + entry + separator;
        }

        result.TrimEnd(separator);
        return(result);
    }
Ejemplo n.º 2
0
    public void GetPlayerScores()
    {
        string value = EncryptedPlayerPrefs.GetString("USER", "");

        if (value != "")
        {
            value = value.Replace("{", "");
            value = value.Replace("}", "");
            string[] values = value.Split(delimeter.ToCharArray());
            try
            {
                if (SystemInfo.deviceUniqueIdentifier != values[0])
                {
                    EventResetPlayerScores();
                }
                levelMaximum = int.Parse(values[1]);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                EventResetPlayerScores();
            }
        }
        else
        {
            EventResetPlayerScores();
        }
        GetComponent <MenuManager>().UpdateIndicator(levelMaximum);
    }
    public void LoadTest()
    {
        userInfo.stat.strength     = EncryptedPlayerPrefs.GetInt("Strength", 0);
        userInfo.stat.agility      = EncryptedPlayerPrefs.GetInt("Agility", 0);
        userInfo.stat.constitution = EncryptedPlayerPrefs.GetInt("Constitution", 0);
        userInfo.stat.intelligence = EncryptedPlayerPrefs.GetInt("Intelligence", 0);
        userInfo.stat.remainPoint  = EncryptedPlayerPrefs.GetInt("RemainPoint", 3);

        userInfo.castle.currentADLevel      = EncryptedPlayerPrefs.GetInt("CurrentADLevel", 0);
        userInfo.castle.currentHealthLevel  = EncryptedPlayerPrefs.GetInt("CurrentHealthLevel", 0);
        userInfo.castle.currentDefenseLevel = EncryptedPlayerPrefs.GetInt("CurrentDefenseLevel", 0);
        userInfo.castle.currentSlot         = EncryptedPlayerPrefs.GetInt("CurrentSlot", 1);


        userInfo.gold   = EncryptedPlayerPrefs.GetInt("Gold", 20);
        userInfo.silver = EncryptedPlayerPrefs.GetInt("Silver", 0);


        for (int i = 0; i < 5; i++)
        {
            userInfo.tower.currentTowerLevel[i] = EncryptedPlayerPrefs.GetInt("TowerType" + i, 0);
        }


        userInfo.maxClearStage = EncryptedPlayerPrefs.GetInt("MaxClearStage", 0);
        for (int i = 0; i < userInfo.stageClearInfo.Length; i++)
        {
            userInfo.stageClearInfo[i] = EncryptedPlayerPrefs.GetInt("StageClearInfo" + i, 0);
        }
        userInfo.picturePath = EncryptedPlayerPrefs.GetString("PicturePath", "");

        userInfo.achieveInfo.killEnemyCount  = EncryptedPlayerPrefs.GetInt("killEnemyCount", 0);
        userInfo.achieveInfo.stageClearCount = EncryptedPlayerPrefs.GetInt("stageClearCount", 0);
    }
Ejemplo n.º 4
0
 private string GetToken()
 {
     if (_token == null)
     {
         _token = EncryptedPlayerPrefs.GetString(SavedTokenString, "");
     }
     return(_token);
 }
Ejemplo n.º 5
0
 private string GetUserid()
 {
     if (_userId == null)
     {
         _userId = EncryptedPlayerPrefs.GetString(SavedUseridString, "");
     }
     return(_userId);
 }
Ejemplo n.º 6
0
    /// <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);
    }
Ejemplo n.º 7
0
    public static T Load <T>(string saveKey, bool encrypted = true)
    {
        var aString = "";

        if (encrypted)
        {
            aString = EncryptedPlayerPrefs.GetString(saveKey);
//            Debug.Log("Load: " + saveKey + " : " + aString);
        }
        else
        {
            aString = PlayerPrefs.GetString(saveKey);
        }
        //Debug.Log(aString);
        return(JsonUtility.FromJson <T>(aString));
    }
Ejemplo n.º 8
0
        public override void Init(params object[] param)
        {
            Debug.Log("TwitterConnector Initialization.");
            DebugUtils.Assert(param[0] is string);
            DebugUtils.Assert(param[1] is string);

            oauth_handler_ = new OAuthHandler(param[0] as string, param[1] as string);

            string oauth_token        = EncryptedPlayerPrefs.GetString("oauth_token");
            string oauth_token_secret = EncryptedPlayerPrefs.GetString("oauth_token_secret");

            if (!string.IsNullOrEmpty(oauth_token) && !string.IsNullOrEmpty(oauth_token_secret))
            {
                oauth_handler_.AddParameter("oauth_token", oauth_token);
                oauth_handler_.AddParameter("oauth_token_secret", oauth_token_secret);

                my_info_.id   = EncryptedPlayerPrefs.GetString("user_id");
                my_info_.name = EncryptedPlayerPrefs.GetString("screen_name");

                Debug.Log("Already logged in.");
                OnEventNotify(SNResultCode.kLoggedIn);
            }
        }
Ejemplo n.º 9
0
    // ------------------------------------------------------------------------------
    // ---  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]));
            }
        }
    }