예제 #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);
    }
예제 #2
0
    void SaveGameData()
    {
        if (isBGMplay)
        {
            EncryptedPlayerPrefs.SetInt("isBGMplay", 1);
        }
        else
        {
            EncryptedPlayerPrefs.SetInt("isBGMplay", 0);
        }

        if (isSFXplay)
        {
            EncryptedPlayerPrefs.SetInt("isSFXplay", 1);
        }
        else
        {
            EncryptedPlayerPrefs.SetInt("isSFXplay", 0);
        }

        EncryptedPlayerPrefs.SetInt("money", money);

        EncryptedPlayerPrefs.SetInt("level", level);

        EncryptedPlayerPrefs.SetInt("exp", exp);

        EncryptedPlayerPrefs.SetInt("hairColor", hairColor);

        PlayerPrefs.Save();
    }
예제 #3
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);
    }
    /// <summary>
    /// Almacena el numero de escudos que ha adquirido actualmente el usuario en las preferencias
    /// </summary>
    public void SaveEscudos()
    {
        Debug.Log(">>> GUARDAR ESCUDOS");

        // almacenar los escudos
        string strEscudos = "";

        for (int i = 0; i < EscudosManager.instance.GetNumEscudos(); ++i)
        {
            Escudo escudo = EscudosManager.instance.GetEscudo(i);
            if (escudo != null && escudo.numUnidades > 0)
            {
                // añadir el separador antes del id de la equipacion
                if (strEscudos != "")
                {
                    strEscudos += separadores[0];
                }

                strEscudos += escudo.id + separadoresIgual[0] + escudo.numUnidades;
            }
        }
        EncryptedPlayerPrefs.SetString("escudos", strEscudos);

        PlayerPrefs.Save();
    }
예제 #5
0
 // Use this for initialization
 void Start()
 {
     actionRate = ACTIONRATE_NOMAL;
     level      = Const.GAME_LEVEL_NOMAL;
     if (GameMaster.Instance.mode == GameMaster.GameMode.EndlessMode)
     {
         level = Const.GAME_LEVEL_NOMAL;
     }
     if (GameMaster.Instance.mode == GameMaster.GameMode.OnePlayerMode)
     {
         level = EncryptedPlayerPrefs.LoadInt(Const.KEY_LEVEL, Const.GAME_LEVEL_NOMAL);
     }
     prevAction = PlayerInfo.Action.None;
     if (level == Const.GAME_LEVEL_EASY)
     {
         actionRate = ACTIONRATE_EASY;
     }
     else if (level == Const.GAME_LEVEL_NOMAL)
     {
         actionRate = ACTIONRATE_NOMAL;
     }
     else if (level == Const.GAME_LEVEL_HEARD)
     {
         actionRate = ACTIONRATE_HEARD;
     }
 }
예제 #6
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 SaveTest()
    {
        EncryptedPlayerPrefs.SetInt("DataExist", 1);
        EncryptedPlayerPrefs.SetInt("Strength", userInfo.stat.strength);
        EncryptedPlayerPrefs.SetInt("Agility", userInfo.stat.agility);
        EncryptedPlayerPrefs.SetInt("Constitution", userInfo.stat.constitution);
        EncryptedPlayerPrefs.SetInt("Intelligence", userInfo.stat.intelligence);
        EncryptedPlayerPrefs.SetInt("RemainPoint", userInfo.stat.remainPoint);

        EncryptedPlayerPrefs.SetInt("CurrentADLevel", userInfo.castle.currentADLevel);
        EncryptedPlayerPrefs.SetInt("CurrentHealthLevel", userInfo.castle.currentHealthLevel);
        EncryptedPlayerPrefs.SetInt("CurrentDefenseLevel", userInfo.castle.currentDefenseLevel);
        EncryptedPlayerPrefs.SetInt("CurrentSlot", userInfo.castle.currentSlot);

        EncryptedPlayerPrefs.SetInt("Gold", userInfo.gold);
        EncryptedPlayerPrefs.SetInt("Silver", userInfo.silver);



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

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

        EncryptedPlayerPrefs.SetString("PicturePath", userInfo.picturePath);

        EncryptedPlayerPrefs.SetInt("killEnemyCount", userInfo.achieveInfo.killEnemyCount);
        EncryptedPlayerPrefs.SetInt("stageClearCount", userInfo.achieveInfo.stageClearCount);
    }
    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();
    }
