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

public class endLevel : MonoBehaviour {

	public int victoryAmount = 2;

	private int counter = 0;

	void OnTriggerEnter(Collider collision) {
		if(collision.gameObject.tag == "Player")counter++;
		if (counter >= victoryAmount) {
			loadNextScene ();
		}
	}

	void loadNextScene() {
		SceneManager.LoadSceneAsync (SceneManager.GetActiveScene().buildIndex + 1);
	}

	void OnTriggerExit(Collider collision) {
		if(collision.gameObject.tag == "Player")counter--;
	}
}