using UnityEngine;
using System.Linq;
using System.Collections;
using Gamelogic.Grids2;

public class MovePreview : MonoBehaviour {

    void StartTurn()
    {
        PreviewMoves();
    }
    
    public void PreviewMoves()
    {
        GameMap.ClearHighLight();
        foreach(GridPoint2 p in PointyHexPoint.GetOrthogonalNeighbors(CombatLib.Player.Location))
        {
            if (!GameMap.Contains(p))
                continue;

            if (GameMap.Cell[p].HasActor())
                PreviewActor(p);
            else
                GameMap.Cell[p].HighLight = true;
        }
    }
    
    private void PreviewActor(GridPoint2 pos)
    {
        Actor a = (Actor)GameMap.Cell[pos] .Actor;
        if(!a.AllowsHop)
            return;

        foreach (GridPoint2 p in PointyHexPoint.GetOrthogonalNeighbors(pos))
        {
            if (!GameMap.Contains(p))
                continue;

            if(!GameMap.Cell[p].HasActor())
                GameMap.Cell[p].HighLight = true;
        }
    }

}
