Exemple #1
0
    public void SaveDecksIntoPlayerPrefs()
    {
        for (int i = 0; i < 9; i++)
        {
            string deckNameKey = "DeckName" + i.ToString();

            if (PlayerPrefs.HasKey(deckNameKey))
            {
                PlayerPrefs.DeleteKey(deckNameKey);
            }
        }

        for (int i = 0; i < AllDecks.Count; i++)
        {
            string deckListKey = "Deck" + i.ToString();
            string deckNameKey = "DeckName" + i.ToString();

            List <string> cardNamesList = new List <string> ();
            foreach (CardAsset a in AllDecks[i].Cards)
            {
                cardNamesList.Add(a.name);
            }

            string[] cardNamesArray = cardNamesList.ToArray();

            PlayerPrefsX.SetStringArray(deckListKey, cardNamesArray);
            PlayerPrefs.SetString(deckNameKey, AllDecks[i].DeckName);
        }
    }
Exemple #2
0
 public void End(string name)
 {
     if (testNetwork.isConnect)
     {
         myParse.InsertScore(combo, name);
         GameObject.Find("Preload").GetComponent <Preload>().FirstInStartScene();
         Application.LoadLevel("Start");
     }
     int[]    scores = PlayerPrefsX.GetIntArray("scores");
     string[] names  = PlayerPrefsX.GetStringArray("names");
     scores[10] = combo;
     names[10]  = name;
     for (int i = 0; i < scores.Length; i++)
     {
         for (int j = i; j < scores.Length; j++)
         {
             if (scores[j] > scores[i])
             {
                 int temp = scores[j];
                 scores[j] = scores[i];
                 scores[i] = temp;
                 string temp1 = names[j];
                 names[j] = names[i];
                 names[i] = temp1;
             }
         }
     }
     PlayerPrefsX.SetIntArray("scores", scores);
     PlayerPrefsX.SetStringArray("names", names);
 }
    void Start()
    {
        if (PlayerPrefsX.GetIntArray("TablicaWynikow", 0, 10)[0] == 0)
        {
            int[] TablicaWynikow = new int[10] {
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            };

            PlayerPrefsX.SetIntArray("TablicaWynikow", TablicaWynikow);
        }

        if (PlayerPrefsX.GetStringArray("TablicaWynikowNick", "", 10)[0] == "")
        {
            string[] TablicaWynikowNick = new string[10] {
                "", "", "", "", "", "", "", "", "", ""
            };

            PlayerPrefsX.SetStringArray("TablicaWynikowNick", TablicaWynikowNick);
        }

        scena = SceneManager.GetActiveScene();
        if (scena.name != naz)
        {
            menuInGame.SetActive(false);
        }
    }
