comparison Assets/Application/Scripts/Test/SaveDataTest.cs @ 11:cf20add31466

change putAttribute -> use fmap.
author Kazuma Takeda
date Sat, 28 Jan 2017 19:15:44 +0900
parents 3fefb9f9025d
children
comparison
equal deleted inserted replaced
10:3fefb9f9025d 11:cf20add31466
2 using UnityEditor; 2 using UnityEditor;
3 using System.Collections; 3 using System.Collections;
4 using UnityEngine.SceneManagement; 4 using UnityEngine.SceneManagement;
5 using JungleDB; 5 using JungleDB;
6 using System.Text; 6 using System.Text;
7 using Default = System.Collections.Generic;
7 8
8 public class SaveDataTest : MonoBehaviour { 9 public class SaveDataTest : MonoBehaviour {
9 10
10 public static SaveDataTest instance; 11 public static SaveDataTest instance;
11 12
109 110
110 private void CreateItemTree () { 111 private void CreateItemTree () {
111 JungleTree tree = jungle.createNewTree ("ItemTree"); 112 JungleTree tree = jungle.createNewTree ("ItemTree");
112 JungleTreeEditor edt = tree.getTreeEditor (); 113 JungleTreeEditor edt = tree.getTreeEditor ();
113 114
114 edt = edt.putAttribute (rootPath, "TreeName", "Item").b ();
115 115
116 edt = edt.addNewChildAt (rootPath, 0).b (); 116 Either<Error, JungleTreeEditor> e = edt.putAttribute (rootPath, "TreeName", "Item");
117 edt = edt.putAttribute ("Category", "Box").b ();
118 117
119 edt = edt.addNewChildAt (rootPath, 1).b (); 118 System.Func<JungleTreeEditor, JungleTreeEditor> f = (JungleTreeEditor arg) => {
120 edt = edt.putAttribute ("Category", "Food").b (); 119 edt = arg;
120 return edt;
121 };
122
123 e.fmap (f, edt.addNewChildAt (rootPath, 0));
124 e.fmap (f, edt.putAttribute ("Category", "Box"));
125
126 e.fmap (f, edt.addNewChildAt (rootPath, 1));
127 e.fmap (f, edt.putAttribute ("Category", "Food"));
121 128
122 NodePath path = rootPath.add(0); 129 NodePath path = rootPath.add(0);
123 130
124 edt = edt.addNewChildAt (path, 0).b (); 131 Default.List<ItemInfo> infoList = new Default.List<ItemInfo> ();
132 infoList.Add (new ItemInfo (1, 2, "Grass", "#019540FF"));
133 infoList.Add (new ItemInfo (2, 4, "Wood", "#7F3C01FF"));
134 infoList.Add (new ItemInfo (3, 1, "Sand", "#D4500EFF"));
135 infoList.Add (new ItemInfo (4, 5, "Water", "#2432ADFF"));
125 136
126 ItemInfo item_info = new ItemInfo (1, 2, "Grass", "#019540FF"); 137 int i = 0;
127 edt = edt.putAttribute (item_info).b (); 138 foreach (var info in infoList) {
139 e.fmap (f, edt.addNewChildAt (path, i));
140 e.fmap (f, edt.putAttribute (info));
141 i++;
142 }
128 143
129 edt = edt.addNewChildAt (path, 1).b ();
130 item_info = new ItemInfo (2, 4, "Wood", "#7F3C01FF");
131 edt = edt.putAttribute (item_info).b ();
132
133 edt = edt.addNewChildAt (path, 2).b ();
134 item_info = new ItemInfo (3, 1, "Sand", "#D4500EFF");
135 edt = edt.putAttribute (item_info).b ();
136
137
138 edt = edt.addNewChildAt (path, 3).b ();
139 item_info = new ItemInfo (4, 5, "Water", "#2432ADFF");
140 edt = edt.putAttribute (item_info).b ();
141 edt.commit (); 144 edt.commit ();
142 145
143 StageManager.Instance.Init (); 146 StageManager.Instance.Init ();
144 } 147 }
145 148