Пример #1
0
 void Start()
 {
     mapValues = GameObject.FindObjectOfType <WorldValues>();
     chunksVisibleInLoadDistance = Mathf.RoundToInt(maxLoadDistance / chunkSize);
     if (GameManager.instance.worldValues.newSave == true)
     {
         SpawnPlayer();
     }
     else
     {
         LoadPlayer();
     }
 }
Пример #2
0
    public SaveData(PlayerStats PlayerStats, WorldValues WorldValues, string SaveName)
    {
        health = PlayerStats.currentHealth;
        xp     = PlayerStats.xp;
        level  = PlayerStats.level;

        position    = new float[3];
        position[0] = PlayerStats.position.x;
        position[1] = PlayerStats.position.y;
        position[2] = PlayerStats.position.z;

        seed     = WorldValues.seed;
        saveName = SaveName;
    }
Пример #3
0
    public static bool CreateNewSave(string saveName, PlayerStats playerStats, WorldValues worldValues)
    {
        BinaryFormatter formatter = GetBinaryFormatter();

        if (!Directory.Exists(Path.GetDirectoryName(Application.dataPath) + "/Saves"))
        {
            Directory.CreateDirectory(Path.GetDirectoryName(Application.dataPath) + "/Saves");
        }

        string path = Path.GetDirectoryName(Application.dataPath) + "/Saves/" + saveName + ".save";

        if (File.Exists(path))
        {
            Debug.Log("There is already a world with this name");
            int numberOfDuplicates = 0;

            DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(Application.dataPath) + "/Saves/");
            FileInfo[]    fileInfo      = directoryInfo.GetFiles(saveName + "*.save");

            if (fileInfo.Length > 0)
            {
                for (int i = 0; i < fileInfo.Length; i++)
                {
                    numberOfDuplicates++;
                }
            }

            saveName = saveName + " " + numberOfDuplicates;

            path = Path.GetDirectoryName(Application.dataPath) + "/Saves/" + saveName + ".save";
        }

        FileStream file = new FileStream(path, FileMode.Create);

        SaveData saveData = new SaveData(playerStats, worldValues, saveName);

        worldValues.worldName = saveName;

        formatter.Serialize(file, saveData);

        file.Close();

        return(true);
    }
Пример #4
0
    public static bool Save(string saveName, PlayerStats playerStats, WorldValues worldValues)
    {
        BinaryFormatter formatter = GetBinaryFormatter();

        if (!Directory.Exists(Path.GetDirectoryName(Application.dataPath) + "/Saves"))
        {
            Directory.CreateDirectory(Path.GetDirectoryName(Application.dataPath) + "/Saves");
        }

        string path = Path.GetDirectoryName(Application.dataPath) + "/Saves/" + saveName + ".save";

        FileStream file = new FileStream(path, FileMode.Create);

        SaveData saveData = new SaveData(playerStats, worldValues, saveName);

        formatter.Serialize(file, saveData);

        file.Close();

        return(true);
    }
Пример #5
0
        public void UpdateBudget()
        {
            BudgetGlobalImpact fullImpact = GenerateGlobalImpact();

            WorldValues.NewYear(fullImpact);
        }
Пример #6
0
 private void Awake()
 {
     mapValues = GameObject.FindObjectOfType <WorldValues>();
 }