public void QuickSaveWriterExample()
    {
        // Use a QuickSaveWriter to save content to a file, multiple items can be saved to the save file by specifying different keys

        string  one   = "Hello World!";
        double  two   = 45.6789;
        Vector2 three = new Vector2(34.0f, 78.92f);
        Color   four  = new Color(0.1f, 0.5f, 0.8f, 1.0f);

        QuickSaveWriter.Create("RootName")
        .Write("Key1", one)
        .Write("Key2", two)
        .Write("Key3", three)
        .Write("Key4", four)
        .Commit();

        // OR

        QuickSaveWriter writer = QuickSaveWriter.Create("RootName");

        writer.Write("Key1", one);
        writer.Write("Key2", two);
        writer.Write("Key3", three);
        writer.Write("Key4", four);
        writer.Commit();
    }
    public void Save()
    {
        var writer = QuickSaveWriter.Create("Shop");

        writer.Write("UnlockedSeeds", unlockedSeeds);
        writer.Commit();
    }
Beispiel #3
0
    public void OnMouseClick()
    {
        if (Points == 0)
        {
            Player_Data Data = Player.GetComponent <Player_Data>();

            Data.strength(Convert.ToDouble(strength));
            Data.endurance(Convert.ToDouble(endurance));
            Data.dexternity(Convert.ToDouble(dexternity));
            Data.constitution(Convert.ToDouble(constitution));
            Data.vitality(Convert.ToDouble(vitality));
            Data.intelligence(Convert.ToDouble(intelligence));


            string encrypted1 = cryptography.Encrypt(strength);
            string encrypted2 = cryptography.Encrypt(endurance);
            string encrypted3 = cryptography.Encrypt(dexternity);
            string encrypted4 = cryptography.Encrypt(constitution);
            string encrypted5 = cryptography.Encrypt(vitality);
            string encrypted6 = cryptography.Encrypt(intelligence);

            QuickSaveWriter.Create("Temp")
            .Write(cryptography.Encrypt("Strength"), encrypted1)
            .Write(cryptography.Encrypt("Endurance"), encrypted2)
            .Write(cryptography.Encrypt("Dexternity"), encrypted3)
            .Write(cryptography.Encrypt("Constitution"), encrypted4)
            .Write(cryptography.Encrypt("Vitality"), encrypted5)
            .Write(cryptography.Encrypt("Intelligence"), encrypted6)
            .Commit();

            Enable.SetActive(true);
            Disable.SetActive(false);
        }
    }
    public static void ResetSaves()
    {
        var quickSaveWriter = QuickSaveWriter.Create("MainSave");

        quickSaveWriter.Delete("SaveData");
        quickSaveWriter.Commit();
    }
Beispiel #5
0
    public void Save()
    {
        QuickSaveWriter writer = QuickSaveWriter.Create("GuardianIdleSave");
        Equipment       item;
        string          key;

        for (int i = 0; i < slots.Count; i++)
        {
            key = "equipSlot" + i;

            if (!(slots[i].IsEmpty()))
            {
                item = (Equipment)slots[i].GetItem();
                string data = JsonUtility.ToJson(item, false);

                writer.Write(key, data);
                writer.Write(key + "_icon", item.imagePath);
            }
            else
            {
                writer.Delete(key);
            }
        }

        writer.Commit();
    }
