﻿using System.Linq;
using System.Net.Mime;
using UnityEngine;
using System.Collections;

using Gamelogic.Grids;

public class Cell_2dtk : TileCell
{
	protected tk2dSprite image;
	protected tk2dSprite highlight;
	protected tk2dTextMesh spriteText;

	private Color color;
	private string text;

	private bool highlightOn;

	public bool HighlightOn
	{
		set
		{
			highlightOn = value;
			
		}

		get
		{
			return highlightOn;
		}
	}

	public void Awake()
	{
		image = GetComponentsInChildren<tk2dSprite>().First(x => x.name == "Image");
		highlight = GetComponentsInChildren<tk2dSprite>().First(x => x.name == "Highlight");
		spriteText = GetComponentInChildren<tk2dTextMesh>();

		HighlightOn = false;
	}

	private void SetColor(Color color)
	{
		image.color = color;
	}

	public string Text
	{
		get { return text; }
		set
		{
			spriteText.text = value;
			spriteText.Commit();
		}
	}


	public override Color Color
	{
		get { return color; }
		set
		{
			color = value;
			__UpdatePresentation(true);
		}
	}

	public override Vector2 Dimensions
	{
		get { throw new System.NotImplementedException(); }
	}

	public override void __UpdatePresentation(bool forceUpdate)
	{
		highlight.gameObject.SetActive(highlightOn);
		image.color = color;

	}

	public override void SetAngle(float angle)
	{
		throw new System.NotImplementedException();
	}

	public override void AddAngle(float angle)
	{
		throw new System.NotImplementedException();
	}
}
