annotate src/test/csharp/DefaultJungleTreeTest.cs @ 0:dec15de2c6ff

first commit
author Kazuma
date Tue, 21 Jun 2016 17:11:12 +0900
parents
children 4d08270a61c8 02b2ab7bffe6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
1 using UnityEngine;
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
2 using System.Collections;
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
3 using System;
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
4 //using System.Diagnostics;
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
5
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
6 public class DefaultJungleTreeTest : MonoBehaviour { // apiの仕様的にこんな感じ
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
7
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
8 public Jungle instance() {
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
9 Jungle j = new DefaultJungle(null, "hoge", new DefaultTreeEditor(new DefaultTraverser())); // hogeというtreeを作る
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
10 return j;
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
11 }
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
12
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
13 public static string key = "KEY";
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
14 public GameObject value;
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
15
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
16 void Start() {
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
17 Jungle j = instance ();
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
18 JungleTree tree = j.createNewTree ("tree"); // hogeの中にtreeという名前の木を作る
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
19
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
20 JungleTreeEditor editor1 = tree.getTreeEditor (); // editor
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
21
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
22 DefaultNodePath path = new DefaultNodePath ();
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
23 // NodePath path;
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
24
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
25 Either<Error, JungleTreeEditor> either = editor1.putAttribute (path, key, value);
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
26 if (either.isA ()) { // 失敗した場合のコード
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
27 Debug.Log ("失敗しました。");
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
28 }
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
29 editor1 = either.b (); //成功した場合
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
30 editor1.success (); // 大本にあるTreeにここで変更を加える
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
31
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
32 TreeNode node = tree.getRootNode ();
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
33 Debug.Log (node);
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
34 Debug.Log (node.getAttributes ().getKeys ());
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
35 GameObject v = node.getAttributes ().get (key);
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
36 Debug.Log (v);
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
37
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
38 }
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
39
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
40 void Update() {
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
41
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
42 }
dec15de2c6ff first commit
Kazuma
parents:
diff changeset
43 }