Mercurial > hg > Members > kazuma > JungleforUnity
view 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 source
using UnityEngine; using System.Collections; using JungleDB; using System.Text; using System; public class Item : MonoBehaviour { 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 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 (); } }