Esempio n. 1
0
        /// <summary>
        /// Loads the game settings from a certain file
        /// </summary>
        /// <param name="extension">The extension where the desired settings are saved</param>
        /// <returns>The certain game settings at a specific location</returns>
        public static GameSettings LoadGameSettings(string extension)
        {
            // Get a default settings in case none exists
            GameSettings data = new GameSettings();

            // If a file exists
            Debug.Log(settingsDataPath + extension);
            if (File.Exists(settingsDataPath + extension))
            {
                // Open the file and get all the data from the file to load
                BinaryFormatter bf   = new BinaryFormatter();
                FileStream      file = File.Open(settingsDataPath + extension, FileMode.Open);

                data = (GameSettings)bf.Deserialize(file);
                file.Close();

                return(data);
            }
            // No file exists, so save the default data
            else
            {
                SaveManager.SaveGameSettings(data, extension);
                return(data);
            }
        }
Esempio n. 2
0
        void Start()
        {
            if (fileName == "")
            {
                return;
            }
            GameSettings g = new GameSettings();

            g.Type = type;

            g.TimeLimitEnabled = timeLimitEnabled;
            g.TimeLimit        = (timeLimit == 0 ? Mathf.Infinity : timeLimit);
            g.KillLimit        = (killLimit == 0 ? Mathf.Infinity : killLimit);
            g.StockLimit       = (stockLimit == 0 ? Mathf.Infinity : stockLimit);
            g.ArrowLimit       = (arrowLimit == 0 ? Mathf.Infinity : arrowLimit);
            g.DamageModifier   = damageModifier;
            g.GravityModifier  = gravityModifier;
            g.SpeedModifier    = speedModifier;
            g.TokenSpawnFreq   = tokenSpawnFreq;
            g.PlayerSpawnFreq  = playerSpawnFreq;

            enabledTokens = new Dictionary <Enums.Tokens, Enums.Frequency>();
            for (int i = 0; i < tokens.Count; i++)
            {
                enabledTokens.Add(tokens[i], freqs[i]);
            }
            g.EnabledTokens = enabledTokens;
            g.DefaultTokens = defaultTokens;

            // Save the settings
            SaveManager.SaveGameSettings(g, fileName + ".dat");
        }