using UnityEngine;
using System.Collections;

public class NextLevelTrigger : MonoBehaviour {

	private int numPlayersInScene = 0;
	private int numPlayersReachedEnd = 0;

	void Start()
	{
		numPlayersInScene = GameObject.FindGameObjectsWithTag ("Player").Length;
	}

	void OnTriggerEnter2D (Collider2D other) {
	
		if (other.tag == "Player") {
			numPlayersReachedEnd++;
			if(numPlayersReachedEnd >= numPlayersInScene)
				Application.LoadLevel(Application.loadedLevel +1);

		}

	}
}