Beispiel #6
0
    public void SaveGameData()
    {
        //Since I can't save ScriptableObjects using this, I make fake data with strings instead of Cards
        Dictionary <string, int> playerCardInventoryFake = new Dictionary <string, int>();
        List <string>            deckFakeList            = new List <string>();

        //Then I fill the fake data
        foreach (KeyValuePair <Card, int> card in playerCardInventory)
        {
            playerCardInventoryFake.Add(card.Key.name, card.Value);
        }

        foreach (KeyValuePair <int, Card> card in Deck.deck)
        {
            deckFakeList.Add(card.Value.name);
        }

        //Save Everything
        QuickSaveWriter.Create("SaveEverything")
        .Write("PlayerName", playerName)
        .Write("PlayerIcon", playerIcon)
        .Write("PlayerLevel", playerLevel)
        .Write("PlayerXP", playerXP)
        .Write("PlayerCardInventory", playerCardInventoryFake)
        .Write("PlayerDeck", deckFakeList)
        .Commit();
    }
    /// <summary>
    /// Сохраняет данные о том, что определённая часть туториала уже проигрывалась
    /// </summary>
    private static void SaveTutorialData(string key)
    {
        var writer = QuickSaveWriter.Create("TutorialState");

        writer.Write(key, true);
        writer.Commit();
    }
Beispiel #8
0
    public void Save()
    {
        QuickSaveWriter writer = QuickSaveWriter.Create("GuardianIdleSave");

        writer.Write("itemIdCounter", idCounter);
        writer.Commit();
    }
    private void Save()
    {
        var writer = QuickSaveWriter.Create("Quantum");

        writer.Write("CooldownEnd", cooldownEnd);
        writer.Commit();
    }
Beispiel #10
0
    /// <summary>
    /// Сохраняет задание
    /// </summary>
    public void Save()
    {
        var writer = QuickSaveWriter.Create("Tasks");

        writer.Write(Details.ID.ToString(), Details);
        writer.Commit();
    }
Beispiel #11
0
 public void SavePlayerSaveData(PlayerSaveData playerData)
 {
     this.player = playerData;
     QuickSaveWriter.Create(fileName)
     .Write("Player", JsonUtility.ToJson(playerData))
     .Commit();
 }
Beispiel #12
0
 public void SaveFileSaveData(FileSaveData fileData)
 {
     this.file = fileData;
     QuickSaveWriter.Create(fileName)
     .Write("File", JsonUtility.ToJson(fileData))
     .Commit();
 }
    /// <summary>
    /// Сохраняет время окончания кулдауна
    /// </summary>
    private void SaveCooldownTime()
    {
        var writer = QuickSaveWriter.Create("Tasks");

        writer.Write("CooldownEnd", cooldownEnd);
        writer.Commit();
    }
    public void Save()
    {
        QuickSaveWriter.Create(fileName)
        .Write("ClickCount", clickCount)
        .Commit();

        //Content.text = QuickSaveRaw.LoadString("Inputs.json");
    }
    /// <summary>
    /// Очищает данные выставки
    /// </summary>
    private static void ClearExhibition()
    {
        GameObject.Find("Exhibition")?.SetActive(false);
        var writer = QuickSaveWriter.Create("ExhibitionData");

        writer.Write("ExhSeed", "no");
        writer.Commit();
    }
Beispiel #16
0
    public void Save()
    {
        var writer = QuickSaveWriter.Create("Market");

        writer.Write("Multipliers", PriceMultipliers)
        .Write("LastDate", _lastRefreshDate);
        writer.Commit();
    }