Exemple #4
0
    private void SaveCoinFromArr(List <GameObject> coin_lst, string prefix)
    {
        List <Quaternion> coin_rotation = new List <Quaternion>();
        List <Vector3>    coin_position = new List <Vector3>();
        List <string>     coin_names    = new List <string>();

        for (int i = 0; i < coin_lst.Count; i++)
        {
            if (coin_lst[i] != null)
            {
                if (coin_lst[i].activeInHierarchy == true)
                {/////////////////////////// change from != false
                    if (coin_lst[i].activeInHierarchy)
                    {
                        coin_rotation.Add(coin_lst[i].transform.rotation);
                        coin_position.Add(coin_lst[i].transform.position);
                        coin_names.Add(coin_lst[i].name);
                    }
                }
            }
        }
        PlayerPrefsX.SetQuaternionArray(prefix + "Quaternion", coin_rotation.ToArray());
        PlayerPrefsX.SetVector3Array(prefix + "Position", coin_position.ToArray());
        PlayerPrefsX.SetStringArray(prefix + "Name", coin_names.ToArray());

        if (coin_names.Count > 0)
        {
            PlayerPrefs.SetInt(prefix + "Count", coin_names.Count);
        }
        else
        {
            PlayerPrefs.SetInt(prefix + "Count", 0);
        }
    }
    public void Save()
    {
        //Make sure savefile has name
        string saveName = GameObject.Find("SaveAsText").GetComponent <Text>().text;

        if (!string.Equals(saveName, ""))
        {
            //Set save number
            int n;
            if (PlayerPrefs.HasKey("saveNumber"))
            {
                n = PlayerPrefs.GetInt("saveNumber");
            }
            else
            {
                n = 0;
            }
            PlayerPrefs.SetInt("saveNumber", ++n);

            //Save arrays into PlayerPrefsX
            string[] words        = new string[CustomTiles.wordNumber - 1];
            string[] translations = new string[CustomTiles.wordNumber - 1];
            for (int i = 0; i < CustomTiles.wordNumber - 1; i++)
            {
                words[i]        = CustomTiles.words[i];
                translations[i] = CustomTiles.translations[i];
            }
            PlayerPrefsX.SetStringArray("WordsSave" + n, words);
            PlayerPrefsX.SetStringArray("TranslationsSave" + n, translations);
            PlayerPrefs.SetString("SaveName" + n, saveName);
            CustomTiles.savePanel.SetActive(false);
            SceneManager.LoadScene(3, LoadSceneMode.Single);
        }
    }
    public Text listeScores;                            //Text pour la liste des scores
    //variable à transformer en % NiveauOxygene



    void Start()
    {
        //ChangementScenePortail.leNomDuJoueur = "Kim";
        //ControlerPersonnage.NiveauOxygene=10;

        PlayerPrefs.DeleteKey("FichierScores");                  //Effacer les données précédemment enregistrées
        PlayerPrefs.DeleteKey("FichierNoms");                    //Effacer les données précédemment enregistrées

        bool infoExisteDeja = PlayerPrefs.HasKey("FichierNoms"); //Regarde si valeurs présentes

        //si valeurs trouvées on affiche
        if (infoExisteDeja == true)
        {
            //lecture des données
            tableauValeursScore = PlayerPrefsX.GetFloatArray("FichierScores");
            tableauNoms         = PlayerPrefsX.GetStringArray("FichierNoms");
        }

        tableauNoms[3] = ChangementScenePortail.leNomDuJoueur;

        tableauValeursScore[3] = ControlerPersonnage.NiveauOxygene;
        //listeScores.text = tableauValeursScore[0].ToString();

        //Trier le tableau selon le score
        System.Array.Sort(tableauValeursScore, tableauNoms);
        System.Array.Reverse(tableauValeursScore); //
        System.Array.Reverse(tableauNoms);         //

        AfficherElements();
        //Écriture des données
        PlayerPrefsX.SetFloatArray("FichierScores", tableauValeursScore);
        PlayerPrefsX.SetStringArray("FichierNoms", tableauNoms);
    }
Exemple #7
0
 void SaveTime(string time)
 {
     string[] times = PlayerPrefsX.GetStringArray(TimeKEY); //[0,0,0]// 取得
     times = Add(times, time);                              // 新しい得点を追加
     Debug.Log(string.Join(",", times));                    // 配列の要素を,区切りのstring型で表示する
     PlayerPrefsX.SetStringArray(TimeKEY, times);           // 保存
 }
Exemple #8
0
    public void SaveGiftsRev2(List <GameObject> objects, string prefix)
    {
        List <Vector3>    positions = new List <Vector3>();
        List <Quaternion> rotations = new List <Quaternion>();
        List <string>     names     = new List <string>();

        for (int i = 0; i < objects.Count; i++)
        {
            if (objects[i].activeInHierarchy)
            {
                positions.Add(objects[i].transform.position);
                rotations.Add(objects[i].transform.rotation);
                names.Add(objects[i].name);
            }
        }
        if (names.Count > 0)
        {
            PlayerPrefsX.SetQuaternionArray(prefix + "Quaternion", rotations.ToArray());
            PlayerPrefsX.SetVector3Array(prefix + "Position", positions.ToArray());
            PlayerPrefsX.SetStringArray(prefix + "Name", names.ToArray());
            PlayerPrefs.SetInt(prefix + "Count", names.Count);
        }
        else
        {
            PlayerPrefs.SetInt(prefix + "Count", 0);
        }
    }
