/**
 * Staticka trida pro predavani informaci napric skripty.
 * Take uchovava seznamy vsech kosticek ve scene a jejich obalovych objektu.
 */
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/**
 * Author:			Karel Zavrel
 * 
 * Thesis:			An interactive application for development of creativity
 * Application:		Little Builder
 */
public static class InnerStoringScript {
	/**
	 * staticke promenne:
	 * 	- nove vkladana kosticka do sceny
	 * 	- podminka, zda je povoleno otaceni kamery kolem objektu
	 * 	- podminka, zda je povoleno priblizovani a oddalovani kamery
	 * 	- seznam vsech kosticek umistenych ve scene - pro potreby ukladani a nacitani modelu za souboru
	 * 	- seznam vsech obalovych objektu jednotlivych kosticek
	 * 	- docasne ulozena kosticka, ktera pokud neprojde kontrolou na protnuti s jinym objektem ve scene, tak je odstranena
	 * 	- nadrazeny objekt celeho modelu
	 * 	- promenna, ktera hlida, zda je viditelny obrazek pro promitnuti mini mapy
	 * 	- promenna, ktera hlida, zda je nastaven lichy pocet vystupku kosticky v ose x
	 * 	- promenna, ktera hlida, zda je nastaven lichy pocet vystupku kosticky v ose z
	 * 	- promenna, ktera hlida, zda je dokoncen presun vybrane existujici kosticky
	 * 	- promenna, ktera hlida, zda dochazi k interakci s vybranou kostickou nebo vyberu jine
	 * 	- promenna, ktera hlida, zda je nacitan model ze souboru
	 * 	- promenna, ktera hlida, zda je nacitan model z galerie modelu
	 */
	private static GameObject newlyInsertedBrick;
	private static bool isRotationPermitted = true, isScalePermitted = true;
	private static List<GameObject> allBricksInModel = new List<GameObject>();
	private static List<Bounds> allBricksBounds = new List<Bounds>();
	private static GameObject brickToBeDeleted = null;
	private static GameObject modelsRoot;
	private static bool isMinimapImageVisible = true;
	private static bool oddCountOfCleatsXAxis = false;
	private static bool oddCountOfCleatsZAxis = false;
	private static bool movementOfSelectedBrickIsDone = false;
	private static bool movePanelClicked = false;
	private static bool isLoading = false;
	private static bool isLoadingFromGallery = false;
	/**
	 * promenne pro vyber pres paprsek
	 */
	private static GameObject selectedBrick;
	private static Bounds selectedBrickBounds;
	/**
	 * promenne pro zmenu materialu
	 */
	private static Material usedMaterial;
	/**
	 * promenna nazev tlacitka pro detailni objekt
	 */
	private static string buttonForDetailObject = "";
	/**
	 * setter pro promennou buttonForDetailObject
	 */
	public static void setButtonForDetailObject(string buttonName){
		buttonForDetailObject = buttonName;
	}
	/**
	 * getter pro promennou buttonForDetailObject
	 */
	public static string getButtonForDetailObject(){
		return buttonForDetailObject;
	}
	/**
	 * setter pro promennou modelsRoot
	 */
	public static void setModelsRoot(GameObject rootOfModel){
		modelsRoot = rootOfModel;
	}
	/**
	 * getter pro promennou modelsRoot
	 */
	public static GameObject getModelsRoot(){
		return modelsRoot;
	}
	/**
	 * getter pro promennou newlyInsertedBrick
	 */
	public static GameObject getNewlyInsertedBrick(){
		return newlyInsertedBrick;
	}
	/**
	 * setter pro promennou newlyInsertedBrick
	 */
	public static void setNewlyInsertedBrick(GameObject newBrick){
		newlyInsertedBrick = newBrick;
	}
	/**
	 * getter pro promennou isRotationPermitted
	 */
	public static bool getIsRotationPermitted(){
		return isRotationPermitted;
	}
	/**
	 * setter pro promennou isRotationPermitted
	 */
	public static void setIsRotationPermitted(bool permission){
		isRotationPermitted = permission;
	}
	/**
	 * getter pro promennou isScalePermitted
	 */
	public static bool getIsScalePermitted(){
		return isScalePermitted;
	}
	/**
	 * setter pro promennou isScalePermitted
	 */
	public static void setIsScalePermitted(bool permission){
		isScalePermitted = permission;
	}
	/**
	 * funkce pro pridani kosticky do listu
	 */
	public static void addBrickToList(GameObject brick){
		brickToBeDeleted = null;
		allBricksInModel.Add (brick);
	}
	/**
	 * funkce vlozi rootBrick na prvni pozici
	 */
	public static void addRootBrickToListAsFirstElement(GameObject rootBrick){
		if (!containsRoot (rootBrick)) {
			allBricksInModel.Insert (0, rootBrick);
		}
	}
	/**
	 * funkce overi, zda uz list neobsahuje rootBrick
	 */
	private static bool containsRoot(GameObject rootBrick){
		if (allBricksInModel.Count > 0) {
			for (int i = 0; i < allBricksInModel.Count; i++) {
				if ((allBricksInModel[i] != null) && (allBricksInModel [i].name == rootBrick.name)) {
					return true;
				}
			}
		}
		return false;
	}
	/**
	 * funkce pro pridani obaloveho objektu kosticky do listu
	 */
	public static void addBoundsToList(Bounds brickBounds){
		allBricksBounds.Add (brickBounds);
	}
	/**
	 * getter pro promennou allBricksBounds
	 */
	public static List<Bounds> getAllBricksBounds(){
		return allBricksBounds;
	}
	/**
	 * funkce pro nastaveni kosticky pro smazani (jeste neni validne pridana)
	 */
	public static void setBrickToDeleted(GameObject brick){
		brickToBeDeleted = brick;
	}
	/**
	 * funkce pro smazani posledni kosticky ze spravne pridanych
	 */
	public static GameObject removeLastBrick(){
		GameObject deletedBrick = null;
		if (allBricksInModel.Count > 1) {
			deletedBrick = allBricksInModel [allBricksInModel.Count - 1];
			allBricksInModel.RemoveAt (allBricksInModel.Count - 1);
		}
		return deletedBrick;
	}
	/**
	 * funkce na ziskani posledniho obaloveho objektu kosticky, ktera byla spravne pridana
	 */
	public static Bounds removeLastBounds(){
		Bounds deletedBounds = new Bounds ();
		if (allBricksBounds.Count > 0) {
			deletedBounds = allBricksBounds [allBricksBounds.Count - 1];
			allBricksBounds.RemoveAt (allBricksBounds.Count - 1);
		}
		return deletedBounds;
	}
	/**
	 * funkce pro ziskani spatne vlozene kosticky
	 */
	public static GameObject getBrickToBeDeleted(){
		return brickToBeDeleted;
	}
	/**
	 * setter pro promennou isMinipamImageVisible
	 */
	public static void setIsMinimapImageVisible(bool visibility){
		isMinimapImageVisible = visibility;
	}
	/**
	 * getter pro promennou isMinipamImageVisible
	 */
	public static bool getIsMinimapVisible(){
		return isMinimapImageVisible;
	}
	/**
	 * setter pro promennou oddCountOfCleatsXAxis
	 */
	public static void setOddCountOfCleatsXAxis(bool cond){
		oddCountOfCleatsXAxis = cond;
	}
	/**
	 * getter pro promennou oddCountOfCleatsXAxis
	 */
	public static bool getOddCountOfCleatsXAxis (){
		return oddCountOfCleatsXAxis;
	}
	/**
	 * setter pro promennou oddCountOfCleatsZAxis
	 */
	public static void setOddCountOfCleatsZAxis(bool cond){
		oddCountOfCleatsZAxis = cond;
	}
	/**
	 * getter pro promennou oddCountOfCleatsZAxis
	 */
	public static bool getOddCountOfCleatsZAxis (){
		return oddCountOfCleatsZAxis;
	}
	/**
	 * setter pro promennou selectedBrick
	 */
	public static void setSelectedBrick(GameObject brick){
		selectedBrick = brick;
	}
	/**
	 * getter pro promennou selectedBrick
	 */
	public static GameObject getSelectedBrick(){
		return selectedBrick;
	}
	/**
	 * setter pro promennou selectedBrickBounds
	 */
	public static void setSelectedBrickBounds(Bounds bounds){
		selectedBrickBounds = bounds;
	}
	/**
	 * getter pro promennou selectedBrickBounds
	 */
	public static Bounds getSelectedBrickBounds(){
		return selectedBrickBounds;
	}
	/**
	 * setter pro promennou usedMaterial
	 */
	public static void setUsedMaterial(Material material){
		usedMaterial = material;
	}
	/**
	 * getter pro promennou usedMaterial
	 */
	public static Material getUsedMaterial(){
		return usedMaterial;
	}
	/**
	 * funkce pro odstraneni kostky z listu
	 */
	public static void removeBrickFromList(GameObject brick){
		allBricksInModel.Remove (brick);
	}
	/**
	 * funkce pro odstraneni obaloveho objektu kosticky z listu
	 */
	public static void removeBoundsFromList(Bounds bounds){
		allBricksBounds.Remove (bounds);
	}
	/**
	 * setter pro promennou movementOfSelectedBrickIsDone
	 */
	public static void setMoveOfSelectedBrickIsDone(bool done){
		movementOfSelectedBrickIsDone = done;
	}
	/**
	 * getter pro promennou movementOfSelectedBrickIsDone
	 */
	public static bool getMoveOfSelectedBrickIsDone(){
		return movementOfSelectedBrickIsDone;
	}
	/**
	 * setter pro promennou movePanelClicked
	 */
	public static void setMovePanelClicked(bool clicked){
		movePanelClicked = clicked;	// nastavit pri kliku na presun nebo smazani
	}
	/**
	 * getter pro promennou movePanelClicked
	 */
	public static bool getMovePanelClicked(){
		return movePanelClicked;
	}
	/**
	 * getter pro promennou allBricksInModel
	 */
	public static List<GameObject> getAllBricksInModel(){
		return allBricksInModel;
	}
	/**
	 * setter pro promennou isLoading
	 */
	public static void setIsLoading(bool loading){
		isLoading = loading;
	}
	/**
	 * getter pro promennou isLoading
	 */
	public static bool getIsLoading(){
		return isLoading;
	}
	/**
	 * setter pro promennou isLoadingFromGallery
	 */
	public static void setIsLoadingFromGallery(bool loading){
		isLoadingFromGallery = loading;
	}
	/**
	 * getter pro promennou isLoadingFromGallery
	 */
	public static bool getIsLoadingFromGallery(){
		return isLoadingFromGallery;
	}
	/**
	 * funkce pro nastaveni promenne allBrickInModel na novy prazdny list
	 */
	public static void setAllBricksInModelOnNew(){
		allBricksInModel = new List<GameObject> ();
	}
	/**
	 * funkce pro nastaveni promenne allBricksBounds na novy prazdny list
	 */
	public static void setAllBricksBoundsOnNew(){
		allBricksBounds = new List<Bounds> ();
	}

		/**public static GameObject returnBrick(){
				return allBricksInModel [allBricksInModel.Count - 1];
		}*/
}