예제 #10
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;
                        }
                    }
                }
            }
        }
예제 #11
0
    private void AddEnableCharas(int charaNo)
    {
        string enabeledCharas = EncryptedPlayerPrefs.LoadString(Const.KEY_ENABLE_CHARAS, Const.ENABLE_CHARAS_DEFAULT);

        enabeledCharas = enabeledCharas + "," + charaNo.ToString();
        EncryptedPlayerPrefs.SaveString(Const.KEY_ENABLE_CHARAS, enabeledCharas);
    }
예제 #12
0
        public void OnClickButton()
        {
            if (selectItem.canSelect)
            {
                SoundController.Instance.PlaySe(SoundController.Instance.buttonSe);
                EncryptedPlayerPrefs.SaveInt(Const.KEY_CHARA, int.Parse(selectItem.num));
                Retry();
                return;
            }

            if (selectItem.canBuy)
            {
                SoundController.Instance.PlaySe(SoundController.Instance.casher);

                int point = EncryptedPlayerPrefs.LoadInt(Const.KEY_POINT, 0);
                int diff  = point - selectItem.price;
                EncryptedPlayerPrefs.SaveInt(Const.KEY_POINT, diff);
                pointText.text = diff + "P";
                string enabledCharas = EncryptedPlayerPrefs.LoadString(Const.KEY_ENABLE_CHARAS, "0");
                enabledCharas = enabledCharas + "," + selectItem.num;
                EncryptedPlayerPrefs.SaveString(Const.KEY_ENABLE_CHARAS, enabledCharas);
                selectItem.canSelect = true;
                priceText.text       = ("PLAY");
            }
        }
예제 #13
0
    public void SetPlayerScores()
    {
        string value     = "{" + SystemInfo.deviceUniqueIdentifier + delimeter + levelMaximum + "}";
        string encrypted = EncryptedPlayerPrefs.SetString("USER", value);

        PlayerPrefs.Save();
        StartCoroutine(DBSetScores(encrypted));
    }
예제 #14
0
 void Awake()
 {
     isExtra = EncryptedPlayerPrefs.GetInt("extraLives");
     if (isExtra == 1)
     {
         numLifes = 4;
     }
 }
예제 #15
0
파일: Client.cs 프로젝트: Syjgin/zerotram
 private string GetToken()
 {
     if (_token == null)
     {
         _token = EncryptedPlayerPrefs.GetString(SavedTokenString, "");
     }
     return(_token);
 }
예제 #16
0
파일: Client.cs 프로젝트: Syjgin/zerotram
 private string GetUserid()
 {
     if (_userId == null)
     {
         _userId = EncryptedPlayerPrefs.GetString(SavedUseridString, "");
     }
     return(_userId);
 }
예제 #17
0
 private void Awake()
 {
     LoadEndingData();
     _stringBuilder     = new StringBuilder();
     _currentIndex      = MyStatus.instance.endingIndex;
     _questionText.text = _endingDatas[_currentIndex].endingQuestion;
     EncryptedPlayerPrefs.SetInt("Ending" + (_currentIndex + 1), 1);
 }
예제 #18
0
파일: Client.cs 프로젝트: Syjgin/zerotram
 public int GetRecord()
 {
     if (!_isRecordLoaded)
     {
         _isRecordLoaded = true;
         _currentRecord  = EncryptedPlayerPrefs.GetInt(TicketsRecordKey, 0);
     }
     return(_currentRecord);
 }
