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

public class ending : MonoBehaviour {
	private bool isPlayerInside = false;
	private Animator ani;
	private Animator camAni;

	void Start(){
		ani = GetComponent<Animator> ();
		camAni = GameObject.Find ("Main Camera").GetComponent<Animator> ();
		ani.SetInteger("state",0);
	}

	void OnTriggerEnter(Collider other){
		if (other.gameObject.name == "Player_2D") {
			isPlayerInside = true;
			camAni.SetTrigger ("Zoom");
		}
	}
	void OnTriggerExit(Collider other){
		if(other.name == "Player_2D")
			isPlayerInside = false;
	}
	void Update(){
		if (isPlayerInside && Input.GetKeyUp ("space")) {
			//diff ending
			if (ItemManager.count <= 0) {
				ani.SetInteger("state",2);
			} else {
				ani.SetInteger("state",1);
			}
		}
	}
}
