view 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 source

´╗┐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;
	}


}