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

public class TileManager : MonoBehaviour {

	#region variables
	protected Tile[] _tiles;

	[SerializeField]
	protected Texture _dayTex;

	[SerializeField]
	protected Texture[] _nightTex;
	#endregion

	#region events
	void Awake () {

		_tiles = GameObject.FindObjectsOfType <Tile> ();

	}
	#endregion


	#region methods
	public void SwitchTiles (GameTime gameTime) {

		foreach (Tile tl in _tiles) {
			tl.GetMaterial ().mainTexture = (gameTime == GameTime.Night) ? GetNightTexture () : _dayTex;
			tl.GetMaterial ().color = (gameTime == GameTime.Day) ? tl.DefaultColor : Color.white;
		}
		
	}

	Texture GetNightTexture () {

		return _nightTex [Random.Range (0, _nightTex.Length)];
		
	}
	#endregion
	
}