예제 #19
0
 private void OnCoinRewrd(bool isReward)
 {
     if (isReward)
     {
         Sound.Instans.PlaySe(Sound.Instans.fixSound);
         int currentCoin = EncryptedPlayerPrefs.LoadInt(Const.KEY_COIN, 0);
         RewardCountUpCoin(currentCoin, gotCoins);
     }
 }
예제 #20
0
    public void OnEnding()
    {
        int level = EncryptedPlayerPrefs.LoadInt(Const.KEY_LEVEL, 2);

        assigned.assignedDialogue = "Ending" + level;
        textArea.SetActive(true);
        DOVirtual.DelayedCall(1f, () => {
            diagUI.Begin(assigned, textArea, true);
        });
    }
예제 #21
0
    // Use this for initialization
    void Start()
    {
        // 設定を反映
        bool bgm = EncryptedPlayerPrefs.LoadBool(Const.KEY_BGM_ON, true);

        Sound.Instans.audioSource.mute = !bgm;
        bool se = EncryptedPlayerPrefs.LoadBool(Const.KEY_SE_ON, true);

        Sound.Instans.seAudioSource.mute = !se;
    }
예제 #22
0
    /*
     * /// <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();
        }
    }
예제 #23
0
    private bool IsEnable()
    {
        string        enabeledCharas = EncryptedPlayerPrefs.LoadString(Const.KEY_ENABLE_CHARAS, Const.ENABLE_CHARAS_DEFAULT);
        List <string> enableList     = new List <string> ();

        enableList.AddRange(enabeledCharas.Split(','));
        int  charaNo = charaType + charaSeq;
        bool enable  = enableList.Contains(charaNo.ToString());

        return(enable);
    }
예제 #24
0
 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];
         }
     }
 }
예제 #25
0
    public void save()
    {
        FinanceManager _totalMoney = _managers.GetComponent <FinanceManager>();

        ShaftManager gett = _managers.GetComponent <ShaftManager>();

        Inventory _elevator_amount = _elevatorDropOff_Amount.GetComponent <Inventory>();

        UpgradeActorUI _elevatorUpgradeAmount   = _elevatorUpgrade.GetComponent <UpgradeActorUI>();
        Actor          _elevatorSkillMultiplier = _elevator.GetComponent <Actor>();

        UpgradeActorUI _wareHouseAmount          = _warehouseUpgrade.GetComponent <UpgradeActorUI>();
        Actor          _wareHouseSkillMultiplier = _wareHouse.GetComponent <Actor>();

        // we add the _textSplit[0] to the name of the saved value to ensure
        // that the script can be used for saving a lot of mines.
        // Encrypt & Save the total number of current shafts.
        EncryptedPlayerPrefs.SetInt(_textSplit[0] + "NumberOfShafts", +gett.Shafts.Count);

        // Encrypt & Save the totalMoney value.
        EncryptedPlayerPrefs.SetFloat(_textSplit[0] + "TotalMoney", +(float)_totalMoney.totalMoney);

        // Encrypt & Save the Elevator Drop Off Amount.
        EncryptedPlayerPrefs.SetFloat(_textSplit[0] + "ElevatorDropOff_Amount", +_elevator_amount.money);

        // Encrypt & Save the Elevator Upgrade Amount.
        EncryptedPlayerPrefs.SetFloat(_textSplit[0] + "ElevatorUpgradeAmount", +_elevatorUpgradeAmount._price);

        // Encrypt & Save the Elevator Skill Multiplier value.
        EncryptedPlayerPrefs.SetFloat(_textSplit[0] + "ElevatorSkillMultiplier", +_elevatorSkillMultiplier.SkillMultiplier);

        // Encrypt & Save the WareHouse Amount.
        EncryptedPlayerPrefs.SetFloat(_textSplit[0] + "WareHouseAmount", +_wareHouseAmount._price);

        // Encrypt & Save the WareHouse Skill Multiplier value.
        EncryptedPlayerPrefs.SetFloat(_textSplit[0] + "WareHouseSkillMultiplier", +_wareHouseSkillMultiplier.SkillMultiplier);

        // Encrypt & Save the Upgrade Amout, Skill Multiplier & Drop Off Amount
        // for every shaft.
        for (int i = 0; i < gett.Shafts.Count; i++)
        {
            float UpgradeAmount   = gett.Shafts[i].transform.GetChild(3).GetChild(1).GetComponent <UpgradeActorUI>()._price;
            float SkillMultiplier = gett.Shafts[i].transform.GetChild(1).GetComponent <Actor>().SkillMultiplier;
            float DropOff_Amount  = gett.Shafts[i].transform.GetChild(2).GetChild(1).GetComponent <Inventory>().money;

            EncryptedPlayerPrefs.SetFloat(_textSplit[0] + "UpgradeAmount" + i, UpgradeAmount);
            EncryptedPlayerPrefs.SetFloat(_textSplit[0] + "SkillMultiplier" + i, SkillMultiplier);
            EncryptedPlayerPrefs.SetFloat(_textSplit[0] + "DropOff_Amount" + i, DropOff_Amount);
        }

        // When the game is saved, hide the menu & return to game.
        _menuBackground.SetActive(false);
        Time.timeScale = 1.0f;
    }
예제 #26
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);
    }
예제 #27
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);
            }
        }
    }
예제 #28
0
    public static void Save(string saveKey, object saveObject, bool encrypted = true)
    {
        var aString = JsonUtility.ToJson(saveObject);

        if (encrypted)
        {
            EncryptedPlayerPrefs.SetString(saveKey, aString);
        }
        else
        {
            PlayerPrefs.SetString(saveKey, aString);
        }
    }
예제 #29
0
        IEnumerator GetAccessToken(string oauth_verifier)
        {
            // header
            oauth_handler_.Clear();
            oauth_handler_.AddParameter("oauth_token", request_token_);
            oauth_handler_.AddParameter("oauth_verifier", oauth_verifier);

            var headers = new Dictionary <string, string>();

            headers["Authorization"] = oauth_handler_.GenerateHeader(kAccessUrl, "POST");

            WWW web = new WWW(kAccessUrl, null, headers);

            yield return(web);

            if (!string.IsNullOrEmpty(web.error))
            {
                Debug.Log(string.Format("GetAccessToken - failed. {0}, {1}", web.error, web.text));
                OnEventNotify(SNResultCode.kLoginFailed);
            }
            else
            {
                my_info_.id   = Regex.Match(web.text, @"user_id=([^&]+)").Groups[1].Value;
                my_info_.name = Regex.Match(web.text, @"screen_name=([^&]+)").Groups[1].Value;
                string token  = Regex.Match(web.text, @"oauth_token=([^&]+)").Groups[1].Value;
                string secret = Regex.Match(web.text, @"oauth_token_secret=([^&]+)").Groups[1].Value;

                if (!string.IsNullOrEmpty(token) && !string.IsNullOrEmpty(secret) &&
                    !string.IsNullOrEmpty(my_info_.id) && !string.IsNullOrEmpty(my_info_.name))
                {
                    Debug.Log("GetAccessToken - succeeded.");
                    Debug.Log(string.Format("id: {0}\nname: {1}\ntoken: {2}\ntoken_secret: {3}",
                                            my_info_.id, my_info_.name, token, secret));

                    oauth_handler_.AddParameter("oauth_token", token);
                    oauth_handler_.AddParameter("oauth_token_secret", secret);

                    EncryptedPlayerPrefs.SetString("user_id", my_info_.id);
                    EncryptedPlayerPrefs.SetString("screen_name", my_info_.name);
                    EncryptedPlayerPrefs.SetString("oauth_token", token);
                    EncryptedPlayerPrefs.SetString("oauth_token_secret", secret);

                    OnEventNotify(SNResultCode.kLoggedIn);
                }
                else
                {
                    Debug.Log("GetAccessToken - failed. " + web.text);
                    OnEventNotify(SNResultCode.kLoginFailed);
                }
            }
        }
예제 #30
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);
    }