Esempio n. 1
0
        public void Load()
        {
            Scene scene = SceneManager.GetActiveScene();

            foreach (GameObject item in _Objects)
            {
                //Chargement et affectation des couleurs et textures sauvegardés
                float _r = EncryptedPlayerPrefs.GetFloat(item.name + "R", -1f);
                float _g = EncryptedPlayerPrefs.GetFloat(item.name + "G", -1f);
                float _b = EncryptedPlayerPrefs.GetFloat(item.name + "B", -1f);
                float _a = EncryptedPlayerPrefs.GetFloat(item.name + "A", -1f);
                if (_r != -1)
                {
                    Color _color = new Color(_r, _g, _b, _a);
                    item.gameObject.GetComponent <Renderer>().material.SetColor("_Color", _color);
                }
                int _idTexture = EncryptedPlayerPrefs.GetInt(item.name + "Texture", -1);
                if (_idTexture != -1)
                {
                    if (_idTexture != 11)
                    {
                        item.GetComponent <Renderer>().material.SetTexture("_MainTex", _SelectedTexture[_idTexture]);
                        if (scene.name != "Gallerie")
                        {
                            item.GetComponent <Highlight>()._idTexture = _idTexture;
                        }
                    }
                }
            }
        }
    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);
    }
    public void GuardarPartidaSinglePlayer()
    {
        int bitMapProgreso = 0;
        //TODO convertir esto a guardar objetivos de mision
        GameLevelMission gameLevel = MissionManager.instance.GetGameLevelMission(GameplayService.gameLevelMission.MissionName);

        GameplayService.gameLevelMission.UnFreeze();
        MissionAchievement[] retosAntes = GameplayService.gameLevelMission.GetAchievements().ToArray();
        //MissionAchievement[] retosDespues = MissionManager.instance.GetMission().Achievements.ToArray();

        if (gameLevel == null)
        {
            Debug.LogWarning(">>> No hay informacion del nivel " + GameplayService.gameLevelMission.MissionName);
        }
        else
        {
            string claveNivel = "prog" + gameLevel.MissionName;
            bitMapProgreso = EncryptedPlayerPrefs.GetInt(claveNivel, 0);

            for (int i = 0; i < retosAntes.Length; i++)
            {
                int flag = (bitMapProgreso % ((int)Mathf.Pow(10, i + 1))) / (int)Mathf.Pow(10, i);
                if (retosAntes[i].IsAchieved() && (flag == 0)) //importante el isAchieved() primero para que lo haga, evitar el lazy
                {
                    bitMapProgreso += (int)Mathf.Pow(10, retosAntes[i].Code);
                }
            }

            EncryptedPlayerPrefs.SetInt(claveNivel, bitMapProgreso);
        }

        // guardar las preferencias
        PlayerPrefs.Save();
    }
Esempio n. 4
0
    void LoadGameData()
    {
        int temBGMplay = EncryptedPlayerPrefs.GetInt("isBGMplay", 1);

        if (temBGMplay == 1)
        {
            isBGMplay = true;
        }
        else
        {
            isBGMplay = false;
        }

        int temSFXplay = EncryptedPlayerPrefs.GetInt("isSFXplay", 1);

        if (temSFXplay == 1)
        {
            isSFXplay = true;
        }
        else
        {
            isSFXplay = false;
        }

        money = EncryptedPlayerPrefs.GetInt("money", 0);

        level = EncryptedPlayerPrefs.GetInt("level", 1);

        exp    = EncryptedPlayerPrefs.GetInt("exp", 0);
        maxExp = level * 100;

        hairColor = EncryptedPlayerPrefs.GetInt("hairColor", 0);
    }
Esempio n. 5
0
 void Awake()
 {
     isExtra = EncryptedPlayerPrefs.GetInt("extraLives");
     if (isExtra == 1)
     {
         numLifes = 4;
     }
 }
Esempio n. 6
0
 public int GetRecord()
 {
     if (!_isRecordLoaded)
     {
         _isRecordLoaded = true;
         _currentRecord  = EncryptedPlayerPrefs.GetInt(TicketsRecordKey, 0);
     }
     return(_currentRecord);
 }
