Example #1
0
        public static void SaveGame()
        {
            if (SavedGame == null)
            {
                SavedGame = new Tino.Save.Game();
            }

            GetGameState();

            BinaryFormatter bf = new BinaryFormatter();

            using (FileStream file = File.Create(Path))
            {
                bf.Serialize(file, SavedGame);
            }
        }
Example #2
0
        public static void LoadGame()
        {
            SaveLoadGame.SaveExists = false;
            if (!File.Exists(Path))
            {
                return;
            }

            BinaryFormatter bf = new BinaryFormatter();

            using (FileStream file = File.Open(Path, FileMode.Open))
            {
                SavedGame = (Tino.Save.Game)bf.Deserialize(file);
            }

            for (int i = 0; i < SavedGame.WorldItems.GetLength(0); i++)
            {
                WorldState.SceneItemState[SavedGame.WorldItems[i]] = SavedGame.WorldItemStates[i];
            }

            SaveLoadGame.SaveExists = true;
        }