Exemple #9
0
 void SaveUserName(string name)
 {
     string[] names = PlayerPrefsX.GetStringArray(UserNameKEY); //[0,0,0]// 取得
     names = Add(names, name);                                  // 新しい得点を追加
     Debug.Log(string.Join(",", names));                        // 配列の要素を,区切りのstring型で表示する
     PlayerPrefsX.SetStringArray(UserNameKEY, names);           // 保存
 }
 //These are save and load functions for the items class.
 //This is not currently in use but will be use in the future.
 public void SaveValues()
 {
     foreach (var item in m_items)
     {
         PlayerPrefs.SetInt("NumberOfItems", item.m_amountOfItemsForPlayer);
         PlayerPrefs.SetFloat("Durability", (float)item.durability);
         PlayerPrefs.SetFloat("ValueofItem", (float)item.valueOfItem);
         PlayerPrefs.SetString("ItemName " + item.name, item.name);
         PlayerPrefs.SetString("ItemDescription", item.description);
         PlayerPrefsX.SetBool("IsDurability", item.isDurability);
         PlayerPrefsX.SetBool("IsItemStatic", item.staticItem);
         PlayerPrefsX.SetBool("ValueIsPercentage", item.isAPercentage);
         PlayerPrefsX.SetBool("IsStackable", item.isStackable);
         //Saving only one of the arrays as they are all the same but
         //will be converted to the same number after it is loaded
         PlayerPrefsX.SetStringArray("StatusNames", item.statusNames[0].ToArray());
         PlayerPrefsX.SetStringArray("TypesNames", item.typesNames[0].ToArray());
         PlayerPrefsX.SetStringArray("StatsNames", item.allStatsEffected[0].ToArray());
         //_______________________________________________________________________________
         PlayerPrefsX.SetIntArray("StatsIndex", item.m_statIndex.ToArray());
         PlayerPrefsX.SetIntArray("TypeIndex", item.typesindex.ToArray());
         PlayerPrefsX.SetIntArray("StatusIndex", item.statusIndex.ToArray());
         PlayerPrefs.Save();
     }
 }
Exemple #11
0
    void UnlockStages(GameObject stage, float soul)
    {
        if (allSoul < soul)
        {
            Debug.Log("Soul not enough");
        }
        else
        {
            string[] rs = PlayerPrefsX.GetStringArray("StageListUnlockx");
            for (int i = 0; i < rs.Length; i++)
            {
                unlockStage.Add(rs [i]);
            }
            unlockStage.Add(stage.transform.name);

            if (!PlayerPrefsX.SetStringArray("StageListUnlockx", unlockStage.ToArray()))
            {
                Debug.Log("Can't save names");
            }

            stage.transform.FindChild("Unlock").gameObject.SetActive(false);
            stage.transform.FindChild("Stage_Info").gameObject.SetActive(false);
            stage.transform.FindChild("Play").gameObject.SetActive(true);
            allSoul          = allSoul - needSoul;
            allSoulText.text = "" + allSoul;
            PlayerPrefs.SetFloat("allSoul", allSoul);
        }
    }
    public void UnlockCar(string id)
    {
        var listCar = PlayerPrefsX.GetStringArray("lockCar").ToList();

        listCar.Remove(id);
        PlayerPrefsX.SetStringArray("lockCar", listCar.ToArray());
    }
    private void addSort()
    {
        int    index  = 0;
        int    temp   = 0;
        int    temp2  = currentScore;
        string tempS1 = "";
        string tempS2 = nameInput.text;

        for (int i = userArray.Length - 1; i >= 0; i--)
        {
            if (temp2 < scoreArray [i])
            {
                break;
            }
            index = i;
        }
        for (int i = index; i < userArray.Length; i++)
        {
            temp           = scoreArray [i];
            tempS1         = userArray [i];
            scoreArray [i] = temp2;
            userArray [i]  = tempS2;
            temp2          = temp;
            tempS2         = tempS1;
        }
        PlayerPrefsX.SetStringArray("userArray", userArray);
        PlayerPrefsX.SetIntArray("scoreArray", scoreArray);
    }
    /// <summary>
    ///
    /// </summary>
    /// <returns></returns>
    public SaveEventMessages SetSaveData()
    {
        if (m_ActiveSave == null)
        {
            return(SaveEventMessages.SaveSlotEmpty);
        }

        if (OverrideSaveData() != SaveEventMessages.SaveOverrideSuccess)
        {
            return(SaveEventMessages.SaveOverrideSuccess);
        }

        string[] temp;

        if (m_Save1.GetSaveID() == m_ActiveSave.GetSaveID())
        {
            temp = SaveData.SaveDataToStringArray(m_Save1);

            ExtendedFunctions.PrintArray(temp);

            PlayerPrefsX.SetStringArray(K_SAVE1, temp);
        }
        else if (m_Save2.GetSaveID() == m_ActiveSave.GetSaveID())
        {
            temp = SaveData.SaveDataToStringArray(m_Save2);
            PlayerPrefsX.SetStringArray(K_SAVE2, temp);
        }

        PlayerPrefs.SetInt(K_HIGHSCORE, m_HighScore);

        return(SaveEventMessages.SaveSuccess);
    }