Esempio n. 7
0
    void Start()
    {
        if (Instance == null)
        {
            Instance = this;
        }

        displayMainMenu       = false;
        displayGameOver       = false;
        displayMainMenuPaused = false;

        sW                 = Screen.width;
        sH                 = Screen.height;
        buttonWidth        = sW * 0.6f;
        buttonHeight       = sH / 20.0f;
        storeKitController = GetComponent <StoreKitController>();

        // always authenticate at every launch
        GameCenterBinding.authenticateLocalPlayer();
        GameCenterBinding.loadLeaderboardTitles();

        //Get in-app purchase product data
        storeKitController.RequestProductData();

        showAds = true;
        int Ads = EncryptedPlayerPrefs.GetInt("removeadverts");

        if (Ads == 1)
        {
            if (EncryptedPlayerPrefs.CheckEncryption("removeadverts", "int", "1"))
            {
                showAds = false;
            }
        }
        else
        {
            //start loading ad
            AdBinding.initializeInterstitial();
            //start iAd
            AdBinding.createAdBanner(true);
        }

        // hack to detect iPad 3 until Unity adds official support
        this.isPad = (Screen.width >= 1536 || Screen.height >= 1536);
        if (isPad)
        {
            customButtonStyle.fontSize    = 64;
            customHighlightStyle.fontSize = 64;
            customPaddedStyle.fontSize    = 64;
        }

        //keep this object in memory
        DontDestroyOnLoad(transform.gameObject);
    }
    /*
     * /// <summary>
     * /// Almacena la informacion del juego
     * /// </summary>
     * public void Save() {
     *  Debug.LogWarning(">>> Almaceno informacion de las preferencias");
     *
     *  // almacenar el tiempo de juego
     *  PlayerPrefs.SetInt("nextTryTime", Interfaz.m_nextTryTime);
     *
     *  // almacenar el avance como portero
     *  PlayerPrefs.SetInt("goalkeeperRecord", Interfaz.m_asKeeper.record);
     *  PlayerPrefs.SetInt("goalkeeperTargets", Interfaz.m_asKeeper.targets);
     *  PlayerPrefs.SetInt("goalkeeperGoals", Interfaz.m_asKeeper.goals);
     *  PlayerPrefs.SetInt("goalkeeperGoalsStopped", Interfaz.m_asKeeper.goalsStopped);
     *  PlayerPrefs.SetInt("goalkeeperThrowOut", Interfaz.m_asKeeper.throwOut);
     *  PlayerPrefs.SetInt("goalkeeperTotalPoints", Interfaz.m_asKeeper.totalPoints);
     *  PlayerPrefs.SetInt("goalkeeperDeflected", Interfaz.m_asKeeper.deflected);
     *  PlayerPrefs.SetInt("goalkeeperPerfects", Interfaz.m_asKeeper.perfects);
     *
     *  // almacenar el avance como lanzador
     *  PlayerPrefs.SetInt("shooterRecord", Interfaz.m_asThrower.record);
     *  PlayerPrefs.SetInt("shooterTargets", Interfaz.m_asThrower.targets);
     *  PlayerPrefs.SetInt("shooterGoals", Interfaz.m_asThrower.goals);
     *  PlayerPrefs.SetInt("shooterGoalsStopped", Interfaz.m_asThrower.goalsStopped);
     *  PlayerPrefs.SetInt("shooterThrowOut", Interfaz.m_asThrower.throwOut);
     *  PlayerPrefs.SetInt("shooterTotalPoints", Interfaz.m_asThrower.totalPoints);
     *  PlayerPrefs.SetInt("shooterDeflected", Interfaz.m_asThrower.deflected);
     *  PlayerPrefs.SetInt("shooterPerfects", Interfaz.m_asThrower.perfects);
     *
     *  // almacenar la ultima mision desbloqueada
     *  PlayerPrefs.SetInt("ultimaMisionDesbloqueada", Interfaz.ultimaMisionDesbloqueada);
     *
     *  PlayerPrefs.Save();
     * }
     */

    public void ActualizarUltimoNivelDesbloqueado(int _nivel)
    {
        int lastSaved = EncryptedPlayerPrefs.GetInt("ultimaMisionDesbloqueada", 0);

        if (_nivel > lastSaved)
        {
            Interfaz.ultimaMisionDesbloqueada = _nivel;
            EncryptedPlayerPrefs.SetInt("ultimaMisionDesbloqueada", _nivel);
            PlayerPrefs.Save();
        }
    }
 private void Start()
 {
     for (int i = 1; i <= 20; ++i)
     {
         string key = "Ending" + i;
         if (EncryptedPlayerPrefs.GetInt(key).Equals(1))
         {
             _screens[i - 1].sprite = _endingThumbnails[i - 1];
         }
     }
 }
