using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameplayBin : MonoBehaviour {

	public Material matWhenCollected;
	public Material matWhenWin;
	public int numCollected = 0;
	public int numCollectedToWin = 10;
	public GameObject objToWinColor;

	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {

		if (numCollected >= numCollectedToWin) {
			Debug.Log ("A winner is you!");
			objToWinColor.GetComponent<Renderer> ().sharedMaterial = matWhenWin;
			numCollected = 0;
		}
		
	}

	void OnTriggerEnter (Collider toucher) {

		if (toucher.tag == "garbage" || toucher.tag == "garbage_attract") {
			toucher.GetComponent<Renderer> ().sharedMaterial = matWhenCollected;
			toucher.GetComponent<Transform>().tag = "garbage_collected";
			toucher.GetComponent<Rigidbody> ().isKinematic = true;
			numCollected++;
			Debug.Log (numCollected + " collected of " + numCollectedToWin + " total!");
		}
	
	}
}
