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

public class ThemeColoredSpriteManager : MonoBehaviour {
	public enum ColorIndex {
		FirstColor,
		SecondColor,
		ThirdColor,
		FourthColor
	}

	[System.Serializable]
	public class ColorScheme {
		public Color firstColor = new Color (1.0f, 0f, 0f);
		public Color secondColor = new Color (0f, 1.0f, 0f);
		public Color thirdColor = new Color (0f, 0f, 1.0f);
		public Color fourthColor = new Color (1.0f, 1.0f, 1.0f);
	}

	public ColorScheme[] schemes;

	public ColorScheme currentScheme;

	public Color ColorFromColorIndex(ColorIndex colorIndex) {

		if(currentScheme == null) {
			currentScheme = new ColorScheme();
		}

		switch (colorIndex) {
		case ColorIndex.FirstColor:
			return currentScheme.firstColor;
		case ColorIndex.SecondColor:
			return currentScheme.secondColor;
		case ColorIndex.ThirdColor:
			return currentScheme.thirdColor;
		case ColorIndex.FourthColor:
			return currentScheme.fourthColor;
		}

		throw new System.ArgumentException ();
	}

	void Awake() {
		// if GameController is there (not debug) and if I am not with GameController, then delete myself
		// because I am there only for debugging
		GameController gc = FindObjectOfType<GameController>();
		if( gc != null && gc.colorManager != this ) {
			Destroy(gameObject);
		}
	}

	public void FadeToScheme(ColorScheme c, float seconds) {
		//TODO: implement scheme fade & apply
	}

	public void FadeToScheme(int index, float seconds) {
		//TODO: implement scheme fade & apply
	}
}
