using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class ItemSlot : MonoBehaviour {
	public Vector3 sPos;
	float posY = 0f;
	public bool active = false;

	public KeyCode key;
	public string type;
	public InventoryManager inv;
	public CastManager cast;

	void Start () {
		Vector3 p = transform.position;
		sPos = new Vector3 (p.x, p.y, p.z);
	}


	void Update () {
		if (active) {
			posY = Mathf.Cos (Time.time * Mathf.Deg2Rad * 400f) * 4f;
		} else {
			posY = 0f;
		}
		transform.position = new Vector3 (sPos.x, sPos.y + posY , sPos.z);

		if (Input.GetKeyUp(key)) {
			
			useItem ();
		}
	}

	public void useItem()
	{
		inv.activateItem (type);
	}

	public void setCastManager (CastManager cast)
	{
		this.cast = cast;
	}

	public void setActive(bool active) {
		this.active = active;
	}
}
