diff Assets/Application/Scripts/Item.cs @ 8:599bd8ddb72b

Create Item Tree and Create Stage.
author Kazuma Takeda
date Tue, 17 Jan 2017 19:57:19 +0900
parents 2878be4487ec
children 3fefb9f9025d
line wrap: on
line diff
--- a/Assets/Application/Scripts/Item.cs	Thu Dec 15 22:45:31 2016 +0900
+++ b/Assets/Application/Scripts/Item.cs	Tue Jan 17 19:57:19 2017 +0900
@@ -1,12 +1,61 @@
 using UnityEngine;
 using System.Collections;
-
+using JungleDB;
+using System.Text;
+using System;
 public class Item : MonoBehaviour {
 
-	public Stage.Type Attribute;
-	public int ID = 0;
+	public string Type;
+	public GameObject ItemImage;
+	public int Broken = 2;
+	private int nowBroken = 2;
+	public int indexID = 0;
+	public int itemID = 1;
+
+	private Jungle jungle;
+
+
+	public void SetItem (int broken, string type, string itemid, int id) {
+		this.Broken = broken;
+		nowBroken   = Broken;
+		Type        = type;
+		itemID      = Convert.ToInt32(itemid);
+		indexID     = id;
+	}
+		
+
+	private void Start () {
+	}
 
-	public void SetHaveObject () {
-		Player.Instance.SetHaveObjectNumber (Attribute);
+	public void SetPosition (Vector3 pos) {
+		this.transform.position = pos;
+		// print ("Set (" + pos.x + ", " + pos.y + ", " + pos.z + ")");
+	}
+
+	public void Delete() {
+		if (nowBroken == 0) {
+			Destroy (this.gameObject);
+			return;
+		}
+
+		nowBroken -= 1;
+	}
+
+	public void SetCreateTreeNode () {
+		jungle = SaveDataTest.jungle;
+		JungleTree tree      = jungle.getTreeByName ("SceneTree");
+		JungleTreeEditor edt = tree.getTreeEditor ();
+
+		NodePath root        = new DefaultNodePath ();
+		NodePath stagePath   = root.add (1);
+		edt                  = edt.addNewChildAt(stagePath, indexID).b();
+
+		Either<Error, JungleTreeEditor> e = edt.putAttribute (stagePath.add (indexID), "Item_ID", Encoding.UTF8.GetBytes(itemID.ToString()));
+		if (e.isA ()) {
+			print ("[Error] Try again!");
+			SetCreateTreeNode ();
+		}
+		edt = e.b ();
+		edt.commit ();
 	}
 }