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

public class SceneManager : MonoBehaviour {

	public GameObject Player;
	public GameObject CameraPOV;
	public ChatManager ChatManagerScript;
	public AudioMixerSnapshot PlaySnapshot;
	public AudioMixerSnapshot MenuSnapshot;
	public bool StartGame;
	public int levelCount;
	int previousLevelCount;

	public List<GameObject> Monsters;

	// Use this for initialization
	void Start () {
		levelCount = 0;
		StartGame = false;
		ChatManagerScript.onDialogueSpawn += GameStart;
	}
	
	// Update is called once per frame
	void Update () {
		if (StartGame) {
			Player.GetComponent<PlayerController> ().startGame = true;
			CameraPOV.GetComponent<CameraPOV> ().StartGame = true;
		} else if (!StartGame) {
			Player.GetComponent<PlayerController> ().startGame = false;
			CameraPOV.GetComponent<CameraPOV> ().StartGame = false;
		}
		if (levelCount < 5) {
			Monsters [previousLevelCount].SetActive (false);
			Monsters [levelCount].SetActive (true);
		}
	}

	public void GameStart(){
		StartGame = true;
		PlaySnapshot.TransitionTo (0.5f);
	}

	public void Menu(){
		previousLevelCount = levelCount;
		levelCount ++;
		StartGame = false;
		MenuSnapshot.TransitionTo (0.5f);
		ChatManagerScript.PlayDialogue ();
	}
}
