comparison Assets/Application/Scripts/Item.cs @ 12:b55d586dd4eb

change bind from fmap.
author Kazuma Takeda
date Tue, 07 Feb 2017 20:48:57 +0900
parents cf20add31466
children
comparison
equal deleted inserted replaced
11:cf20add31466 12:b55d586dd4eb
1 using UnityEngine; 1 using UnityEngine;
2 using System.Collections; 2 using System.Collections;
3 using JungleDB; 3 using JungleDB;
4 using System.Text; 4 using System.Text;
5 using System; 5 using System;
6
7 /// <summary>
8 /// Base Item Class.
9 /// </summary>
6 public class Item : MonoBehaviour { 10 public class Item : MonoBehaviour {
7 11
8 public string Type; 12 public string Type;
9 public GameObject ItemImage;
10 public int Broken = 2;
11 private int nowBroken = 2;
12 public int indexID = 0; 13 public int indexID = 0;
13 public int itemID = 1; 14 public int itemID = 1;
14 public string ColorCode = "";
15 15
16 private Jungle jungle; 16 public Jungle jungle;
17
18 public void SetItem (ItemInfo item, int index) {
19 this.Broken = item.Broken;
20 nowBroken = Broken;
21 Type = item.Type;
22 itemID = item.itemID;
23 indexID = index;
24 ColorCode = item.ColorCode;
25 SetColor (this.ColorCode);
26 }
27
28 public void SetItem (int broken, string type, string item_id, int index, string code) {
29 this.Broken = broken;
30 nowBroken = Broken;
31 Type = type;
32 itemID = Convert.ToInt32(item_id);
33 indexID = index;
34 SetColor (code);
35 }
36 17
37 public void SetPosition (Vector3 pos) { 18 public void SetPosition (Vector3 pos) {
38 this.transform.position = pos; 19 this.transform.position = pos;
39 // print ("Set (" + pos.x + ", " + pos.y + ", " + pos.z + ")");
40 } 20 }
41 21
42 public void SetColor (string code) { 22 public virtual void Delete() {
43 Color color; 23
44 ColorUtility.TryParseHtmlString(code, out color);
45 this.GetComponent<MeshRenderer> ().material.color = color;
46 }
47
48 public void Delete() {
49 if (nowBroken == 0) {
50 DeleteTreeNode ();
51 Destroy (this.gameObject);
52 return;
53 }
54
55 nowBroken -= 1;
56 } 24 }
57 25
58 public void DeleteTreeNode () { 26 public void DeleteTreeNode () {
59 jungle = SaveDataTest.jungle; 27 jungle = SaveData.jungle;
60 JungleTree tree = jungle.getTreeByName ("SceneTree"); 28 JungleTree tree = jungle.getTreeByName ("SceneTree");
61 JungleTreeEditor edt = tree.getTreeEditor (); 29 JungleTreeEditor edt = tree.getTreeEditor ();
62 30
63 NodePath root = new DefaultNodePath (); 31 NodePath root = new DefaultNodePath ();
64 NodePath stagePath = root.add (1); 32 NodePath stagePath = root.add (1);
72 edt.commit (); 40 edt.commit ();
73 } 41 }
74 42
75 43
76 public void SetCreateTreeNode () { 44 public void SetCreateTreeNode () {
77 jungle = SaveDataTest.jungle; 45 jungle = SaveData.jungle;
78 JungleTree tree = jungle.getTreeByName ("SceneTree"); 46 JungleTree tree = jungle.getTreeByName ("SceneTree");
79 JungleTreeEditor edt = tree.getTreeEditor (); 47 JungleTreeEditor edt = tree.getTreeEditor ();
80 48
81 NodePath root = new DefaultNodePath (); 49 NodePath root = new DefaultNodePath ();
82 NodePath stagePath = root.add (1); 50 NodePath stagePath = root.add (1);