diff Assets/Application/Scripts/Item.cs @ 10:3fefb9f9025d

put Attribute class.
author Kazuma Takeda
date Fri, 20 Jan 2017 07:30:26 +0900
parents 599bd8ddb72b
children cf20add31466
line wrap: on
line diff
--- a/Assets/Application/Scripts/Item.cs	Wed Jan 18 22:00:24 2017 +0900
+++ b/Assets/Application/Scripts/Item.cs	Fri Jan 20 07:30:26 2017 +0900
@@ -11,20 +11,27 @@
 	private int nowBroken = 2;
 	public int indexID = 0;
 	public int itemID = 1;
+	public string ColorCode = "";
 
 	private Jungle jungle;
 
+	public void SetItem (ItemInfo item, int index) {
+		this.Broken = item.Broken;
+		nowBroken   = Broken;
+		Type        = item.Type;
+		itemID      = item.itemID;
+		indexID     = index;
+		ColorCode   = item.ColorCode;
+		SetColor (this.ColorCode);
+	}
 
-	public void SetItem (int broken, string type, string itemid, int id) {
+	public void SetItem (int broken, string type, string item_id, int index, string code) {
 		this.Broken = broken;
 		nowBroken   = Broken;
 		Type        = type;
-		itemID      = Convert.ToInt32(itemid);
-		indexID     = id;
-	}
-		
-
-	private void Start () {
+		itemID      = Convert.ToInt32(item_id);
+		indexID     = index;
+		SetColor (code);
 	}
 
 	public void SetPosition (Vector3 pos) {
@@ -32,6 +39,12 @@
 		// print ("Set (" + pos.x + ", " + pos.y + ", " + pos.z + ")");
 	}
 
+	public void SetColor (string code) {
+		Color color;
+		ColorUtility.TryParseHtmlString(code, out color);
+		this.GetComponent<MeshRenderer> ().material.color = color;
+	}
+
 	public void Delete() {
 		if (nowBroken == 0) {
 			Destroy (this.gameObject);