Esempio n. 10
0
    public void SaveScore()
    {
        int highS = EncryptedPlayerPrefs.GetInt("highScoore");

        if (EncryptedPlayerPrefs.CheckEncryption("highScoore", "int", highS.ToString()) || highS == 0)
        {
            if (highS < score)
            {
                EncryptedPlayerPrefs.SetInt("highScoore", (int)score);
                MainMenu.Instance.SetHighScore(highS);
            }
        }
    }
    void CargarObjetivosMision()
    {
        foreach (GameLevelMission mision in MissionManager.instance.ListaLevelMissions)
        {
            int bitMap = EncryptedPlayerPrefs.GetInt("prog" + mision.MissionName, 0);

            List <MissionAchievement> listaObjetivos = mision.GetAchievements();
            foreach (MissionAchievement ma in listaObjetivos)
            {
                int flag = (bitMap % ((int)Mathf.Pow(10, ma.Code + 1))) / (int)Mathf.Pow(10, ma.Code);
                if (flag > 0)
                {
                    ma.SetAchieved(true);
                }
            }
        }
    }
    void Start()
    {
        // this array should be filled before you can use EncryptedPlayerPrefs :

        EncryptedPlayerPrefs.keys = new string[5];

        EncryptedPlayerPrefs.keys[0] = "23Wrudre";
        EncryptedPlayerPrefs.keys[1] = "SP9DupHa";
        EncryptedPlayerPrefs.keys[2] = "frA5rAS3";
        EncryptedPlayerPrefs.keys[3] = "tHat2epr";
        EncryptedPlayerPrefs.keys[4] = "jaw3eDAs";


        EncryptedPlayerPrefs.SetInt("test_int", 130);
        int a = EncryptedPlayerPrefs.GetInt("test_int");

        Debug.Log(a);
    }
    public void AcumularRondaMision(Result _result, bool _perfect, int _points, bool _guardarProgresoMision)
    {
        bool goalkeeper = GameplayService.initialGameMode == GameMode.GoalKeeper;

        if (!goalkeeper)
        {
            int record = EncryptedPlayerPrefs.GetInt("shooterRecord", 0);
            if (record < RoundInfoManager.instance.puntos)
            {
                EncryptedPlayerPrefs.SetInt("shooterRecord", RoundInfoManager.instance.puntos);
                Interfaz.m_asThrower.record = RoundInfoManager.instance.puntos;
            }

            if (_points > 0)
            {
                EncryptedPlayerPrefs.SetInt("shooterTotalPoints", PlayerPrefs.GetInt("shooterTotalPoints", 0) + _points);
                Interfaz.m_asThrower.totalPoints += _points;
            }

            if (_perfect)
            {
                EncryptedPlayerPrefs.SetInt("shooterPerfects", PlayerPrefs.GetInt("shooterPerfects", 0) + 1);
                Interfaz.m_asThrower.perfects++;
            }

            switch (_result)
            {
            case Result.Saved:
                EncryptedPlayerPrefs.SetInt("shooterGoalsStopped", EncryptedPlayerPrefs.GetInt("shooterGoalsStopped", 0) + 1); Interfaz.m_asThrower.goalsStopped++; break;

            case Result.Stopped:
                EncryptedPlayerPrefs.SetInt("shooterDeflected", EncryptedPlayerPrefs.GetInt("shooterDeflected", 0) + 1); Interfaz.m_asThrower.deflected++; break;

            case Result.Goal:
                EncryptedPlayerPrefs.SetInt("shooterGoals", EncryptedPlayerPrefs.GetInt("shooterGoals", 0) + 1); Interfaz.m_asThrower.goals++; break;

            case Result.OutOfBounds:
                EncryptedPlayerPrefs.SetInt("shooterThrowOut", EncryptedPlayerPrefs.GetInt("shooterThrowOut", 0) + 1); Interfaz.m_asThrower.throwOut++; break;

            case Result.Target:
                EncryptedPlayerPrefs.SetInt("shooterTargets", EncryptedPlayerPrefs.GetInt("shooterTargets", 0) + 1); Interfaz.m_asThrower.targets++; break;
            }
        }
        else
        {
            int record = EncryptedPlayerPrefs.GetInt("goalkeeperRecord", 0);
            if (record < RoundInfoManager.instance.puntos)
            {
                EncryptedPlayerPrefs.SetInt("goalkeeperRecord", RoundInfoManager.instance.puntos);
                Interfaz.m_asKeeper.record = RoundInfoManager.instance.puntos;
            }

            if (_points > 0)
            {
                EncryptedPlayerPrefs.SetInt("goalkeeperTotalPoints", EncryptedPlayerPrefs.GetInt("goalkeeperTotalPoints", 0) + _points);
                Interfaz.m_asKeeper.totalPoints += _points;
            }

            if (_perfect)
            {
                EncryptedPlayerPrefs.SetInt("goalkeeperPerfects", EncryptedPlayerPrefs.GetInt("goalkeeperPerfects", 0) + 1);
                Interfaz.m_asKeeper.perfects++;
            }

            switch (_result)
            {
            case Result.Saved:
                EncryptedPlayerPrefs.SetInt("goalkeeperGoalsStopped", EncryptedPlayerPrefs.GetInt("goalkeeperGoalsStopped", 0) + 1); Interfaz.m_asKeeper.goalsStopped++; break;

            case Result.Stopped:
                EncryptedPlayerPrefs.SetInt("goalkeeperDeflected", EncryptedPlayerPrefs.GetInt("goalkeeperDeflected", 0) + 1); Interfaz.m_asKeeper.deflected++; break;

            case Result.Goal:
                EncryptedPlayerPrefs.SetInt("goalkeeperGoals", EncryptedPlayerPrefs.GetInt("goalkeeperGoals", 0) + 1); Interfaz.m_asKeeper.goals++; break;

            case Result.OutOfBounds:
                EncryptedPlayerPrefs.SetInt("goalkeeperThrowOut", EncryptedPlayerPrefs.GetInt("goalkeeperThrowOut", 0) + 1); Interfaz.m_asKeeper.throwOut++; break;

            case Result.Target:
                EncryptedPlayerPrefs.SetInt("goalkeeperTargets", EncryptedPlayerPrefs.GetInt("goalkeeperTargets", 0) + RoundInfoManager.instance.numTargets); Interfaz.m_asKeeper.targets++; break;
            }
        }

        if (_guardarProgresoMision)
        {
            MissionAchievement[] retosActuales = MissionManager.instance.GetMission().Achievements.ToArray();
            string claveNivel     = "prog" + GameplayService.gameLevelMission.MissionName;
            int    bitMapProgreso = EncryptedPlayerPrefs.GetInt(claveNivel, 0);

            for (int i = 0; i < retosActuales.Length; i++)
            {
                int flag = (bitMapProgreso % ((int)Mathf.Pow(10, i + 1))) / (int)Mathf.Pow(10, i);
                if ((flag == 0) && retosActuales[i].IsAchieved())
                {
                    bitMapProgreso += (int)Mathf.Pow(10, retosActuales[i].Code);
                }
            }
            EncryptedPlayerPrefs.SetInt(claveNivel, bitMapProgreso);
        }

        PlayerPrefs.Save();
    }
    // ------------------------------------------------------------------------------
    // ---  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]));
            }
        }
    }
