예제 #1
0
        // Use this for initialization
        void Start()
        {
            if (MainMenuManager.IsContinue)
            {
                DungeLikeCurrentGameData = BinarySaver.LoadCurrentGameData();
                Level = DungeLikeCurrentGameData.Level;
            }

            Initialize();
        }
예제 #2
0
        internal void SaveCurrentGameData()
        {
            DungeLikeCurrentGameData = new DungeLikeCurrentGameData();
            DungeLikeCurrentGameData.PlayerHealth = Player.Health.Value;
            DungeLikeCurrentGameData.PlayerMana   = Player.Mana.Value;
            DungeLikeCurrentGameData.PlayerAttack = Player.Attack.Value;
            DungeLikeCurrentGameData.Level        = Level;
            DungeLikeCurrentGameData.Gold         = Player.Gold.Value;

            BinarySaver.SaveData(DungeLikeCurrentGameData);
        }
예제 #3
0
    public static void SaveData(DungeLikeCurrentGameData data)
    {
        string folderPath = Path.Combine(Application.persistentDataPath, currentGameFolderName);

        if (!Directory.Exists(folderPath))
        {
            Directory.CreateDirectory(folderPath);
        }
        string filePath = Path.Combine(folderPath, currentGameFolderName + fileExtension);

        var binaryFormatter = new BinaryFormatter();

        using (FileStream fileStream = File.Open(filePath, FileMode.OpenOrCreate))
        {
            binaryFormatter.Serialize(fileStream, data);
        }
    }