Exemple #15
0
    public void SaveGifts()
    {
        GameObject[] gifts_array = GameObject.FindGameObjectsWithTag("Gift");
        if (gifts_array.Length > 0)
        {
            Quaternion[] gift_rotation = new Quaternion[gifts_array.Length];
            Vector3[]    gift_position = new Vector3[gifts_array.Length];
            string[]     gift_names    = new string[gifts_array.Length];

            for (int i = 0; i < gifts_array.Length; i++)
            {
                gift_rotation[i] = gifts_array[i].transform.rotation;
                gift_position[i] = gifts_array[i].transform.position;
                gift_names[i]    = gifts_array[i].name;
            }

            PlayerPrefsX.SetQuaternionArray("GiftQuaternion", gift_rotation);
            PlayerPrefsX.SetVector3Array("GiftPosition", gift_position);
            PlayerPrefsX.SetStringArray("GiftName", gift_names);
            PlayerPrefs.SetInt("GiftCount", gifts_array.Length);
        }
        else
        {
            PlayerPrefs.SetInt("GiftCount", 0);
        }
    }
Exemple #16
0
    private void SavePlayerPrefsData()
    {
        for (int i = 0; i < playerPrefsMaxArraySize; i++)
        {
            nameList[i] = "null";
            //coordinateList[i] = Vector2d.zero;
            XList[i] = "null";
            YList[i] = "null";
        }
        int j = 0;

        foreach (KeyValuePair <string, Vector2d> entry in savedMarkers)
        {
            // do something with entry.Value or entry.Key
            nameList[j] = entry.Key;
            //coordinateList[j] = entry.Value;
            XList[j] = entry.Value.x.ToString();
            YList[j] = entry.Value.y.ToString();
            j++;
        }
        PlayerPrefsX.SetStringArray("nameList", nameList);
        //PlayerPrefsX.SetVector2Array("coordinateList", coordinateList);
        PlayerPrefsX.SetStringArray("XList", XList);
        PlayerPrefsX.SetStringArray("YList", YList);
        PlayerPrefs.SetInt("listLength", playerPrefsCurrentArraySize);
    }
Exemple #17
0
    public void UnlockWorld(string nameWorld)
    {
        var listWorld = PlayerPrefsX.GetStringArray("lockWorld").ToList();

        listWorld.Remove(nameWorld);
        PlayerPrefsX.SetStringArray("lockWorld", listWorld.ToArray());
    }