Esempio n. 15
0
 public bool HasPurchasedFullTrajectory()
 {
     return(EncryptedPlayerPrefs.GetInt(FULL_TRAJECTORY_KEY) == 1);
 }
Esempio n. 16
0
    void OnClick()
    {
        Debug.Log(this.gameObject.name);

        switch (this.gameObject.name)
        {
        case "2.Sprite (btn_start)":

            if (EncryptedPlayerPrefs.GetInt("DataExist", 0) == 1)
            {
                csUserSaveNLoad.loadFlag = true;

                inventory.SetActive(true);
                stageScene.SetActive(true);
                break;
            }
            else
            {
                csUserSaveNLoad.loadFlag = true;

                userInfo.InitTest();
                inventory.SetActive(true);
                stageScene.SetActive(true);
                break;
            }

        case "4.Sprite (btn_load)":
            if (EncryptedPlayerPrefs.GetInt("DataExist", 0) == 1)
            {
                csUserSaveNLoad.loadFlag = true;
                main.SetActive(false);
                inventory.SetActive(true);
                inventory_Character.SetActive(true);

                Main.currentSceneNumber = 2;
            }
            break;

        case "3.Yes Button":
            Main.currentSceneNumber  = 2;
            csUserSaveNLoad.loadFlag = true;
            userInfo.InitTest();

            warningPopup.SetActive(false);
            main.SetActive(false);
            inventory.SetActive(true);
            inventory_Character.SetActive(true);

            panel1.alpha = 1.0f;
            panel2.alpha = 1.0f;
            break;

        case "4.No Button":
            warningPopup.SetActive(false);
            panel1.alpha = 1.0f;
            panel2.alpha = 1.0f;
            break;

        case "4.Sprite (btn_option)":
            panel1.alpha = 0.5f;
            panel2.alpha = 0.5f;
            Option.SetActive(true);
            break;

        case "8.Sprite (btn_help)":
            panel1.alpha = 0.5f;
            panel2.alpha = 0.5f;
            HelpObj.SetActive(true);
            break;
        }
    }
