using UnityEngine;
using UnityEngine.EventSystems;

public class TilePlacementButton : UnitPlacementButton
{
    public LevelTile tile;
    const string NULL = "0";

    protected override bool CanPlace()
    {
        return ResourceManager.Instance.EnoughFor(_unitCardInformation.Rock, _unitCardInformation.Wood, _unitCardInformation.Food) && base.CanPlace();
    }

    protected override DraggablePlaceholder Place()
    {
        var instance = new GameObject(tile.name);
        var placeholder = instance.AddComponent<TilePlaceholder>();
        placeholder.Tile = tile;
        var rend = instance.AddComponent<SpriteRenderer>();
        rend.sprite = tile.Sprite;
        rend.sortingLayerName = "Character";
        rend.material = OutlineMaterial;
        rend.sortingOrder = 2;
        return placeholder;
    }

    public override void OnPointerEnter(PointerEventData eventData)
    {
        TooltipManager.Instance.ShowTooltip(_unitCardInformation, NULL, NULL, NULL, false);
    }

    public override void OnPointerExit(PointerEventData eventData)
    {
        TooltipManager.Instance.HideToolTip();
    }
}
