13
|
1 using System.Collections;
|
|
2 using System.Collections.Generic;
|
|
3 using UnityEngine;
|
|
4
|
|
5 public class BoxItem : Item {
|
|
6
|
|
7 public int Broken = 2;
|
|
8 private int nowBroken = 2;
|
|
9 public string ColorCode = "";
|
|
10
|
|
11 public void SetItem (BoxItemInfo item, int index) {
|
|
12 Broken = item.Broken;
|
|
13 nowBroken = Broken;
|
|
14 Type = item.Type;
|
|
15 itemID = item.itemID;
|
|
16 indexID = index;
|
|
17 ColorCode = item.ColorCode;
|
|
18 SetColor (this.ColorCode);
|
|
19 }
|
|
20
|
|
21 public override void Delete() {
|
|
22 if (nowBroken == 0) {
|
|
23 DeleteTreeNode ();
|
|
24 Destroy (this.gameObject);
|
|
25 return;
|
|
26 }
|
|
27 nowBroken -= 1;
|
|
28 }
|
|
29
|
|
30 public void SetColor (string code) {
|
|
31 Color color;
|
|
32 ColorUtility.TryParseHtmlString(code, out color);
|
|
33 this.GetComponent<MeshRenderer> ().material.color = color;
|
|
34 }
|
|
35
|
|
36
|
|
37 }
|