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

public class KangarooGameManager : MonoBehaviour
{
	public LevelHandling levelHandling;
	public NoteGenerator noteGenerator;

	private static KangarooGameManager instance;
	public static KangarooGameManager Instance {
		get {
			return instance;
		}
	}

	private void Awake() {
		instance = this;
	}

	private void Start() {
		RestartGame();
	}

	public void RestartGame() {
		levelHandling.currentLevel = 0;
		StartGame();
	}

	public void StartGame() {
		AssembleItemsManager.Instance.CreateObjective(levelHandling.levels[levelHandling.currentLevel].locations, levelHandling.levels[levelHandling.currentLevel].instructions);
	}

	[ContextMenu("WonGame")]
	public void SetWonGame() {
		EndGameManager.Instance.ShowEndGameScreen(EndGameManager.EndgameScreen.WinToUruguay);
	}

	[ContextMenu("LoseGame")]
	public void SetLoseGame() {
		EndGameManager.Instance.ShowEndGameScreen(EndGameManager.EndgameScreen.Lose);
	}

	[ContextMenu("CompletedGame")]
	public void CompletedLevel() {
		if (levelHandling.LevelUp()) {
			AssembleItemsManager.Instance.ClearAll();
			AssembleItemsManager.Instance.CreateObjective(levelHandling.levels[levelHandling.currentLevel].locations, levelHandling.levels[levelHandling.currentLevel].instructions);



			//TODO
			/*
				restart scene with different objective

		Set fire back
		set kangaroos to start pos
		restock food



		 */
		} else {
			SetWonGame();
		}
	}

	public void StartNewMelody(ResourceType type) {
		noteGenerator.createNotes(type);
	}

	public void CreateNewMaterial(ResourceType type) {
		AssembleItemsManager.Instance.GenerateNewItem(type);
	}

	public void exit(){
		Application.Quit();
	}
}
