Save() public method

public Save ( ) : void
return void
Exemplo n.º 1
0
    public void SaveGame(string path, string name)
    {
        //Save all the game data
        PlayerSave.SetString("save_name", name);
        PlayerSave.SetDateTime("save_time", System.DateTime.Now);

        //Save the rigidbodies
        for (int i = 0; i < rigidbodies.Length; i++)
        {
            //Save the position, rotation and scale
            PlayerSave.SetTransform("rigidbody_" + i + "_pos", rigidbodies[i].transform);

            //Save the colour
            PlayerSave.SetColor("rigidbody_" + i + "_color", rigidbodies[i].GetComponent <Renderer>().material.color);

            //Save the velocity
            PlayerSave.SetVector3("rigidbody_" + i + "_velocity", rigidbodies[i].velocity);

            //Save the angular velocity
            PlayerSave.SetVector3("rigidbody_" + i + "_angularVelocity", rigidbodies[i].angularVelocity);
        }


        //PlayerSave does not automaticly save at all.
        //The PlayerSaveManager saves on recompile and ApplicationQuit, but only if its in the current scene
        PlayerSave.SetSaveFile(path);
        PlayerSave.Save();

        //Reload all the data
        RefreshSaveData();
    }
Exemplo n.º 2
0
    public static void RestoreEnergyByIdle()
    {
        PlayerSave.ActiveSave.energy.Value += (int)((DateTime.Now - PP.GetDateTime(PPKeys.LAST_ENERGY_RELOADING_TIME)).TotalSeconds / ENERGY_RELOADING_TIME);
        PlayerSave.Save();

        PP.SetDateTime(PPKeys.LAST_ENERGY_RELOADING_TIME, DateTime.Now);
    }
Exemplo n.º 3
0
    public void SaveLevelAchievements()
    {
        PlayerSave playerSave = FindObjectOfType <PlayerSave>();

        if (playerSave.levelCoins[playerSave.currentlevel] < CoinsCollected)
        {
            playerSave.levelCoins[playerSave.currentlevel] = CoinsCollected;
        }
        switch (levelGrade)
        {
        case "A":
            playerSave.levelGrade[playerSave.currentlevel] = PlayerSave.LevelGrade.A;
            break;

        case "B":
            if (playerSave.levelGrade[playerSave.currentlevel] == PlayerSave.LevelGrade.C || playerSave.levelGrade[playerSave.currentlevel] == PlayerSave.LevelGrade.Ungraded)
            {
                playerSave.levelGrade[playerSave.currentlevel] = PlayerSave.LevelGrade.B;
            }
            break;

        case "C":
            if (playerSave.levelGrade[playerSave.currentlevel] == PlayerSave.LevelGrade.Ungraded)
            {
                playerSave.levelGrade[playerSave.currentlevel] = PlayerSave.LevelGrade.C;
            }
            break;
        }
        playerSave.RefreshTotalCoins();
        playerSave.Save();
    }
Exemplo n.º 4
0
 public void LevelComplete()
 {
     if (!isLevelCompleted)
     {
         PlayerSave playerSave   = FindObjectOfType <PlayerSave>();
         int        currentLevel = SceneManager.GetActiveScene().buildIndex - 2; // -2 because of the start and level select scenes being first in the build order
         if (currentLevel < 26)
         {
             if (playerSave != null)
             {
                 playerSave.level[currentLevel + 1] = true;                     // unlocks next level
             }
         }
         playerSave.Save();
         Ball[] ballsInScene = FindObjectsOfType <Ball>();
         for (int i = 0; i < ballsInScene.Length; i++)
         {
             ballsInScene[i].Pause();
         }
         BossHealth bossHealth = FindObjectOfType <BossHealth>();
         if (bossHealth != null)
         {
             bossHealth.bIsPaused = true;
             FindObjectOfType <BossPickupSpawner>().bIsPaused = true;
         }
         FindObjectOfType <Paddle>().Pause();
         Camera.main.GetComponent <BlinderEffect>().activated = false;
         Instantiate(levelComplete);
         isLevelCompleted = true;
     }
 }