Beispiel #17
0
        public static string SaveGame()
        {
            CameraController cameraController = Camera.main.GetComponent <CameraController>();

            string saveName = DateTime.Now.ToString("MM_dd_yyyy_HH_mm_ss");

            QuickSaveWriter quickSaveWriter = QuickSaveWriter.Create(saveName);

            quickSaveWriter.Write(GameInfo.MAP_SEED, GameInfo.mapSeed);
            quickSaveWriter.Write(GameInfo.MAP_SIZE, GameInfo.mapSize);
            quickSaveWriter.Write("playerTeam", GameInfo.playerTeam);
            quickSaveWriter.Write("cameraPosition", Camera.main.transform.position);
            quickSaveWriter.Write("cameraRotation", Camera.main.transform.rotation);

            quickSaveWriter.Write("gold", cameraController.resources[BaseBehavior.ResourceType.Gold]);
            quickSaveWriter.Write("wood", cameraController.resources[BaseBehavior.ResourceType.Wood]);
            quickSaveWriter.Write("food", cameraController.resources[BaseBehavior.ResourceType.Food]);
            quickSaveWriter.Write("favor", cameraController.resources[BaseBehavior.ResourceType.Favor]);

            int index = 0;

            foreach (GameObject unitObject in GameObject.FindGameObjectsWithTag("Building").Concat(GameObject.FindGameObjectsWithTag("Unit")))
            {
                BaseBehavior unitBaseBehavior = unitObject.GetComponent <BaseBehavior>();
                unitBaseBehavior.Save(ref quickSaveWriter, index);
                index++;
            }
            quickSaveWriter.Write("indexCount", index);

            TerrainGenerator terrainGenerator = Terrain.activeTerrain.GetComponent <TerrainGenerator>();

            // Blind texture
            Color[] colors    = terrainGenerator.blindTexture2D.GetPixels();
            int[]   blindInfo = new int[colors.Length];
            for (int i = 0; i < colors.Length; i++)
            {
                blindInfo[i] = colors[i] == Color.black ? 1 : 0;
            }
            quickSaveWriter.Write("blindTextureData", blindInfo);

            // Binds
            for (int number = 1; number <= 9; number++)
            {
                int[] binds = new int[cameraController.unitsBinds[KeyCode.Alpha0 + number].Count];
                int   i     = 0;
                foreach (GameObject bindObject in cameraController.unitsBinds[KeyCode.Alpha0 + number])
                {
                    BaseBehavior bindObjectBaseBehavior = bindObject.GetComponent <BaseBehavior>();
                    binds[i] = bindObjectBaseBehavior.uniqueId;
                    i++;
                }
                quickSaveWriter.Write(new StringBuilder(15).AppendFormat("{0}_{1}", number, "bind").ToString(), binds);
            }

            quickSaveWriter.Commit();

            return(saveName);
        }
    public void Init()
    {
        _quickSaveWriter = QuickSaveWriter.Create("MainSave");
        _quickSaveWriter.Commit();

        _quickSaveReader = QuickSaveReader.Create("MainSave");

        Load();
    }
