public static void LoadFakeDebugSave()
    {
        dontWriteFiles = true;
        int       HP    = 99999;
        int       MaxHP = 99999;
        int       AP    = 99999;
        int       MaxAP = 99999;
        int       level = 1;
        ArmorType aType = ArmorType.Blue;

        string[] guns = new string[5] {
            "fists", "pistol", "shotgun", "rocket", "chaingun"
        };

        AmmoType[] ammoTypes = (AmmoType[])Enum.GetValues(typeof(AmmoType));
        Ammo[]     ammos     = new Ammo[ammoTypes.Length];
        for (int i = 0; i < ammoTypes.Length; i++)
        {
            AmmoType type = ammoTypes[i];
            Ammo     ammo = new Ammo(type);
            ammo.AddAmmo(999);
            ammos[i] = ammo;
        }

        save      = new SaveVariables(HP, MaxHP, AP, MaxAP, level, aType, guns, ammos);
        saveIndex = 0;
    }
 void MakeSingleton()
 {
     if (instance != null)
     {
         Destroy(this.gameObject);
     }
     else
     {
         instance = this;
         DontDestroyOnLoad(this.gameObject);
     }
 }
    public static void New(int _saveIndex)
    {
        if (!loadedSaves)
        {
            return;
        }

        Debug.Log("Overwriting save" + _saveIndex + " with a new variable set...");
        saveIndex        = _saveIndex;
        save             = DefaultSave();
        saves[saveIndex] = save;
        savesExist       = true;
        WriteSaveFiles();
    }
Exemple #4
0
 public void LoadScore()
 {
     RNG = Random.Range(0, ScorePaths.Count - 1);
     if (ScorePaths.Count > 0 && RNG != lastRNG || ScorePaths.Count == 1 || ScorePaths.Count == 2)
     {
         lastRNG = RNG;
         SaveVariables data = SaveManager.LoadScore(ScorePaths[RNG]);
     }
     else
     {
         if (ScorePaths.Count == 0)
         {
             Debug.Log("NO MORE Scores");
         }
         LoadScore();
     }
 }
    public static void SaveScore(SaveNLoad SD)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        //name/path of file
        string path = Application.persistentDataPath + "/Highscore" + "/" + SD.Player + Random.Range(0, 1000000000) + ".Asteroid";

        if (!File.Exists(path))
        {
            FileStream    stream   = new FileStream(path, FileMode.Create);
            SaveVariables SaveData = new SaveVariables(SD);
            formatter.Serialize(stream, SaveData);
            stream.Close();
        }
        else
        {
            Debug.Log("FILE ALREADY EXISTS");
        }
    }
    public static SaveVariables LoadScore(string EPath)
    {
        string path = Application.persistentDataPath + "/Highscore" + "/" + EPath;

        if (File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(path, FileMode.Open);

            SaveVariables data = formatter.Deserialize(stream) as SaveVariables;
            stream.Close();
            return(data);
        }
        else
        {
            Debug.LogError("NO FILE FOUND AT: " + path);
            return(null);
        }
    }
    public static void Load(int _saveIndex)
    {
        if (!loadedSaves)
        {
            LoadAll();
        }

        Debug.Log("Loading save save" + _saveIndex + ".json ...");
        SaveVariables saveToLoad = saves[_saveIndex];

        if (saveToLoad != null)
        {
            save      = saveToLoad;
            saveIndex = _saveIndex;
        }
        else
        {
            Debug.LogError($"Couldn't load {_saveIndex}.");
        }
    }
Exemple #8
0
    private void Start()
    {
        SaveManager.MakeDirectory();
        ScorePaths = SaveManager.GetFileNames();
        foreach (string item in ScorePaths)
        {
            SaveVariables data = SaveManager.LoadScore(item);
            sorted.Add(int.Parse(data.Score));
            sorted.Sort();
        }
        List <int> finalscore = new List <int>();

        for (int i = sorted.Count; i-- > 0;)
        {
            finalscore.Add(sorted[i]);
        }
        sorted          = finalscore;
        ScoreUI[0].text = "Score: " + sorted[0].ToString();
        ScoreUI[1].text = "Score: " + sorted[1].ToString();
        ScoreUI[2].text = "Score: " + sorted[2].ToString();
        ScoreUI[3].text = "Score: " + sorted[3].ToString();
        ScoreUI[4].text = "Score: " + sorted[4].ToString();
    }