Exemple #18
0
    // Specific paramerters for loading experiments

    void ReadyExp()
    {
        // ---------------------------------------------------------------------
        // Experiment: ESC return name of city to load based on id number
        // ---------------------------------------------------------------------
        if (expID.options[expID.value].text == "esc")
        {
            int id = int.Parse(subID.text); // parse the id input string to int

            if (practice.isOn)
            {
                config.level = "esc_practice";
            }
            else
            {
                // if it's in the 100 range, load city 01
                if (id > 100 && id < 200)
                {
                    config.level = "esc_city01";
                    PlayerPrefsX.SetStringArray("NextLevels", new string[1] {
                        "esc_city02"
                    });                                                                        // using arrayprefs2 allows for multiple 'next' levels
                }
                else if (id > 200 && id < 300)
                {
                    config.level = "esc_city02";
                    PlayerPrefsX.SetStringArray("NextLevels", new string[1] {
                        "esc_city01"
                    });                                                                        // using arrayprefs2 allows for multiple 'next' levels
                }
            }

            // if it's odd, start with standard navigation
            if (id % 2 != 0)
            {
                config.condition = "Standard";
                PlayerPrefsX.SetStringArray("NextConditions", new string[1] {
                    "Scaled"
                });
            }
            else
            {
                config.condition = "Scaled";
                PlayerPrefsX.SetStringArray("NextConditions", new string[1] {
                    "Standard"
                });
            }

            PlayerPrefs.SetInt("NextIndex", 0);
        }
        // ---------------------------------------------------------------------



        else
        {
            config.level = "simpleSample_gettingStarted";
        }
    }
 public static void saveProtectedCardsID(string[] cardIDs)
 {
     for (int i = 0; i < cardIDs.Length; i++)
     {
         Debug.Log("KEY_CARD_PROTECT:" + cardIDs[i]);
     }
     PlayerPrefsX.SetStringArray(KEY_CARD_PROTECT + Obj_MyselfPlayer.GetMe().accountID, cardIDs);
 }
Exemple #20
0
 public void SaveConq()
 {
     PlayerPrefs.SetInt("ConqHealth", conq_health);
     PlayerPrefs.SetInt("ConqEquip", conq_equip);
     PlayerPrefs.SetInt("ConqSkill", conq_skill);
     PlayerPrefs.SetFloat("ConqDamage", (float)conq_damage);
     PlayerPrefsX.SetStringArray("ConqInven", conq_inven);
 }
    // Save Player's Inventory
    public static void SaveInventory()
    {
        Inventory tempInventory = GameObject.FindGameObjectWithTag("Player").GetComponent <Player> ().getInventory();

        string[] itemList = tempInventory.GetInventoryList();

        PlayerPrefsX.SetStringArray("Inventory", itemList);
        PlayerPrefsX.SetIntArray("Quantity", tempInventory.GetQuantityList());
    }
    /// <summary>
    /// Remove username data index in ArrayPrefs.
    /// </summary>
    /// <param name="playerPrefsKey"></param>
    /// <param name="s"></param>
    /// <param name="index"></param>
    private void Del(string playerPrefsKey, string[] s, int index)
    {
        List <string> list = new List <string> ( );

        list.AddRange(s);
        list.RemoveAt(index);

        PlayerPrefsX.SetStringArray(playerPrefsKey, list.ToArray( ));
    }
Exemple #23
0
        public static void AddSaveName(string folder, string name)
        {
#if UNITY_WEBGL
            SaveFolders[folder].Add(name);
            var saves = SaveFolders[folder].ToArray();
            Array.Sort(saves);
            PlayerPrefsX.SetStringArray(folder, saves);
#endif
        }
Exemple #24
0
        public override void saveGame()
        {
            Debug.Log("saveGame");
            PlayerPrefsX.SetBool("_isMusicOff", isMusicOff);
            PlayerPrefsX.SetStringArray("_highScoreName", highScoreName);
            PlayerPrefsX.SetFloatArray("_highScore", highScore);

            PreviewLabs.PlayerPrefs.Flush();
        }
Exemple #25
0
    public void SendMessageToPlayer(string character, string _passage, bool archive)
    {
        FindTracker();
        message         = new Message();
        message.sender  = character;
        message.passage = _passage;
        message.belief  = json[message.sender][message.passage]["belief_id"];
        if (tracker)
        {
            tracker.belief_id = message.belief;
            tracker.path      = _passage;
            tracker.character = character;
        }
        message.body = json[message.sender][message.passage]["message"];

        //TODO: save belief

        chatLog.addMessage(message, avatar);
        sender  = character;
        passage = _passage;

        if (archive)
        {
            List <string> chat_path_history = PlayerPrefsX.GetStringArray(character).ToList();
            chat_path_history.Add(passage);
            Debug.Log("character: " + character + " passage:" + _passage);
            PlayerPrefsX.SetStringArray(character, chat_path_history.ToArray());
            ToggleResponseOptions();
            if (passage.Contains("finished"))
            {
                PlayerPrefs.SetInt("intervention index", 1);
                //show notification
                Invoke("SendNotification", 3.0f);
            }
        }
        else
        {
            Debug.Log("not archiving...");
            Debug.Log("passage: " + passage);
            if (passage.Contains("finished"))
            {
                Debug.Log("Deactivating Responses");
                chatLog.respondButton.SetActive(false);
                chatLog.responseContainer.SetActive(false);
                chatLog.waitingForResponse = false;
            }
            else
            {
                ToggleResponseOptions();
            }
        }

        if (tracker)
        {
            tracker.Track();
        }
    }
