view README.md @ 41:bd44baa491a9 default tip

add TestJungleCore.cs
author Kazuma Takeda
date Thu, 23 Feb 2017 17:19:55 +0900
parents f7616084d3ab
children
line wrap: on
line source

# Jungle-Sharp

using UnityEngine.
tree structure database.

# How to use Jungle-Sharp

namespace is JungleDB, so you write c# script.

using JungleDB;

# How to use Jungle Database.

- need interface.

Jungle
JungleTree
JungleTreeEditor
NodePath

1. Create Instance Jungle from DefaultJungle Class.
2. Create Tree in 1's Jungle Instance.
3. Set 2'Tree to Jungle Tree. 
4. Change Tree Mode to Editor Tree Mode, so Set JungleTreeEditor.
5. Create root a Path.
6. Put Key(String) and Value(Byte Array)  Attribute from path to TreeEditor.

private void Start () {
  Jungle jungle = new DefaultJungle(null, "TestJungle", new DefaultTreeEditor(new DefaultTraverser()));
  jungle.createNewTree ("TestTree");
  JungleTree tree = jungle.getTreeByName ("TestTree");
  JungleTreeEditor editor = tree.getTreeEditor();
  NodePath root = new DefaultNodePath ();
  // if put root.
  Either<Error, JungleTreeEditor> putAttr = editor.putAttribute(root, "Key", "Value"); // <-1>
  if(putAttr.isA()) { // put error.
    // Expection
  }
  
  editor = putAttr.b();

  // elif put root children path.
  NodePath path = root.add(0);
  Either<Error, JungleTreeEditor> createRootChild = editor.addNewChildAt(root, 0); // <-1, 0>
  if(createRootChild.isA()) { // child create error.
    // Expection
  }

  editor = createRootChild.b(); // success create root child.

  putAttr = editor.putAttribute(path, "Key", "Value");
  if(putAttr.isA()) { // put error.
    // Expection
  }

  editor = putAttr.b();
  
  // else put other path child.
  path = path.add(0);
  Either<Error, JungleTreeEditor> createPathChild = editor.addNewChildAt(path, 0); // <-1, 0, 0>
  if(createPathChild.isA()) { // child create error.
    // Expection
  }

  editor = createPathChild.b();
  
  putAttr = editor.putAttribute(path, "Key", "Value"); 
  if(putAttr.isA()) { // put error.
    // Expection
  }

  editor = putAttr.b(); 

  // end put Attribute function.
}

# Fix Update

1/18 no use path, Continue to put on the created path.