using UnityEngine;
using System.Collections;

public class Item {
	
	const float TEXTURE_TILE_SIZE = 1f * 16f / 512f;
	const float CORRECTION = 1f / (512f * 64f);
	
//	int place = 0;
	
	protected string name; 
	public Sprite icon = null;
	protected Coordinate uv;

	public Item () {
		name = "Sepulka";
		uv = new Coordinate(1, 0);
	}
	
	protected Sprite CreateSprite(Transform transform, Coordinate tileUV, Vector3 position){		
		return Tile.CreateChar(transform, tileUV, position);
	}
	
	public virtual void ShowIcon (Transform parent, Vector3 position) {
		if (icon != null) {
			icon.transform.parent = parent;
			icon.transform.localPosition = position;
			icon.visible = true;
		} else {
			icon = CreateSprite(parent, uv, position);
		}
	}
	
	public virtual void Hide(){
		if (icon != null)
			icon.visible = false;
	}
	
	public virtual bool Use(){
		return false;
	}
	
	public virtual void Destroy() {
		//if (icon != null)
		//	GameObject.Destroy(icon.gameObject);
		//icon = null;
	}
}