Esempio n. 17
0
    void OnGUI()
    {
        //PAUSE MENU
        if (displayMainMenu)
        {
            gameOver = false;
            GUI.DrawTextureWithTexCoords(new Rect(0f, 0f, sW, sH), mainMenuBackground, new Rect(0f, 0f, 5f, 5f));
            GUI.DrawTexture(new Rect(sW * 0.2f, sH * 0.1f, sW * 0.6f, sH * 0.1f), gamelogo);

            if (GUI.Button(new Rect((sW - buttonWidth) / 2, sH * 0.3f, buttonWidth, buttonHeight), "RESUME GAME", customHighlightStyle))
            {
                displayMainMenu       = false;
                displayMainMenuPaused = false;
                Camera.main.GetComponent <beeGUI>().dispMenu = true;
                Time.timeScale = 1;
            }

            if (GUI.Button(new Rect((sW - buttonWidth) / 2, sH * 0.4f, buttonWidth, buttonHeight), "LEADERBOARD", customButtonStyle))
            {
                if (GameCenterBinding.isPlayerAuthenticated())
                {
                    if (_hasLeaderboardData)
                    {
                        GameCenterBinding.showGameCenterViewController(GameCenterViewControllerState.Leaderboards);
                    }
                }
                else
                {
                    GameCenterBinding.authenticateLocalPlayer();
                    GameCenterBinding.loadLeaderboardTitles();
                }
            }


            if (GUI.Button(new Rect((sW - buttonWidth) / 2, sH * 0.5f, buttonWidth, buttonHeight), "RATE", customHighlightStyle))
            {
                Application.OpenURL("itms-apps://itunes.apple.com/app/id875911453");
            }


            if (EncryptedPlayerPrefs.GetInt("10xtralives") != 1)
            {
                if (GUI.Button(new Rect((sW - buttonWidth) / 2, sH * 0.6f, buttonWidth, buttonHeight), "EXTRA LIVES", customButtonStyle))
                {
                    displayExtraLives = true;
                    displayMainMenu   = false;
                }
            }


            if (EncryptedPlayerPrefs.GetInt("removeadverts") != 1)
            {
                if (EncryptedPlayerPrefs.GetInt("10xtralives") != 1)
                {
                    if (GUI.Button(new Rect((sW - buttonWidth) / 2, sH * 0.7f, buttonWidth, buttonHeight), "REMOVE ADS", customHighlightStyle))
                    {
                        displayRemoveAds = true;
                        displayMainMenu  = false;
                    }
                }
                else
                {
                    if (GUI.Button(new Rect((sW - buttonWidth) / 2, sH * 0.6f, buttonWidth, buttonHeight), "REMOVE ADS", customButtonStyle))
                    {
                        displayRemoveAds = true;
                        displayMainMenu  = false;
                    }
                }
            }
        }


        //EXTRA LIVES
        if (displayExtraLives)
        {
            GUI.DrawTextureWithTexCoords(rRect(0f, 0f, 1f, 1f), mainMenuBackground, new Rect(0f, 0f, 5f, 5f));
            GUI.DrawTexture(rRect(0.2f, 0.1f, 0.6f, 0.1f), gamelogo);


            if (EncryptedPlayerPrefs.GetInt("10xtralives") != 1)
            {
                GUI.Label(rRect(0.25f, 0.3f, 0.5f, 0.05f), "BUY EXTRA LIVES", customHighlightStyle);
                GUI.Label(rRect(0.125f, 0.35f, 0.75f, 0.25f), "Survive longer each game by buying extra life options. You can buy an extra 3 or a whopping 10 extra lives!", customPaddedStyle);

                if (GUI.Button(rRect(0.125f, 0.6f, 0.375f, 0.05f), "3 EXTRA LIVES", customHighlightStyle))
                {
                    BuyExtraLives();
                }

                if (GUI.Button(rRect(0.5f, 0.6f, 0.375f, 0.05f), "RESTORE", customHighlightStyle))
                {
                    RestoreButtonPressed();
                }

                if (GUI.Button(rRect(0.125f, 0.65f, 0.375f, 0.05f), "10 EXTRA LIVES", customHighlightStyle))
                {
                    Buy10ExtraLives();
                }

                if (GUI.Button(rRect(0.5f, 0.65f, 0.375f, 0.05f), "CANCEL", customHighlightStyle))
                {
                    CancelButtonPressed();
                }
            }
        }


        //GAME OVER
        if (displayGameOver)
        {
            gameOver = true;

            if (showAds && AdBinding.isInterstitalLoaded())
            {
                AdBinding.destroyAdBanner();
                AdBinding.showInterstitial();
            }

            GUI.DrawTextureWithTexCoords(rRect(0f, 0f, 1f, 1f), mainMenuBackground, new Rect(0f, 0f, 5f, 5f));
            GUI.DrawTexture(rRect(0.2f, 0.1f, 0.6f, 0.1f), gamelogo);

            GUI.Label(rRect(0.3f, 0.25f, 0.4f, 0.05f), "GAME OVER", customHighlightStyle);
            GUI.Label(rRect(0.3f, 0.3f, 0.4f, 0.05f), "SCORE", customButtonStyle);
            GUI.Label(rRect(0.3f, 0.35f, 0.4f, 0.05f), ((int)Camera.main.GetComponent <beeGUI>().score).ToString(), customButtonStyle);
            GUI.Label(rRect(0.3f, 0.4f, 0.4f, 0.05f), "HIGH", customButtonStyle);
            GUI.Label(rRect(0.3f, 0.45f, 0.4f, 0.05f), EncryptedPlayerPrefs.GetInt("highScoore").ToString(), customButtonStyle);

            if (GUI.Button(rRect(0.3f, 0.52f, 0.4f, 0.05f), "RATE", customHighlightStyle))
            {
                Application.OpenURL("itms-apps://itunes.apple.com/app/id875911453");
            }

            if (GUI.Button(rRect(0.3f, 0.59f, 0.4f, 0.05f), "LEADERBOARD", customHighlightStyle))
            {
                if (GameCenterBinding.isPlayerAuthenticated())
                {
                    if (_hasLeaderboardData)
                    {
                        GameCenterBinding.showGameCenterViewController(GameCenterViewControllerState.Leaderboards);
                    }
                }
                else
                {
                    GameCenterBinding.authenticateLocalPlayer();
                    GameCenterBinding.loadLeaderboardTitles();
                }
            }

            float yoffset = 0f;

            if (EncryptedPlayerPrefs.GetInt("10xtralives") != 1)
            {
                if (GUI.Button(rRect(0.3f, 0.66f, 0.4f, 0.05f), "EXTRA LIVES", customHighlightStyle))
                {
                    displayExtraLives = true;
                    displayGameOver   = false;
                }
            }
            else
            {
                yoffset -= 0.07f;
            }

            if (showAds == true)
            {
                if (GUI.Button(rRect(0.3f, 0.73f + yoffset, 0.4f, 0.05f), "REMOVE ADS", customHighlightStyle))
                {
                    displayRemoveAds = true;
                    displayGameOver  = false;
                }
            }
            else
            {
                yoffset -= 0.07f;
            }

            if (GUI.Button(rRect(0.3f, 0.80f + yoffset, 0.4f, 0.05f), "TRY AGAIN", customHighlightStyle))
            {
                displayMainMenu = false;
                displayGameOver = false;
                Camera.main.GetComponent <beeGUI>().dispMenu = true;
                Time.timeScale = 1;
                if (showAds)
                {
                    AdBinding.createAdBanner(true);
                    AdBinding.initializeInterstitial();
                }
                Application.LoadLevel("game");
            }
        }


        //REMOVE ADS PURCHASE
        if (displayRemoveAds)
        {
            GUI.DrawTextureWithTexCoords(new Rect(0f, 0f, sW, sH), mainMenuBackground, new Rect(0f, 0f, 5f, 5f));
            GUI.DrawTexture(new Rect(sW * 0.2f, sH * 0.1f, sW * 0.6f, sH * 0.1f), gamelogo);


            if (EncryptedPlayerPrefs.GetInt("removeadverts") != 1)
            {
                GUI.Label(rRect(0.25f, 0.3f, 0.5f, 0.05f), "REMOVE ADVERTS", customHighlightStyle);
                GUI.Label(rRect(0.125f, 0.35f, 0.75f, 0.25f), "Have and advert-free experience by purchasing the option below. Then experience uninterrupted gameplay!", customPaddedStyle);


                if (GUI.Button(rRect(0.125f, 0.6f, 0.25f, 0.05f), "NO ADS!", customHighlightStyle))
                {
                    BuyRemoveAds();
                }

                if (GUI.Button(rRect(0.375f, 0.6f, 0.25f, 0.05f), "RESTORE", customHighlightStyle))
                {
                    RestoreButtonPressed();
                }

                if (GUI.Button(rRect(0.625f, 0.6f, 0.25f, 0.05f), "CANCEL", customHighlightStyle))
                {
                    CancelButtonPressed();
                }
            }
        }


        //PROBLEM WITH IN-APP PURCHASE
        if (displayProblem)
        {
            GUI.DrawTextureWithTexCoords(new Rect(0f, 0f, sW, sH), mainMenuBackground, new Rect(0f, 0f, 5f, 5f));
            GUI.DrawTexture(new Rect(sW * 0.2f, sH * 0.1f, sW * 0.6f, sH * 0.1f), gamelogo);

            GUI.Label(rRect(0.25f, 0.3f, 0.5f, 0.05f), "PROBLEM", customHighlightStyle);
            GUI.Label(rRect(0.125f, 0.35f, 0.75f, 0.25f), "There appears to be a problem in doing that action. Please can you try again later?", customPaddedStyle);


            if (GUI.Button(rRect(0.375f, 0.6f, 0.25f, 0.05f), "HOME", customHighlightStyle))
            {
                if (gameOver)
                {
                    displayGameOver = true;
                }
                else
                {
                    displayMainMenu = true;
                }
                displayProblem = false;
            }
        }
    }