Beispiel #19
0
    public void SaveResourceAndUpgradeData()
    {
        QuickSaveWriter instWriter = QuickSaveWriter.Create(resourceAndUpgradeDataSaveFileName); //create an instance of the QuickSaveWriter

        instWriter.Write <int>("resources", Resources);
        instWriter.Write <int>("totalResources", TotalResources);
        instWriter.Write <int>("solarSystemNumber", SolarSystemNumber);
        instWriter.Write <int>("currentMaxLaserRange", currentMaxLaserRange);
        instWriter.Write <int>("currentMaxLaserRecharge", currentMaxLaserRecharge);
        instWriter.Write <int>("currentMaxRocketRange", currentMaxRocketRange);
        instWriter.Write <int>("currentMaxRocketReload", currentMaxRocketReload);
        instWriter.Write <int>("currentMaxRocketYield", currentMaxRocketYield);
        instWriter.Write <int>("currentMaxJumpRange", currentMaxJumpRange);
        instWriter.Write <int>("currentMaxJumpRecharge", currentMaxJumpRecharge);
        instWriter.Write <int>("currentMaxShieldBoost", currentMaxShieldBoost);
        instWriter.Write <bool>("currentShieldOverboostActive", currentShieldOverboostActive);
        instWriter.Write <int>("currentMaxShieldBoostRecharge", currentMaxShieldBoostRecharge);
        instWriter.Write <int>("currentMaxHealth", currentMaxHealth);
        instWriter.Write <int>("currentMaxShields", currentMaxShields);
        instWriter.Write <int>("currentMaxSensorRange", currentMaxSensorRange);

        instWriter.Write <bool>("rocketsInstalled", rocketsInstalled);
        instWriter.Write <bool>("jumpDriveInstalled", jumpDriveInstalled);
        instWriter.Write <bool>("shieldBoostInstalled", shieldBoostInstalled);

        instWriter.Write <int>("currentHealth", playerHealthControl.currentPlayerHealth);
        instWriter.Write <int>("currentShields", playerHealthControl.currentPlayerShields);
        instWriter.Write <int>("currentJumpCharge", abilityController.jumpRange);
        instWriter.Write <int>("currentLaserCharge", abilityController.laserRange);
        //Debug.Log("Laser range saved as " + abilityController.laserRange);
        instWriter.Write <int>("currentShieldBoostCharge", abilityController.currentShieldBoostCharge);
        instWriter.Write <int>("currentRocketReload", abilityController.currentRocketReloadAmount);

        instWriter.Write <int>("healthMaxUpgradeCost", HealthMaxUpgradeCost);
        instWriter.Write <int>("shieldMaxUpgradeCost", ShieldMaxUpgradeCost);
        instWriter.Write <int>("sensorRangeUpgradeCost", SensorRangeUpgradeCost);
        instWriter.Write <int>("rocketRangeUpgradeCost", RocketRangeUpgradeCost);
        instWriter.Write <int>("rocketReloadUpgradeCost", RocketReloadUpgradeCost);
        instWriter.Write <int>("rocketYieldUpgradeCost", RocketYieldUpgradeCost);
        instWriter.Write <int>("laserRangeUpgradeCost", LaserRangeUpgradeCost);
        instWriter.Write <int>("laserRechargeUpgradeCost", LaserRechargeUpgradeCost);
        instWriter.Write <int>("jumpRangeUpgradeCost", JumpRangeUpgradeCost);
        instWriter.Write <int>("jumpRechargeUpgradeCost", JumpRechargeUpgradeCost);
        instWriter.Write <int>("shieldBoostUpgradeCost", ShieldBoostUpgradeCost);
        instWriter.Write <int>("shieldBoostRechargeUpgradeCost", ShieldBoostRechargeUpgradeCost);
        instWriter.Write <int>("shieldOverboostUpgradeCost", ShieldOverboostUpgradeCost);

        instWriter.Write <float>("threatLevel", ThreatLevel);
        instWriter.Write <int>("maxThreatLevelCounter", MaxThreatLevelCounter);


        instWriter.Commit();//write the save file

        mapManager.Save();
    }
    public void Save()
    {
        QuickSaveWriter.Create("Inputs")
        .Write("Input1", Input1.text)
        .Write("Input2", Input2.text)
        .Write("Input3", Input3.text)
        .Write("Input4", Input4.text)
        .Commit();

        Content.text = QuickSaveRaw.LoadString("Inputs.json");
    }
Beispiel #21
0
    public void Text_Changed(string newText)
    {
        Player_Data Data = Player.GetComponent <Player_Data>();

        Data.name(newText);
        string encrypted = cryptography.Encrypt(newText);

        QuickSaveWriter.Create("Temp")
        .Write(cryptography.Encrypt("Name"), encrypted)
        .Commit();
    }
    public void SkipTutorial()
    {
        ClearGameAfterTutorial();

        var writer = QuickSaveWriter.Create("TutorialState");

        writer.Write("TutorialSkipped", true);
        writer.Commit();

        // перезагружает сцену, чтобы неактивные кнопки обновились
        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
    }
Beispiel #23
0
    public void change()
    {
        val = Convert.ToInt32(slider.value);
        string encrypted30 = cryptography.Encrypt(val);

        QuickSaveWriter.Create("UserData")
        .Write(cryptography.Encrypt("fps"), encrypted30)
        .Commit();
        Vl.text = val + "";
        HeroT Data = Player.GetComponent <HeroT>();

        Data.Fps(val);
    }
Beispiel #24
0
    public void Save()
    {
        var writer   = QuickSaveWriter.Create("ExhibitionData");
        var exhSeeds = new List <string>();

        foreach (var btn in exhButtons)
        {
            exhSeeds.Add(btn.GetComponent <ExhibitionButton>().NowSelected is null
                ? ""
                : btn.GetComponent <ExhibitionButton>().NowSelected.ToString());
        }
        writer.Write("Seeds", exhSeeds);
        writer.Commit();
    }