Exemple #26
0
    public void setHighScoreList(List <HighscoreClass> highscoreList)
    {
        List <string> outputArray = new List <string>();

        foreach (HighscoreClass h in highscoreList)
        {
            outputArray.Add(h.name + '`' + h.score);
        }
        PlayerPrefsX.SetStringArray("Highscore", outputArray.ToArray());
    }
Exemple #27
0
        public static void RemoveSaveName(string folder, string name)
        {
            name += ".ccs";
#if UNITY_WEBGL
            SaveFolders[folder].Remove(name);
            var saves = SaveFolders[folder].ToArray();
            Array.Sort(saves);
            PlayerPrefsX.SetStringArray(folder, saves);
#endif
        }
    public static void Save_Item_Info()      //아이템을 먹거나 사용할 때 호출
    {
        _ic_for_Save = GameObject.FindWithTag("Item_Canvas").GetComponent <Item_Controller> ();

        PlayerPrefsX.SetStringArray("IC_nameList", _ic_for_Save._item_name_list);
        PlayerPrefsX.SetBoolArray("Usable_item", _ic_for_Save._usable_item);
        PlayerPrefsX.SetIntArray("NumOfItem", _ic_for_Save._the_number_of_items);
        PlayerPrefsX.SetStringArray("Interaction", _ic_for_Save._interaction_object);
        PlayerPrefsX.SetBoolArray("Consumable", _ic_for_Save._consumable);
    }
    public void AddGameStage(string stageName)
    {
        if (gameStages.Contains(stageName))
        {
            return;
        }

        gameStages.Add(stageName);
        PlayerPrefsX.SetStringArray("Stages", gameStages.ToArray());
    }
 public void purchase()
 {
     if (isSkin)
     {
         //get the object's name
         currentskins = ShopScript.currentskins;
         contains     = false;
         //checks if already purchased
         for (int i = 0; i < currentskins.Length; i++)
         {
             if (currentskins [i] == button.name)
             {
                 contains = true;
             }
         }
         if (contains == false)
         {
             //if does not exist, then add to existing.
             //purchase.
             int newcoins = PlayerPrefs.GetInt("coins") - cost;
             if (newcoins >= 0)
             {
                 PlayerPrefs.SetInt("coins", newcoins);
                 List <string> currentskinsList = new List <string> ();
                 currentskinsList.AddRange(currentskins);
                 currentskinsList.Add(this.gameObject.name);
                 currentskins            = currentskinsList.ToArray();
                 ShopScript.currentskins = currentskinsList.ToArray();
                 PlayerPrefsX.SetStringArray("purchased", ShopScript.currentskins);
                 ShopScript.loadcoinvalue(newcoins);
                 button.image.overrideSprite = button.image.sprite;
                 PlayerPrefs.Save();
             }
         }
         else if (contains == true)
         {
             //if already contains, select skin and use it.
             PlayerPrefs.SetString("currentskin", this.gameObject.name);
             PlayerPrefs.Save();
             canvas.GetComponent <ShopScript> ().resetSkinsButtons();
         }
     }
     else
     {
         string buttonname = button.name;
         int    newcoins   = PlayerPrefs.GetInt("coins") - cost;
         if (newcoins >= 0)
         {
             PlayerPrefs.SetInt(buttonname, (PlayerPrefs.GetInt(buttonname) + 1));
             PlayerPrefs.SetInt("coins", newcoins);
             ShopScript.loadcoinvalue(newcoins);
             text.GetComponent <Text>().text = cost + " (" + PlayerPrefs.GetInt(button.name) + ")";
         }
     }
 }