comparison Assets/Application/Scripts/SaveData.cs @ 4:2878be4487ec

add Maping Code.
author Kazuma
date Tue, 08 Nov 2016 17:07:48 +0900
parents e5ef0342d00b
children 12f4f937da7f
comparison
equal deleted inserted replaced
3:2dd40b4412e4 4:2878be4487ec
3 3
4 public class SaveData : MonoBehaviour { 4 public class SaveData : MonoBehaviour {
5 5
6 public static SaveData Instance; 6 public static SaveData Instance;
7 7
8 private Jungle mainScene ;
9 private JungleTree mainTree;
10 private JungleTreeEditor TreeEditor;
11 private TreeNode node;
8 // Use this for initialization 12 // Use this for initialization
9 void Awake () { 13 void Awake () {
10 if (Instance == null) { 14 if (Instance == null) {
11 Instance = this; 15 Instance = this;
12 } 16 }
13 } 17 }
18
19 private void Start () {
20 JungleStart ();
21 }
22
23 private void JungleStart () {
24 Debug.Log ("[Jungle] Start ...");
25 mainScene = new DefaultJungle(null, "Main", new DefaultTreeEditor(new DefaultTraverser()));
26 }
27
28 public void CreateTree (string name) {
29 mainTree = mainScene.createNewTree (name);
30 Debug.Log ("[Jungle] Create " + name + " Tree");
31 EditorMode ();
32 }
33
34 public void EditorMode () {
35 TreeEditor = mainTree.getTreeEditor ();
36 Debug.Log ("[Jungle] Editor Mode" + TreeEditor.ToString());
37 }
38
39 public void PutAttribute (NodePath path, string key, byte[] value) {
40 Either<Error, JungleTreeEditor> either = TreeEditor.putAttribute (path, key, value);
41 if (either.isA ()) {
42 Debug.LogError ("[Error]" + either.a());
43 } else {
44 Debug.Log ("[Success]");
45 either.b ();
46 }
47 }
48
49 public void GetAttribute (NodePath path, string key) {
50 node = mainTree.getNodeOfPath (path).b ();
51 byte[] target = node.getAttributes ().get (key);
52 var obj = ConvertObject.UnConvert (target);
53 print (obj);
54 }
55
56 public void Push() {
57 Either<Error, JungleTreeEditor> r = TreeEditor.success();
58 if (!r.isA ()) {
59 Debug.LogError ("[Error]");
60 } else {
61 Debug.Log ("[Success]");
62 TreeEditor = r.b ();
63 }
64 }
14 } 65 }