Esempio n. 18
0
    IEnumerator Loading()
    {
        FinanceManager _totalMoney = _managers.GetComponent <FinanceManager>();

        // Check if we have any data saved before
        if (EncryptedPlayerPrefs.GetFloat(_textSplit[0] + "TotalMoney", -1f) != -1f)
        {
            // Get the totalMoney stored value and assign it.
            double total = (double)EncryptedPlayerPrefs.GetFloat(_textSplit[0] + "TotalMoney", -1f);
            _totalMoney.totalMoney = total;
            moneyText.text         = "" + total.ToString("F2");

            // Get the Elevator Drop Off Amount stored value and assign it.
            Inventory _elevator_amount = _elevatorDropOff_Amount.GetComponent <Inventory>();
            _elevator_amount.money = EncryptedPlayerPrefs.GetFloat(_textSplit[0] + "ElevatorDropOff_Amount", -1f);
            _elevator_amount._floatingText.text = "" + Mathf.Round(_elevator_amount.money).ToString();

            // Get the Elevator Upgrade Amount stored value and assign it.
            UpgradeActorUI _elevatorUpgradeAmount = _elevatorUpgrade.GetComponent <UpgradeActorUI>();
            _elevatorUpgradeAmount._price = EncryptedPlayerPrefs.GetFloat(_textSplit[0] + "ElevatorUpgradeAmount", -1f);
            Actor _elevatorSkillMultiplier = _elevator.GetComponent <Actor>();

            // Get the Elevator Skill Multiplier stored value and assign it.
            _elevatorSkillMultiplier.SkillMultiplier = EncryptedPlayerPrefs.GetFloat(_textSplit[0] + "ElevatorSkillMultiplier", -1f);
            _elevatorUpgradeBtn_Text.text            = "" + Mathf.Round(_elevatorUpgradeAmount._price).ToString();
            _elevatorUpgradeAmount.LoadLastUpgrade();

            // Get the WareHouse Amount stored value and assign it.
            UpgradeActorUI _wareHouseAmount = _warehouseUpgrade.GetComponent <UpgradeActorUI>();
            _wareHouseAmount._price = EncryptedPlayerPrefs.GetFloat(_textSplit[0] + "WareHouseAmount", -1f);

            // Get the WareHouse Skill Multiplier stored value and assign it.
            Actor _wareHouseSkillMultiplier = _wareHouse.GetComponent <Actor>();
            _wareHouseSkillMultiplier.SkillMultiplier = EncryptedPlayerPrefs.GetFloat(_textSplit[0] + "WareHouseSkillMultiplier", -1f);
            _warehouseUpgradeBtn_Text.text            = "" + Mathf.Round(_wareHouseAmount._price).ToString();
            _wareHouseAmount.LoadLastUpgrade();

            // Get the total number of shafts saved value.
            int nb_shafts = EncryptedPlayerPrefs.GetInt(_textSplit[0] + "NumberOfShafts", -1);

            // Load all the saved shafts.
            for (int i = _managers.GetComponent <ShaftManager>().Shafts.Count; i < nb_shafts; i++)
            {
                _managers.GetComponent <ShaftManager>().LoadPreviousShafts();
            }

            yield return(1);

            // Get	the Upgrade Amout, Skill Multiplier & Drop Off Amount stored value
            // for every shaft and assign them.
            ShaftManager gett = _managers.GetComponent <ShaftManager>();
            for (int i = 0; i < nb_shafts; i++)
            {
                float UpgradeAmount   = +EncryptedPlayerPrefs.GetFloat(_textSplit[0] + "UpgradeAmount" + i, -1f);
                float SkillMultiplier = +EncryptedPlayerPrefs.GetFloat(_textSplit[0] + "SkillMultiplier" + i, -1f);
                float DropOff_Amount  = +EncryptedPlayerPrefs.GetFloat(_textSplit[0] + "DropOff_Amount" + i, -1f);

                gett.Shafts[i].transform.GetChild(1).GetComponent <Actor>().SkillMultiplier             = SkillMultiplier;
                gett.Shafts[i].transform.GetChild(3).GetChild(1).GetComponent <UpgradeActorUI>()._price = UpgradeAmount;
                gett.Shafts[i].transform.GetChild(3).GetChild(1).GetChild(1).GetChild(1).gameObject.GetComponent <TextMeshProUGUI>().text = "" + Mathf.Round(UpgradeAmount).ToString();
                gett.Shafts[i].transform.GetChild(3).GetChild(1).GetComponent <UpgradeActorUI>().LoadLastUpgrade();
                gett.Shafts[i].transform.GetChild(2).GetChild(1).GetComponent <Inventory>().money = DropOff_Amount;
                gett.Shafts[i].transform.GetChild(2).GetChild(1).GetComponent <Inventory>()._floatingText.text = "" + Mathf.Round(DropOff_Amount).ToString();
            }

            // The game is loaded so, hide the menu & return to game.
            _popUp.SetActive(false);
            _menuBackground.SetActive(false);
            _map.SetActive(false);
            _menuBtn.GetComponent <Button>().interactable = true;
            _moneyAmount.SetActive(true);
            Time.timeScale = 1.0f;
        }

        // If no data was saved we show an alert message: There is no saved data to load
        else
        {
            _popUp.SetActive(true);
            _menuBackground.SetActive(false);
            _map.SetActive(false);
        }
    }
Esempio n. 19
0
 public int LoadGame(string key)
 {
     return(EncryptedPlayerPrefs.GetInt(key, 0));
 }