﻿using System.Collections.Generic;
using UnityEngine;

using Gamelogic.Grids;

public class LinkedGridBehaviour : GridBehaviour<PointyHexPoint>
{
	public PointyHexTileGridBuilder otherGrid;

	public void OnClick(PointyHexPoint clickedPoint)
	{
		//Normally, you would add this logic here:
		//
		//ToggleHighlight(clickedPoint);
		//
		//However, we made a design mistake with the cells; they toggle by default.
		//So in this case we do not need to duplicate the behaviour we want to happen 
		//when the cell is clicked.

		otherGrid.SendMessage("OnOtherGridClicked", clickedPoint);
	}

	public void OnOtherGridClicked(PointyHexPoint clickedPoint)
	{
		ToggleHighlight(clickedPoint);
	}

	private void ToggleHighlight(PointyHexPoint clickedPoint)
	{
		Grid[clickedPoint].GetComponent<SpriteCell>().HighlightOn = !Grid[clickedPoint].GetComponent<SpriteCell>().HighlightOn;
	}
}
