-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuestManager.cs
65 lines (43 loc) · 1.05 KB
/
QuestManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using UnityEngine;
using System.Collections;
using PixelCrushers.DialogueSystem;
using System;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
public class QuestManager : MonoBehaviour
{
string saveData;
void Update ()
{
if (Input.GetKeyUp(KeyCode.T))
{
Save ();
}
if (Input.GetKeyUp(KeyCode.G))
{
Load ();
}
}
void Save ()
{
saveData = PersistentDataManager.GetSaveData();
Debug.Log (saveData);
BinaryFormatter bf = new BinaryFormatter();
string fileName = @"C:/SaveGame/Quests" ;
FileStream file = File.Create(fileName);
saveQuest data = new saveQuest();
data.saveData = saveData;
bf.Serialize (file, data);
file.Close ();
}
void Load ()
{
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Open (@"C:/SaveGame/Quests" , FileMode.Open);
saveQuest data = (saveQuest) bf.Deserialize(file);
file.Close();
saveData = data.saveData;
DialogueManager.Instance.GetComponent<LevelManager>().LoadGame(saveData);
Debug.Log (saveData);
}
}