enum PickupType { Candy = 0, Fish = 1 }
var pickupType = PickupType.Fish; 				//default
var amount = 23;									//public - changeble in the Unity enviroment
var sound : AudioClip;
var soundVolume : float = 2.0;


private var used = false;
private var mover : DroppableMover;

function Update()
{
	Debug.Log("ICI !");
	transform.Rotate(Vector3.up*Time.deltaTime);
}
function Start ()
{
	// do we exist in the level or are we instantiated by an enemy dying?
	mover = GetComponent(DroppableMover);
}

function ApplyPickup (playerStatus : ThirdPersonStatus)
{
	// A switch...case statement may seem overkill for this, but it makes adding new pickup types trivial.
	switch (pickupType)
	{
		case PickupType.Candy:
		Debug.Log("je suis bon");
			playerStatus.AddHealth(amount);		//add the amount of health
			break;
		
		case PickupType.Fish:					//add the amount of fish
			Menu.nbColect ++;
			playerStatus.FoundItem(amount);
			break;
	}
	
	return true;
}

function OnTriggerEnter (col : Collider) {

	// If there is an animation attached.
	// Play it.
	if (animation && animation.clip)
	{
		animation.Play();
		Destroy(gameObject, animation.clip.length);	//after animation he destroys the object
	}
	else
	{
		Destroy(gameObject);					//clear the pickUp object
	}


	if(mover && mover.enabled) return;
	var playerStatus : ThirdPersonStatus = col.GetComponent(ThirdPersonStatus);	//playerStatus has three components
	
	//* Make sure we are running into a player
	//* prevent picking up the trigger twice, because destruction
	//  might be delayed until the animation has finished
	if (used || playerStatus == null)
		return;
	
	if (!ApplyPickup (playerStatus))			//moras pozvati funkciju pametnice xD
		return;

	used = true;
	
	// Play sound
	if (sound)
		AudioSource.PlayClipAtPoint(sound, transform.position, soundVolume);
		
	
	
	
}

// Auto setup the pickup
function Reset ()
{
	if (collider == null)	
		gameObject.AddComponent(BoxCollider);
	collider.isTrigger = true;
}

@script RequireComponent(SphereCollider)
@script AddComponentMenu("Third Person Props/Pickup")	//where to put it, instead of default path