diff Assets/Application/Scripts/BoxItem.cs @ 13:e297afe0889d default tip

Add Prefab.
author Kazuma Takeda
date Tue, 07 Feb 2017 20:49:26 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Assets/Application/Scripts/BoxItem.cs	Tue Feb 07 20:49:26 2017 +0900
@@ -0,0 +1,37 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class BoxItem : Item {
+
+	public int Broken = 2;
+	private int nowBroken = 2;
+	public string ColorCode = "";
+
+	public void SetItem (BoxItemInfo item, int index) {
+		Broken      = item.Broken;
+		nowBroken   = Broken;
+		Type        = item.Type;
+		itemID      = item.itemID;
+		indexID     = index;
+		ColorCode   = item.ColorCode;
+		SetColor (this.ColorCode);
+	}
+
+	public override void Delete() {
+		if (nowBroken == 0) {
+			DeleteTreeNode ();
+			Destroy (this.gameObject);
+			return;
+		}
+		nowBroken -= 1;
+	}
+
+	public void SetColor (string code) {
+		Color color;
+		ColorUtility.TryParseHtmlString(code, out color);
+		this.GetComponent<MeshRenderer> ().material.color = color;
+	}
+
+
+}