Exemplo n.º 5
0
    public void Reload()
    {
        PlayerSave.ActiveSave.energy.Value++;
        PlayerSave.Save();
        EnergyReloader.onEnergyReload.Invoke();

        PP.SetDateTime(PPKeys.LAST_ENERGY_RELOADING_TIME, DateTime.Now);

        StartCoroutine(Reloader());
    }
Exemplo n.º 6
0
    void OnDisable()
    {
        //We have to make sure the data isn't kept in the editor as it gets really confusing.
        if (!Application.isPlaying)
        {
            PlayerSave.DeleteAll();
            return;
        }

        //Pull out the settings and save the information before we loose it all during Serialization.
        _loadedCrypt = PlayerSave.GetEncryptionMethod();
        _loadedSave  = PlayerSave.GetSaveFile();
        PlayerSave.Save();
    }
Exemplo n.º 7
0
    void Start()
    {
        //Set encryption to none so we can see it.
        PlayerSave.SetEncryptionMethod(SaveEncryptionMethod.None);

        //All saving functions
        //String
        PlayerSave.SetString("string", "value");

        //Floats
        PlayerSave.SetFloat("float", 0F);
        PlayerSave.SetFloats("floats", new float[] { 0F, 0.1F, 0.2F });

        //Ints
        PlayerSave.SetInt("int", 0);
        PlayerSave.SetInts("ints", new int[] { 0, 1, 2 });

        //Booleans
        PlayerSave.SetBoolean("bool", true);
        PlayerSave.SetBooleans("bools", new bool[] { true, false, false });

        //Bytes
        PlayerSave.SetBytes("bytes", new byte[] { 0, 1, 2, 4, 8, 16, 32 });

        //Vectors
        PlayerSave.SetVector2("vector2", Vector2.up);
        PlayerSave.SetVector3("vector3", Vector3.one);
        PlayerSave.SetQuaternion("quaternion", transform.rotation);

        //Color
        PlayerSave.SetColor("color", Color.green);

        //Rectangle
        PlayerSave.SetRect("rect", new Rect(10, 10, 240, 25));

        //Time
        PlayerSave.SetDateTime("time", System.DateTime.Now);

        //Transform (pos, rot, scal combined)
        PlayerSave.SetTransform("transform", transform);

        //Texture
        PlayerSave.SetTexture2D("texture", texture);

        //Save the file
        PlayerSave.Save();
    }
Exemplo n.º 8
0
    public void RefreshSaveData(bool firstRun = false)
    {
        //Store the current settings, so we don't loose them on load
        string sav = PlayerSave.GetSaveFile();

        if (!firstRun)
        {
            PlayerSave.Save();
        }

        //Get all the save files at the path
        string[]         saveFiles = GetSaveFiles(Application.dataPath + "/" + saveDirectory);
        List <SavedGame> games     = new List <SavedGame>();

        //Itterate through all of them, getting the save data
        for (int i = 0; i < saveFiles.Length; i++)
        {
            //Load up the save
            PlayerSave.SetSaveFile(saveFiles[i]);
            PlayerSave.Load();

            //fetch the data about the save
            string          name = PlayerSave.GetString("save_name", "A Player Save");
            System.DateTime time = PlayerSave.GetDateTime("save_time", System.DateTime.Now);
            string          path = PlayerSave.GetSaveFile();

            //Store the save as a new SavedGame data
            games.Add(new SavedGame(name, path, time));
        }

        //Clear the array for readiness of the goods
        savedGames = null;

        //M'aiq has the goods for you.
        savedGames = games.OrderBy(o => o.time).Reverse().ToArray <SavedGame>() as SavedGame[];

        //Clear all the temporarly loaded settings
        PlayerSave.DeleteAll();

        //Reload the previous settings
        PlayerSave.SetSaveFile(sav);
        if (!firstRun)
        {
            PlayerSave.Load();
        }
    }
Exemplo n.º 9
0
 public void OnApplicationQuit()
 {
     //Save the data on quit.
     PlayerSave.Save();
 }
Exemplo n.º 10
0
 public void Save()
 {
     playerSave.Save();
 }