Beispiel #25
0
    public void SaveNewGameData()
    {
        Dictionary <string, int> playerCardInventoryFake = new Dictionary <string, int>();
        List <string>            deckFakeList            = new List <string>();

        //Save Everything as blank
        QuickSaveWriter.Create("SaveEverything")
        .Write("PlayerName", "")
        .Write("PlayerIcon", "")
        .Write("PlayerLevel", 0)
        .Write("PlayerXP", 0)
        .Write("PlayerCardInventory", playerCardInventoryFake)
        .Write("PlayerDeck", deckFakeList)
        .Commit();
    }
Beispiel #26
0
 public void Enable2(bool val2)
 {
     if (val2 == true)
     {
         toggle1.GetComponent <Toggle>().isOn = false;
         toggle2.GetComponent <Toggle>().isOn = true;
         toggle3.GetComponent <Toggle>().isOn = false;
         R = "Elf";
         selectedName.text = "Elf : -25% Base Strength \n -25% Base Endurance(HP) \n -25% Base Vitality(Defense) \n +75% Base Dexternity(Speed)";
         string encrypted = cryptography.Encrypt(R);
         QuickSaveWriter.Create("Temp")
         .Write(cryptography.Encrypt("Race"), encrypted)
         .Commit();
         Player_Data Data = Player.GetComponent <Player_Data>();
         Data.race(R);
     }
 }
Beispiel #27
0
 public void Enable3(bool val3)
 {
     if (val3 == true)
     {
         toggle1.GetComponent <Toggle>().isOn = false;
         toggle2.GetComponent <Toggle>().isOn = false;
         toggle3.GetComponent <Toggle>().isOn = true;
         R = "Orc";
         selectedName.text = "Orc : +50% Base Strength \n +50% Base Endurance(HP) \n -50% Base Intelligence(Magic Attack) \n -50% Base Constitution(M Defense) ";
         string encrypted = cryptography.Encrypt(R);
         QuickSaveWriter.Create("Temp")
         .Write(cryptography.Encrypt("Race"), encrypted)
         .Commit();
         Player_Data Data = Player.GetComponent <Player_Data>();
         Data.race(R);
     }
 }
    /// <summary>
    /// Выходит с начальной сцены, либо деактивирует текущий объект (использовать на последнем слайде)
    /// </summary>
    public void ChangeStartSceneOrDisable()
    {
        const string key = "GameInitialised";

        if (!QSReader.Create("GameState").Exists(key))
        {
            var writer = QuickSaveWriter.Create("GameState");
            writer.Write(key, true);
            writer.Commit();

            SceneManager.LoadScene(1);
        }
        else
        {
            gameObject.SetActive(false);
        }
    }
    public void female_Orc_Berseker(bool val)
    {
        if (val == true)
        {
            Male_Orc_Berseker.GetComponent <Toggle>().isOn   = false;
            Female_Orc_Berseker.GetComponent <Toggle>().isOn = true;

            G = "Female";
            string encrypted = cryptography.Encrypt(G);
            QuickSaveWriter.Create("Temp")
            .Write(cryptography.Encrypt("Gender"), encrypted)
            .Commit();

            Player_Data Data = Player.GetComponent <Player_Data>();
            Data.gender(G);
        }
    }
Beispiel #30
0
 public void Enable1(bool val1)
 {
     if (val1 == true)
     {
         string encrypted29 = cryptography.Encrypt("true");
         QuickSaveWriter.Create("UserData")
         .Write(cryptography.Encrypt("Hmp"), encrypted29)
         .Commit();
     }
     if (val1 == false)
     {
         string encrypted29 = cryptography.Encrypt("false");
         QuickSaveWriter.Create("UserData")
         .Write(cryptography.Encrypt("Hmp"), encrypted29)
         .Commit();
     }
 }